Ask Your Question
0

Getting a shape out of edges Canny algorithm

asked 2013-06-04 04:46:45 -0600

william13200 gravatar image

Hi there, i'm extracting an img from a file ( then i will be doing this from a capture ) and i'm using canny algorithms in order to get its edges. this works fine but i guess i'm stuck here because it doesn't seem obvious how to use this result:

i would like to get something like a shape that would fit the best way as possible the edge of the result. How would you do this?

for instance: getting the edges of a building, how would you actually get the rectangular shape out of it?

NB: cvtColor (image,imageGray,CV_BGR2GRAY); blur(imageGray,edge,Size(3,3)); Canny(edge,edge,edgeThresh,edgeThresh*3,3); Cedge = Scalar::all(0); // important image.copyTo(Cedge,edge);

i'm converting to Gray then processing the canny algorithm. Do you think rather converting to black&white would give better result?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-06-04 04:58:55 -0600

berak gravatar image

edge detection filters, like sobel or canny will give you only an image with edges in .

i guess, you want something like an outline, so look at findContours .

your pipeline will look like this:

  • grayscale
  • binarize (threshold, compare,canny,etc)
  • findContours
    • process the vector of contours
edit flag offensive delete link more

Comments

thanks, very helpful!

william13200 gravatar imagewilliam13200 ( 2013-06-04 06:20:50 -0600 )edit

Question Tools

Stats

Asked: 2013-06-04 04:46:45 -0600

Seen: 1,985 times

Last updated: Jun 04 '13