Hey, Im trying to segment out a polygon region out of an image. I have already got the boundary pixels . Can you please help me in finding out the pixel values inside the boundary.
Thank You

 Réponse acceptée

Sean de Wolski
Sean de Wolski le 7 Mar 2011

0 votes

Okay, use IMFILL or POLY2MASK to generate a logical mask and then multiply it by the image to preserve the content inside the mask. I.e.
For grayscale images:
Imasked = I.*cast(Mask,class(I));
or for RGB images:
Imasked = bsxfun(@times,I,cast(Mask,class(I)));

Plus de réponses (4)

Gaurav  Kaila
Gaurav Kaila le 7 Mar 2011

0 votes

Thanks For Replying, but i have already tried these functions. What i need is , that image part that i am segmenting out, is displayed as an image itself with its original data inside it.
Like when we crop an image, the original data of the cropped image remains in it.
Gaurav  Kaila
Gaurav Kaila le 7 Mar 2011

0 votes

Thanks a Lot, I am very new to MATLAB, can you please elaborate on this answer a little more.
Thanks Again.

Community Treasure Hunt

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

Start Hunting!

Translated by