The design functions are as follows:
which
void int int low);
In the parameter list, the first entry is the grayscale image to be traced, and the second is the output image.
The third high is the detection threshold, and the fourth low is the tracking threshold value.
voidGratingdetect (Mat &graysrc, Mat &graydst,intHighintLow ) { intRowNum =graysrc.rows; intColnum =Graysrc.cols; for(inti =0; i < RowNum; i++) {Uchar* D_data = graydst.ptr<uchar>(i); Uchar* S_data = graysrc.ptr<uchar>(i); for(intj =0; J < Colnum; J + +) { if(S_data[j] >=High ) {D_data[j]=255; inttemp =S_data[j]; if(I < rowNum-1) {D_data= graydst.ptr<uchar> (i +1); S_data= graysrc.ptr<uchar> (i +1); if(J >0&& J < Colnum-1) { for(intK =-1; K <2; k++) { if(ABS (Temp-s_data[j + K]) <=Low ) D_data[j+ K] =255; Elsed_data[j+ K] =0; }} d_data= graydst.ptr<uchar>(i); S_data= graysrc.ptr<uchar>(i); } } ElseD_data[j]=0; } }}
"OpenCV, C + +" implements down-grating tracking to detect edges