MATLAB: Is masking,ROI and contour the same

image processingImage Processing Toolboximage segmentationmask

i have studied these again and again but still i am confuse about this, are these three the same if not please explain to clear the concept.

Best Answer

Masking and ROI are pretty similar. ROI is the pixels in the image that you're interested in analyzing. Those outside the ROI you want to ignore. One way to do this is by masking. In masking you create a mask, a binary image. You can then use that to set all pixels outside the ROI to black for example. Then you can process the whole image and perhaps your algorithm will ignore the black pixels, like if you just summed all the pixel gray levels for example. So somehow you can create a mask and ROI, for example by intensity thresholding to find all bright pixels,
mask = grayImage > 200;
then you can "mask" the image by using the mask as indexes to the gray level image,
maskedImage = grayImage; % Initialize
maskedImage(mask) = 0;
or by multiplying the mask by the gray level image.
% Mask the image using bsxfun() function
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, class(rgbImage)));
or
maskedImage = grayImage .* uint8(mask); % Or uint16 if grayImage is 16 bit
Masking is the operation of applying the binary mask to the gray scale image.
Contours are isolines of constant gray level, just like contours on topographic maps are lines of constant altitude. It doesn't necessarily have anything to do with ROIs or masking, though if you were to threshold at, say, 200 gray levels, the white blobs you get from that would have perimeters that are the same as the contours you'd get at 200 gray levels. But normally, just ignore contours and the contour() function as far as setting ROIs/masks goes.