how to get the roi of an image by masking

1 回表示 (過去 30 日間)
Mahua Nandy(Pal)
Mahua Nandy(Pal) 2013 年 3 月 12 日
I have an image of size 584x565x3 and a binary mask of size 584x565. please consider the following piece of code
greenimg=I(:,:,2);
masked_I=mask.*greenimg;
imshow(masked_I);
But I am not getting the region of interest instead it seems same as the original mask
Please help
  4 件のコメント
Mahua Nandy(Pal)
Mahua Nandy(Pal) 2013 年 3 月 13 日
One modification in the question I want to mention is that my image is .tif (584x565x3) and binary mask is .gif(584x565). If anybody provide me with the solution it will be immensely helpful to me.Thanks in advance.
Alessandro
Alessandro 2013 年 3 月 13 日
probably you are reading the roi in the wrong way or you roi isn t a valid roi. look for the values on your roi using unique(roi(:)). Read the roi using imread.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2013 年 3 月 13 日
Try it this way (Sean's way):
% Mask the image.
maskedImage = bsxfun(@times, originalImage, cast(mask,class(originalImage)));
Works no matter if originalImage is gray scale or RGB. mask is your binary image with true being "foreground" and that is what remains after masking.

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by