0

Sobel Edge detection:
Sobel Edge detection

Original Image:
Original Image

I have used sobel edge detection technique to identify the boundaries of each object in the given image. How can I extract the objects in the original image using these boundaries. We can ignore the objects with smaller pixel count.

Shai
  • 111,146
  • 38
  • 238
  • 371
vishnu
  • 11
  • 2
  • 2
  • That is hard. The best thing is that you try to find rectangles that fit to the edges, or something like that. Also, I personally like Canny more, you may want to try it – Ander Biguri Oct 17 '16 at 12:08
  • Possible duplicate of [Image segmentation based on edge pixel map](http://stackoverflow.com/questions/18972932/image-segmentation-based-on-edge-pixel-map) – Shai Oct 17 '16 at 20:19
  • Use Sobel is not going to be enough for your problem. See answer from Yves Daoust. – FiReTiTi Oct 17 '16 at 21:35

2 Answers2

1

What you are after is called image segmentation. Your case looks particularly difficult because of low contrast between the furniture elements, and because of texture and shadows.

You will also realize that you need to define what you call an "object" and you will realize that it is about impossible to isolate the pieces of furniture in this scene.

Another bad news: neither Sobel nor Canny will be good enough to address this, as the true edges will be discontinous at places and there will be many false responses.

In my opinion, the current state of the art does not allow to solve your problem.

0

What

You want to use cv2.findContours() with hierarchy enabled. Try retr_ccomp.

Why

That will try to find the regions that can be filled in. Or, more precisely, holes in closed contours. Since the sobel filter returned soft edges, we want to detect the closed contours among the soft edges, which will simply be the edges themselves. The holes are the objects.

How

You'll get both a contours, a list of points, and hierarchy, a list of tuples. If hierarchy[i][3] is positive, then contours[i] has a parent, and therefore is a hole, since ccomp only allows 2 levels.

I should note we've been working on the image segmentation problem for 50 years and no one has a great solution. You will find that this approach is often unreliable for arbitrary scenes.

Jacob Panikulam
  • 1,196
  • 1
  • 9
  • 12