A simple synthetic gray scale image is dilated by a flat SE 7x7 box to illustrate the operator effect on its surface. Three visualizations are used: gray scale mapping, top view and surface view.
f=imread('ggray.tif');
g=mmdil(f,mmsebox(3));
mmshow(f);
mmshow(g);
|
| (f) |
|
|
| (g) |
|
|
mmshow(mmsurf(f));
mmshow(mmsurf(g));
|
| (mmsurf(f)) |
|
|
| (mmsurf(g)) |
|
|
Here a real image is dilated by a disk of radius 3 (7x7 support). Both original and dilated images are visualized as gray scale and as top view of their surface.
f=imread('n2538.tif');
mmshow(f);
B=mmsedisk(3);
g=mmdil(f,B);
mmshow(g);
|
| (f) |
|
|
| (g) |
|
|
mmshow(mmsurf(f));
mmshow(mmsurf(g));
|
| (mmsurf(f)) |
|
|
| (mmsurf(g)) |
|
|
The erosion is the dual of the dilation. Its formulation for a flat SE is the following.

Below, a signal is eroded by a non-symmetrical SE. The original signal is displayed in red and the eroded in blue.
f=imread('heart_uint8.tif');
x=1:size(f,2);
B=mmimg2se(logical(uint8([zeros(1,18) ones(1,50)])));
g=plot(x,f,'-r',x,mmero(f,B),'-b');
|
| (g) |
|
|
Here, a synthetic image is eroded and visualized in the same as done with the dilation illustration. The erosion uses a box 7x7 flat SE.
f=imread('ggray.tif');
g=mmero(f,mmsebox(3));
mmshow(f);
mmshow(g);
|
| (f) |
|
|
| (g) |
|
|
mmshow(mmsurf(f));
mmshow(mmsurf(g));
|
| (mmsurf(f)) |
|
|
| (mmsurf(g)) |
|
|
Here a real image is eroded by a disk of radius 3 (7x7 support). Both original and dilated images are visualized as gray scale and as top view of its surface.
f=imread('n2538.tif');
mmshow(f);
B=mmsedisk(3);
g=mmero(f,B);
mmshow(g);
|
| (f) |
|
|
| (g) |
|
|
mmshow(mmsurf(f));
mmshow(mmsurf(g));
|
| (mmsurf(f)) |
|
|
| (mmsurf(g)) |
|
|
Exercises
- Give the geometrical interpretation of the following equation of the flat gray scale erosion.

- Build a script in MATLAB to illustrate the geometrical interpretation of the gray scale erosion, using the same technique applied in the gray scale dilation.