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,
then you can "mask" the image by using the mask as indexes to the gray level image,
maskedImage = grayImage;
maskedImage(mask) = 0;
or by multiplying the mask by the gray level image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, class(rgbImage)));
or
maskedImage = grayImage .* uint8(mask);
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.
Best Answer