| [Top] [Up] [Prev] [Next] | [Up] [Tutorial] | mmtutor V1.0 30abr2001 |
mm040opcl Opening and closing are two of the most important operators in Mathematical Morphology. They are the simplest morphological filters.


The opening can be modeled as the waxing or polishing a floor using a waxing brush. Supose the input binary image is the shape of the floor to be waxed. The structuring element is the shape of the waxing brush. The waxing is done only by translating the brush throughout the floor. Remember that the walls limits the translation of the brush, so that depending on the floor shape and the brush shape, there are parts of the floor that will never be waxed. The result of the opening is the shape of the waxed floor. You can notices the idempotence of this operations. No matter how many times you wax the floor, as long as you use the same brush, the waxed area will be the same.
The opening equation that justifies this geometrical interpretation is given by

In the illustration below, the image is opened by an Euclidean disk of radius 10 (21x21). The opening is shown overlayed on the original image. This is possible as the opening is anti-extensive operator. Note that the opening has removed small protusions and has smothed the shape.
F=imread('blob.tif');
mmshow(F);
B=mmsedisk(10);
GO=mmopen(F,B);
mmshow(F,GO);
|
There are many applications that can be solved using the opening as the central tool. The demonstration of PCB segmentation has the target the classification of a binary image of a Printed Circuit Board in its components: holes; square, circle, and rectangular pads; thin and thick tracks. This is acomplish by choosing the proper structuring element to detect the desired shapes. mmdpcb.html mmdpcb
The easiest interpretation is to use the duality property between the closing and the opening.

This means that the closing is the non-waxed area when the background is waxed by the brush (structuring element).
In the illustration below, note that for the displaying purpose, the original image is overlayed over the result as the closing is an extensive operator.
F=imread('blob.tif');
mmshow(F);
B=mmsedisk(10);
GC=mmclose(F,B);
mmshow(GC,F);
|
The gray scale closing and opening are built by composing gray scale dilation and erosion as in the binary case. The geometric interpretation is better visualize using the sub-graph model. The experiment below shows the closing and opening of an 1D ECG signal. The structuring element used is of length 30 pixels. Note that the origin of the SE is not important. The result of the closing filters out all the valleys of the signal which are narrower than 30 pixels. By duality, the opening of the signal filters out all the peaks narrower than 30 pixels.
f=imread('heart_uint8.tif');
x=1:size(f,2);
B=mmimg2se(logical(uint8(ones(1,30))));
gc=mmclose(f,B);
go=mmopen(f,B);
g=plot(x,f,'-k', x,gc,'-r');
g=plot(x,f,'-k', x,go,'-r');
|
For bidimensional gray scale images, we can see the behavior of the opening in the three gaussian-shaped peaks sinthetic image. The opening used a box of radius 3 (7x7) and all peaks in the image in which the SE cannot fit from beneath are removed. Note that, for visual comparison, a white pixel (255) is set on their top left corners so that the display is normalized to the range 0, 255.
f=imread('ggray.tif');
go=mmopen(f,mmsebox(3));
f(1)=255;
mmshow(f);
go(1)=255;
mmshow(go);
|
mmshow(mmsurf(f)); mmshow(mmsurf(go));
|
mmsurfshow(f); mmsurfshow(go);
|
An illustration of the gray scale closing and opening on a real image shown below. A disk of radius 3 (7x7 support) is used for the structuring element. Original, closed and opened images are visualized as gray scale and as top view of their surface. Note that the closing has removed all valleys on which the SE cannot fit, so that only the three wider dark bars are still in the closed image. On the other hand, the opened image has removed all white bars, leaving only the wider one.
f=imread('n2538.tif');
B=mmsedisk(3);
gc=mmclose(f,B);
go=mmopen(f,B);
mmshow(f);
mmshow(gc);
mmshow(go);
|
mmshow(mmsurf(f)); mmshow(mmsurf(gc)); mmshow(mmsurf(go));
|
mmshow display function.circuit_bw.tif: vertical and horizontal lines, connection between lines, and resistors function g=ropen(f,L,THETA) where f is the input image, binary or gray-scale; L is the length and THETA is a vector with many orientations. Use the function mmseline to generate the linear structuring element.| [Top] [Up] [Prev] [Next] | [Up] [Tutorial] |
|
| Copyright (c) 1998-20001 by SDC Information SystemsCopyright (c) 1998-20001 by SDC Information Systems | ||