Ask Your Question

Edge detection

asked 2018-05-03 07:10:06 -0600

Safa gravatar image

Hello, I'm using canny for contour detection, I only need to detect the bounds/edges of my objects but it picks up all the details of the objects. I tried morphological transformations but it doesn't help much/it affects important contours. Is there any way to get only the bounds/edges of the objects without losing any information?

Here's my original image Here's the canny output

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2018-05-03 09:06:16 -0600

lezan gravatar image

updated 2018-05-03 09:07:25 -0600

You can try in this way:

  1. Apply threholding because you need a binary image.
  2. Apply morphological operator: first Open, then Close. Try with different SE.
  3. Use findContours.
  4. Use drawContours() with the original image.

You can try to convert to grayscale before the first threholding.

You can try to use Canny operator instead of threholding and morphogical operator before findContours().

Basically you need is a binary image as input for findContours.

Suggestion: you can also extract boundary in this way: A - (A EROSION B), where A is your image and B is your SE.

edit flag offensive delete link more

answered 2018-05-03 07:37:42 -0600

RazeK gravatar image

Try smoothing the image before applying the canny operator. The main idea is to keep the abrupt changes (high frequency) between the different objects, and at the same time smoothing the changes within the same object (low frequency). I think you can use a median filter or a bilateral filter (slower) for this.

Referencia: link text

I hope it helps you

edit flag offensive delete link more


Sadly it doesn't change much, I also tried making the kernel size bigger but it ended up removing some of the important contours

Safa gravatar imageSafa ( 2018-05-03 07:46:29 -0600 )edit

Question Tools

1 follower


Asked: 2018-05-03 07:10:06 -0600

Seen: 512 times

Last updated: May 03 '18