How can I perform image analysis only within object's boundary?

1 visualizzazione (ultimi 30 giorni)
I have an image on which I’m performing superpixel segmentation. The object within the image is irregularly shaped, so that although the .tif image dimensions are 213x365, the actual object in the image goes from 4 to 176px height and 19 to 335px width. (Image attached – 15NC.) 15NC.jpgThe rest of the area is the background. So when I perform the segmentation, it accounts for the white background as well. (Image attached – S15NC.)
S15NC.jpg
Is there a way I can tell the program to only operate within the object boundary?
I tried setting the background pixel values to 0 (instead of 255) but that didn’t help. Then I set all the 255’s to [ ] but that left me with a row matrix of over 20,00 values – it took out all the pixel values of 255 but I don’t know how to reshape the row matrix into the image object’s shape because it’s irregular.
I did trace the boundary with bwboundaries but I’m still unclear on how to exclude the background so the segmentation is only done on the image object.
Anyone know how I can do this?

Risposte (1)

Image Analyst
Image Analyst il 18 Ott 2019
superpixels() gives you a labeled image. You can get a mask for a particular boundary by passing the labeled image into ismember(), for example, to get a binary image of just superpixel #24, do this:
mask = ismember(labeledImage, 24);
Now you can pass that into regionprops() to get some measurements or do your own thing with the mask - whatever you want to do.

Community Treasure Hunt

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

Start Hunting!

Translated by