Edge Detection Using OpenCV (Canny)

I am trying to detect rectangles using OpenCV. However, sometimes it becomes quite difficult after running the Canny method, because two of the edges are usually deleted. I tried many different sets of thresholds and blurred it before applying Canny, but so far I have no serious positive results. I am not currently blurring the image, so this is pretty much what I am doing:

Mat imgSource = Highgui.imread(filepath); Imgproc.Canny(imgSource, imgSource, 300, 600, 5, true); 

Example:

original http://imagizer.imageshack.us/a/img822/8776/27i9j.jpg Canny http://imagizer.imageshack.us/a/img841/9868/wkc95.jpg

Then I try to find the OpenCV findContours method to detect the rectangle, it works 80% of the time, how can I improve it?

+7
java android opencv
source share
2 answers

Try with a different threshold value, in which case you will get a better result when using lower threshold values, for example 10 100.

 blur(src,src,Size(3,3)); cvtColor(src,tmp,CV_BGR2GRAY); Canny( src, thr, 10, 100, 3 ); 

Or else you will get outline images by applying threshold like,

 threshold(tmp,thr,50,255,THRESH_BINARY_INV); 
+7
source share

the problem here is probably a JPEG image compression file.
try converting the image to monochrome , since you only have a black and white image and edit the threshold value. This should eliminate the noise around the edges of the lines. then canny can be applied with any values.

+2
source share

All Articles