How mask can a image is segmented using a mask

2 views (last 30 days)
I have an binary image with size [185 272] which will be used as a mask. Then how another image can be segmented using this mask.

Answers (2)

Jeremy Wurbs
Jeremy Wurbs on 28 Nov 2013
If I understand you correctly you wish to apply a mask to an image. You can accomplish this with the .* operator. Just make sure the mask is the same size as the image itself.
For example, applying a centered circular mask to an image can be done with:
[X Y] = meshgrid(1:272, 1:185);
cen = [272 185]/2; rad = 75;
mask = double(sqrt((X-cen(1)).^2+(Y-cen(2)).^2)<rad);
img = imresize(im2double(imread('cameraman.png')), size(mask));
figure; colormap(gray)
subplot(3,1,1)
imagesc(img); axis off
title('Image')
subplot(3,1,2)
imagesc(mask); axis off
title('Mask')
subplot(3,1,3)
imagesc(img.*mask); axis off
title('Mask Applied to Image')

Image Analyst
Image Analyst on 28 Nov 2013
Your question is not clear as stated. Segmentation may involve creating a mask but you can get the mask either by segmenting the image (for example by thresholding) or it can be defined in advance. I don't know what you want to do. Please attach your images and a description of what you want to measure in the color or grayscale image. In the meantime, see my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Community Treasure Hunt

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

Start Hunting!