MATLAB: What is meant by imdilate

Image Processing Toolboximage segmentationmaskingwatershed

Hi, can i know what is meant by:
(imdilate(L == 0, ones(3,3))
What is L == 0?
and ones(3,3)
This can be found in marker controlled watershed segmentation algorithm.
Thank you very much.
gradmag2 = imimposemin(gradmag, bgm | fgm4);
L = watershed(gradmag2);
I4 = I;
I4(imdilate(L == 0, ones(3, 3)) | bgm | fgm4) = 255;
figure, imshow(I4), title('Markers and object boundaries superimposed on original image (I4)');

Best Answer

L is a labeled image. A label of 0 means an unlabeled region, usually the background, though I'm not sure the labeled image coming from a watershed would have any background.
It sets I4 to the original image and then
So then it dilates (expands) the background region. Then it takes any true values in the other binary imagesbgm and fgm4 and combines them to form a mask of all three images ORed together. Any pixels in the I4 image that are where the combined mask are white will also be set to white.
So basically it takes a bunch of regions and sets a gray scale image to white in those regions.