Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bugfix radon transform#3847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Dugnom wants to merge5 commits intoopencv:4.x
base:4.x
Choose a base branch
Loading
fromDugnom:bugfix_radon-transform
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletionsmodules/ximgproc/src/radon_transform.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ namespace cv {namespace ximgproc {
_col_num = cvRound((end_angle - start_angle) / theta);
transpose(_srcMat, _srcMat);
Mat _masked_src;
cv::Point _center;
Point2f _center;

if (_srcMat.type() == CV_32FC1 || _srcMat.type() == CV_64FC1) {
_out_mat_type = CV_64FC1;
Expand All@@ -35,26 +35,26 @@ namespace cv {namespace ximgproc {
if (crop) {
// crop the source into square
_row_num = min(_srcMat.rows, _srcMat.cols);
cv::Rect _crop_ROI(
_srcMat.cols / 2 - _row_num / 2,
_srcMat.rows / 2 - _row_num / 2,
_row_num, _row_num);
_srcMat = _srcMat(_crop_ROI);
Point2f _srcCenter = Point2f(_srcMat.cols / 2.f - 0.5f, _srcMat.rows / 2.f - 0.5f);
Mat _squared_src = Mat(Size(_row_num, _row_num), _srcMat.type(), Scalar(0));
_center = Point2f(_squared_src.cols / 2.f - 0.5f, _squared_src.rows / 2.f - 0.5f);
Point2f _offset = _center - _srcCenter;
Mat _t_matrix = (Mat1f(2, 3) << 1, 0, _offset.x, 0, 1, _offset.y);
warpAffine(_srcMat, _squared_src, _t_matrix, _squared_src.size());
// crop the source into circle
Mat _mask(_srcMat.size(), CV_8UC1, Scalar(0));
_center = Point(_srcMat.cols / 2, _srcMat.rows / 2);
circle(_mask, _center, _srcMat.cols / 2, Scalar(255), FILLED);
_srcMat.copyTo(_masked_src, _mask);
Mat _mask(_squared_src.size(), CV_8UC1, Scalar(0));
circle(_mask, _center * 2, _srcMat.cols, Scalar(255), FILLED, LINE_8, 1);
_squared_src.copyTo(_masked_src, _mask);
}
else {
// avoid cropping corner when rotating
_row_num = cvCeil(sqrt(_srcMat.rows * _srcMat.rows + _srcMat.cols * _srcMat.cols));
_masked_src = Mat(Size(_row_num, _row_num), _srcMat.type(), Scalar(0));
_center =Point(_masked_src.cols / 2, _masked_src.rows / 2);
_srcMat.copyTo(_masked_src(Rect(
(_row_num - _srcMat.cols) / 2,
(_row_num - _srcMat.rows) / 2,
_srcMat.cols, _srcMat.rows)));
_center =Point2f(_masked_src.cols / 2.f - 0.5f, _masked_src.rows / 2.f - 0.5f);
Point2f _srcCenter = Point2f(_srcMat.cols / 2.f - 0.5f, _srcMat.rows / 2.f - 0.5f);
Point2f _offset = _center - _srcCenter;
Mat _t_matrix = (Mat1f(2, 3) << 1, 0, _offset.x, 0, 1, _offset.y);
warpAffine(_srcMat, _masked_src, _t_matrix, _masked_src.size());
}

double _t;
Expand All@@ -64,11 +64,11 @@ namespace cv {namespace ximgproc {
for (int _col = 0; _col < _col_num; _col++) {
// rotate the source by _t
_t = (start_angle + _col * theta);
cv::Mat _r_matrix =cv::getRotationMatrix2D(_center, _t, 1);
cv::warpAffine(_masked_src, _rotated_src, _r_matrix, _masked_src.size());
Mat _r_matrix = getRotationMatrix2D(_center, _t, 1);
warpAffine(_masked_src, _rotated_src, _r_matrix, _masked_src.size());
Mat _col_mat = _radon.col(_col);
// make projection
cv::reduce(_rotated_src, _col_mat, 1, REDUCE_SUM, _out_mat_type);
reduce(_rotated_src, _col_mat, 1, REDUCE_SUM, _out_mat_type);
}

if (norm) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp