@@ -34,7 +34,7 @@ namespace cv {namespace ximgproc {
3434 if (crop) {
3535 // crop the source into square
3636 _row_num = min (_srcMat.rows , _srcMat.cols );
37- cv:: Rect _crop_ROI (
37+ Rect _crop_ROI (
3838 _srcMat.cols / 2 - _row_num / 2 ,
3939 _srcMat.rows / 2 - _row_num / 2 ,
4040 _row_num, _row_num);
@@ -58,23 +58,28 @@ namespace cv {namespace ximgproc {
5858
5959 double _t;
6060 Mat _rotated_src;
61+ Mat _radon (_row_num, _col_num, _out_mat_type);
6162
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 );
6569
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+ });
7578
7679 if (norm) {
7780 normalize (_radon, _radon, 0 , 255 , NORM_MINMAX, CV_8UC1);
7881 }
82+
83+ _radon.copyTo (dst);
7984 }
8085} }
0 commit comments