Extract each object after edge detection using sobel filter
<p>Sobel Edge detection:<br>
<img src="https://i.stack.imgur.com/bbgpD.png" alt="Sobel Edge detection"></p>

<p>Original Image:<br>
<img src="https://i.stack.imgur.com/L8yvq.jpg" alt="Original Image"></p>

<p>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.</p>

<h1>What</h1>

<p>You want to use <code>cv2.findContours()</code> with <a href="http://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours" rel="nofollow">hierarchy enabled</a>. Try retr_ccomp.</p>

<h1>Why</h1>

<p>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 <strong>holes</strong> are the objects. </p>

<h1>How</h1>

<p>You'll get both a <code>contours</code>, a list of points, and <code>hierarchy</code>, 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.</p>

<p>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. </p>

python opencv image-processing image-segmentation skimage