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

 Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 7 Mär. 2011

0 Stimmen

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)));

Weitere Antworten (4)

Gaurav  Kaila
Gaurav Kaila am 7 Mär. 2011

0 Stimmen

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 am 7 Mär. 2011

0 Stimmen

Thanks a Lot, I am very new to MATLAB, can you please elaborate on this answer a little more.
Thanks Again.
Gaurav  Kaila
Gaurav Kaila am 7 Mär. 2011

0 Stimmen

I got it!
Thank You!

Community Treasure Hunt

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

Start Hunting!

Translated by