Skip to content

Commit

Permalink
Update radon_transform.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sturkmen72 authored Oct 21, 2024
1 parent c49e156 commit f08a0da
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions modules/ximgproc/src/radon_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace cv {namespace ximgproc {
if (crop) {
// crop the source into square
_row_num = min(_srcMat.rows, _srcMat.cols);
cv::Rect _crop_ROI(
Rect _crop_ROI(
_srcMat.cols / 2 - _row_num / 2,
_srcMat.rows / 2 - _row_num / 2,
_row_num, _row_num);
Expand All @@ -58,23 +58,28 @@ namespace cv {namespace ximgproc {

double _t;
Mat _rotated_src;
Mat _radon(_row_num, _col_num, _out_mat_type);

// Initialize dst with appropriate size and type
dst.create(_row_num, _col_num, _out_mat_type);
Mat _radon = dst.getMat(); // Get reference to the output matrix
// Define the parallel loop as a lambda function
cv::parallel_for_(Range(0, _col_num), [&](const Range& range) {
for (int _col = range.start; _col < range.end; _col++) {
// rotate the source by _t
double _t = (start_angle + _col * theta);
Mat _r_matrix = getRotationMatrix2D(_center, _t, 1);

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 _col_mat = _radon.col(_col);
// make projection
cv::reduce(_rotated_src, _col_mat, 1, REDUCE_SUM, _out_mat_type);
}
Mat _rotated_src;
warpAffine(_masked_src, _rotated_src, _r_matrix, _masked_src.size());

Mat _col_mat = _radon.col(_col);
// make projection
reduce(_rotated_src, _col_mat, 1, REDUCE_SUM, _out_mat_type);
}
});

if (norm) {
normalize(_radon, _radon, 0, 255, NORM_MINMAX, CV_8UC1);
}

_radon.copyTo(dst);
}
} }

0 comments on commit f08a0da

Please sign in to comment.