@@ -69,10 +69,9 @@ SC_MODULE(Tb_top)
6969 Mat colorImage;
7070
7171 unsigned char localR, localG, localB;
72- unsigned char localResult;
72+ unsigned short int localResult;
7373
74- int localWindow[3 ][3 ];
75- int localGradientX, localGradientY;
74+ short int localGradientX, localGradientY;
7675
7776 int total_number_of_pixels;
7877 int current_number_of_pixels = 0 ;
@@ -115,12 +114,11 @@ SC_MODULE(Tb_top)
115114 dbgprint (" After doing a read in TB" );
116115 dbgprint (" Data_returned: %0d" , *data_returned);
117116
118- localResult = *data_returned;
119- grayImage.at <uchar>(i, j) = localResult;
117+ grayImage.at <uchar>(i, j) = *data_returned;
120118
121119 current_number_of_pixels++;
122120 if (((((float )(current_number_of_pixels)) / ((float )(total_number_of_pixels))) * 100.0 ) >= next_target_of_completion) {
123- dbgprint (" Image processing completed at %0d " , next_target_of_completion);
121+ dbgprint (" Image processing completed at %f " , next_target_of_completion);
124122 next_target_of_completion += 10.0 ;
125123 }
126124 }
@@ -317,12 +315,19 @@ SC_MODULE(Tb_top)
317315 detectedImageY.at <uchar>(i, j) = (unsigned char )localGradientY;
318316 }
319317
320- localResult = (unsigned char )sqrt ((float )(pow (localGradientX, 2 )) + (float )(pow (localGradientY, 2 )));
321- detectedImage.at <uchar>(i, j) = localResult;
318+ localResult = (unsigned short int )sqrt ((float )(pow (localGradientX, 2 )) + (float )(pow (localGradientY, 2 )));
319+ if (localResult > 255 )
320+ {
321+ detectedImage.at <uchar>(i, j) = 255 ;
322+ }
323+ else
324+ {
325+ detectedImage.at <uchar>(i, j) = (unsigned char )localResult;
326+ }
322327
323328 current_number_of_pixels++;
324329 if (((((float )(current_number_of_pixels)) / ((float )(total_number_of_pixels))) * 100.0 ) >= next_target_of_completion) {
325- dbgprint (" Image processing completed at %0d " , next_target_of_completion);
330+ dbgprint (" Image processing completed at %f " , next_target_of_completion);
326331 next_target_of_completion += 10.0 ;
327332 }
328333 }
0 commit comments