When I use the canny edge algorithm, it creates 2 edges opposite the thick color line, as expected, but I want only one edge to be displayed to make the line and curve detection algorithm much less complicated, any ideas about how I can do this?

Here is the code:
bool CannyEdgeDetection(DataStructure& col) { Mat src, src_gray; Mat dst, detected_edges, fin; int WhiteCount = 0, BCount = 0; char szFil1[32] = "ocv.bmp"; char szFil2[32] = "dst.bmp"; src = imread(szFil1); dst = imread(szFil1); blur( src_gray, detected_edges, Size(3,3) ); Canny( src, dst, 100, 200, 3 ); imwrite(szFil2, dst ); IplImage* img = cvLoadImage(szFil2); int height = img->height; int width = img->width; int step = img->widthStep; int channels = img->nChannels; uchar * datau = (uchar *)img->imageData; for(int i=0;i<height;i++){ for(int j=0;j<width;j++){ for(int k=0;k<channels;k++){ datau[i*step+j*channels+k] = 255 - datau[i*step+j*channels+k]; if (datau[i*step+j*channels+k]==0){ WhiteCount++; col.pixel_col [i][j] = 2; } else{BCount++; col.pixel_col[i][j] = 0; } } } } cvSaveImage("img.bmp" ,img); return 0; }
This is not an original image, but similar:

What part do I comment to read black images on a white background? or any color image?
bool done; do { cv::morphologyEx(img, temp, cv::MORPH_OPEN, element); cv::bitwise_not(temp, temp); cv::bitwise_and(img, temp, temp); cv::bitwise_or(skel, temp, skel); cv::erode(img, img, element); double max; cv::minMaxLoc(img, 0, &max); done = (max == 0); } while (!done);
Gambit king
source share