2

I'm currently working on image processing project and I need to detect edges from image. I thought to use canny edge detection for detect lines of the image, So i searched about canny edge detection using javacv on internet and I found some tutorials which gives the basic idea about canny edge detection technique but I could not be able to find any sample code regarding this. Please can someone provide simple sample edge detection code ?

It’s really appreciate if you can provide code example for following image.

enter image description here

Gum Slashy
  • 385
  • 5
  • 19

1 Answers1

1

For canny edge detection you need to perform like following.

IplImage gray = ...

cvCvtColor(colored, gray, CV_RGB2GRAY); 
cvSmooth( gray, smooth, CV_BLUR, 9, 9, 2, 2);   
cvThreshold(gray,gray, 155, 255, CV_THRESH_BINARY);

cvCanny( gray, gray, lowThreshold, highThreshold, aperature_size );  

Check this Question and Answer for more detail

Community
  • 1
  • 1
Nikson Kanti Paul
  • 3,211
  • 1
  • 31
  • 49
  • could you please tell me what are the lowThreshold and highThreshold means ? are those need to calculate seperatly ? – Gum Slashy Oct 21 '12 at 11:38
  • Yes , you should calculate them using histogram of the image.As in real world scenarios the background can be very close to the main part of the image(I assume u are extracting something out of the full image) or very different from that .So if you manually decide the values , it is very possible to get bad result .Sometimes u won't get any edge detected and some you will have lots of possible edges that your implementation detect and which will make you unable to select/identify the part were looking for. – Ankur Gautam Jan 24 '14 at 05:24