MATLAB(8)

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:
Here Insert Picture Description
to the underlying matrix etching
Here Insert Picture Description
etching operation for a first pixel as follows:

Here Insert Picture DescriptionHere Insert Picture Description
When a pixel to an intermediate point of corrosion as follows:
Here Insert Picture DescriptionHere Insert Picture Description

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:
Here Insert Picture Description
for matrix expansion following
Here Insert Picture Description
the expansion operation on a first pixel as follows:
Here Insert Picture DescriptionHere Insert Picture Description
a scanning operation to the expansion of the middle point of a certain pixel:
Here Insert Picture DescriptionHere Insert Picture Description

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.
Here Insert Picture Description
step:

  1. First picture into a grayscale image, because the end cap and top hat operations are for grayscale.
    Here Insert Picture Description
  2. Direct top cap and bottom cap manipulation function
    Here Insert Picture Description
    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('底帽');
Released eight original articles · won praise 2 · Views 1877

Guess you like

Origin blog.csdn.net/qq_36793268/article/details/93852010