@@ -34,7 +34,7 @@ namespace cv {namespace ximgproc {
34
34
if (crop) {
35
35
// crop the source into square
36
36
_row_num = min (_srcMat.rows , _srcMat.cols );
37
- cv:: Rect _crop_ROI (
37
+ Rect _crop_ROI (
38
38
_srcMat.cols / 2 - _row_num / 2 ,
39
39
_srcMat.rows / 2 - _row_num / 2 ,
40
40
_row_num, _row_num);
@@ -58,23 +58,28 @@ namespace cv {namespace ximgproc {
58
58
59
59
double _t;
60
60
Mat _rotated_src;
61
+ Mat _radon (_row_num, _col_num, _out_mat_type);
61
62
62
- // Initialize dst with appropriate size and type
63
- dst.create (_row_num, _col_num, _out_mat_type);
64
- Mat _radon = dst.getMat (); // Get reference to the output matrix
63
+ // Define the parallel loop as a lambda function
64
+ cv::parallel_for_ (Range (0 , _col_num), [&](const Range& range) {
65
+ for (int _col = range.start ; _col < range.end ; _col++) {
66
+ // rotate the source by _t
67
+ double _t = (start_angle + _col * theta);
68
+ Mat _r_matrix = getRotationMatrix2D (_center, _t, 1 );
65
69
66
- for (int _col = 0 ; _col < _col_num; _col++) {
67
- // rotate the source by _t
68
- _t = (start_angle + _col * theta);
69
- cv::Mat _r_matrix = cv::getRotationMatrix2D (_center, _t, 1 );
70
- cv::warpAffine (_masked_src, _rotated_src, _r_matrix, _masked_src.size ());
71
- Mat _col_mat = _radon.col (_col);
72
- // make projection
73
- cv::reduce (_rotated_src, _col_mat, 1 , REDUCE_SUM, _out_mat_type);
74
- }
70
+ Mat _rotated_src;
71
+ warpAffine (_masked_src, _rotated_src, _r_matrix, _masked_src.size ());
72
+
73
+ Mat _col_mat = _radon.col (_col);
74
+ // make projection
75
+ reduce (_rotated_src, _col_mat, 1 , REDUCE_SUM, _out_mat_type);
76
+ }
77
+ });
75
78
76
79
if (norm) {
77
80
normalize (_radon, _radon, 0 , 255 , NORM_MINMAX, CV_8UC1);
78
81
}
82
+
83
+ _radon.copyTo (dst);
79
84
}
80
85
} }
0 commit comments