Ayaz Amin
Ayaz Amin

Reputation: 180

How to segment images so that the result is just the segmented image (no background whatsoever)

I am working on a computer vision project that involves the segmentation of images. However, I do not want a 'normal' segmentation (like this), rather, I want a segmentation that only leaves the desired image itself, without even a blank background (similar to this).

Right now, I am thinking that the background needs to be set to the alpha channel after image segmentation, after which the image can be fed into a probabilistic program. Is that the proper way to approach this, or do I need to perform additional preprocessing to segment the desired image BTW, I am working with opencv-python.

Upvotes: 0

Views: 318

Answers (1)

Vu Gia Truong
Vu Gia Truong

Reputation: 1032

The image you're providing is segmentation results for different approaches.

  1. The image at first image is the result image of semantic segmentation. In this semantic segmentation task, you have do define which pixel are belonging to which class
  2. The image at second image is the result image of hierarchical segmentation. In this hierachical segmentation task, you have to group pixel and find the relationship between them.

So from first image, you have to apply the "hierarchical analyzing", then you will have the result as second image. The easiest approach using opencv is :

  1. considering each class as one contour
  2. Find the contours hierarchy . Some tut here : contour hierachy

Hope this help.

Upvotes: 1

Related Questions