MATLAB (Part 8)
Corrosion and grayscale expansion
Grayscale corrosion
The center point of the structural elements, from left to right from top to bottom, sequentially scanned grayscale pixel value of the pixel on the image is taken in the pixel area covered by the structural elements of the minimum value , the scan will again get a new map is the original corrosion map.
With this structure elements:
to the underlying matrix etching
etching operation for a first pixel as follows:
When a pixel to an intermediate point of corrosion as follows:
Grayscale expansion
The center point of the structural elements, each pixel sequentially scanned grayscale value of the pixel on the image is taken as the structural elements of all pixels covered by the maximum value , the scanning will be again a new map, is the original expansion map.
With this structure elements:
for matrix expansion following
the expansion operation on a first pixel as follows:
a scanning operation to the expansion of the middle point of a certain pixel:
Top cap operation
The effect is equivalent to the operation of the top cap picture - opening operation , i.e., subtracting the original image opening operation. Overcap used to operate grayscale. Function is:
tophat = imtophat( g , se ); (= g - g_open; )
Overcap operation often used to remove background.
Bottom cap operation
The effect is equivalent to the operation of the end cap picture - closing operation , i.e., subtracting the original image closing operation. Bottom cap for operation of the grayscale. Function is:
bothat = imbothat ( g , a ); (= G - g_close ;)
Note: top cap and bottom cap for grayscale operations are operations.
Top cap and bottom cap application
Top cap and bottom cap for the operation of the FIG., See the results.
step:
- First picture into a grayscale image, because the end cap and top hat operations are for grayscale.
- Direct top cap and bottom cap manipulation function
according to the present embodiment codes:
clear,clc,close all;
f=imread('lemon.jpg');
imshow(f);
g=rgb2gray(f);
figure,imshow(g);
tophat=imtophat(g,strel('disk',10));
subplot(1,2,1),imshow(tophat),title('顶帽');
bothat=imbothat(g,strel('disk',10));
subplot(1,2,2),imshow(bothat),title('底帽');