Image segmentation in matlab

Hello, i am trying to extract an object from an image. I want to extract the butterfly from the image. I tried using otsu thresholding and the result i get are not satisfied. I want to extract it perfectly with just the butterfly only. Anyone can provide me some guidance?

 Accepted Answer

Image Analyst
Image Analyst on 8 Apr 2017
The computer doesn't know that butterflies aren't supposed to have pointy triangle heads so it would be hard to get rid of that part unless you had know shape templates that you could fit to it, perhaps using the Hausdorf distance.
To get rid of the black thing on the lower left, you can try to use imclose() followed by bwareafilt(~binaryImage, 1) to extract only the largest blob. Better would be to probably start with a full color image with less noise in it.
Worst case you can use imfreehand() to "chop off" the parts you don't want. Demo attached.

3 Comments

Easy, except for the triangular head thing. Just find dark pixels that are not in the red - green range of hues. Try the HSV color segmentation demo in my File Exchange http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
or else try the Color Thresholder app on the Apps tab of the tool ribbon.
What happened to your original image? It's not attached anymore. Also, please attach your m-file.

Sign in to comment.

More Answers (0)

Tags

No tags entered yet.

Asked:

on 8 Apr 2017

Edited:

on 10 Apr 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!