Looks like about 3 or 4 imdilate() operations. Original image, dilate to get image2, construct mask2 from the list of pixels set in image2 that were not set originally. Dilate image2 to get image3, construct mask3 from the list of pixels set in image3 that were not set in image 2. Repeat as needed.
At the end, create color matrix with the original pixels in one color, the pixels in mask2 in a different color, the pixels in mask3 in a third color, and so on.
This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0.1 (R14SP1) when using the CLABEL function. To work around this issue, use the 'v6' option with the CONTOUR command, as in the following example:
Best Answer