| [Top] [Up] [Prev] [Next] | [Up] [Tutorial] | mmtutor V1.0 30abr2001 |
mm045residues The residue is a generic name for what is left something is removed. For instance if we clean or filter something, the residue is what did not pass on the filter. As long as we have two operators, one larger that the other, the residue can be computed by their difference.

One first group of residues are called gradient and are obtained from the dilations and erosions. They generate contours (binary or gray scale), that can be internal (original minus the erosion), external (dilation minus the original) or both (dilation minus erosion).
In the example below, the gradients of a binary image are computed using the elementary cross (3x3) structuring element. Observe that the internal gradient is the internal contour and the external is the external contour of the blobs.
F=imread('blob3.tif');
G=mmgradm(F,mmsecross,mmsecross);
Gi=mmgradm(F,mmsecross(0),mmsecross);
Ge=mmgradm(F,mmsecross,mmsecross(0));
mmshow(F);
mmshow(G);
|
mmshow(Gi); mmshow(Ge);
|
By changing the size and shape of the structuring element, different results can be obtained. In the example below, an internal contour of thickness 5 is computed using the internal gradient of a disk of radius 5.
F=imread('blob3.tif');
Gt=mmgradm(F,mmsedisk(0),mmsedisk(5));
mmshow(F);
mmshow(Gt);
|
Similarly, the gradients can be applied to gray scale image. The example below computes the internal gradient of a gray scale image using the elementary cross.
f=(imread('danaus.tif'));
mmshow(f);
g=mmgradm(f,mmsecross(0),mmsecross);
mmshow(g);
|
The second category of residues are the open and close top-hat. In this case, the opening and the closing are morphological filters geared by the shape of the structuring element. The residues are everything that the structuring element did not fit. The open top-hat is the difference between the original and the opened image and the close top-hat is the difference between the close and the original.
As the open removes narrow protuberances or spikes on the contour, the open top-hat reveals exactly these protuberances that the structuring element does not fit. Here is a simple demonstration to detect the teeth of a gear.
For gray scale signals, the open top-hat detects the peaks that are narrower than the width of the structuring element. In the example below, a signal with three gaussian peaks of different widths is generated (in black), the opened signal appears in red and the top hat is displayed in blue.
For bidimensional gray scale images, we can see the behavior of the opening top-hat 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 detected by the top hat.
f=imread('ggray.tif');
gth=mmopenth(f,mmsebox(3));
mmshow(f);
mmshow(gth);
|
mmshow(mmsurf(f)); mmshow(mmsurf(gth));
|
mmsurfshow(f); mmsurfshow(gth);
|
In the didactical example below, a binary text image is corrupted by a background shading ramp. The opening by a structuring element larger than the widest element of the text characters will filter out all the text features. The open top hat will detect the residues, which is the target for this demonstration.
f=imread('nshading.tif');
B=mmsebox(2);
go=mmopen(f,B);
gth=mmopenth(f,B);
mmshow(f);
mmshow(go);
mmshow(gth);
|
Although this example was generated artificially, this methodology is very powerful and there are many successful image segmentation applications using top hat followed by a thresholding. The top hat removes the background noise and the thresholding selects the strongest features. This composed operations (top hat and the thresholding) can be seen as a very powerful adaptive thresholding. Actually, the original top-hat was proposed this way. Later, the term top hat become popular to call it just for the residue of the opening.
This is an illustration of the power of the top hat followed by a thresholding as an image segmentation tool. The idea is to detect faults in a microelectronic image of vertical stripes. The closing top-hat by vertical structuring element can enhance them for later selection using thresholding.
Demo: mmdlith
retina.tif to eliminate the background effect.
f=imread('retina.tif');
mmshow(f);
|
| [Top] [Up] [Prev] [Next] | [Up] [Tutorial] |
|
| Copyright (c) 1998-20001 by SDC Information SystemsCopyright (c) 1998-20001 by SDC Information Systems | ||