1, binary image of the corrosion principle: we know that the binary image is a matrix of 0 and 1, 0 is black 1 for white, corrosion on 1 is the image of the high-gloss white part, and then the white portion outward contraction. The corrosion is similar to the Black Army's anti-offensive white Army, which eventually expands its black territory and the black font becomes thicker.
2, matlab corrosion algorithm source code Q_ERODE.M
%erode Corrosion f=[0 1 0 1 0 0; 0 1 1 0 1 0; 0 0 1 0 0 0; 0 0 1 1 0 0; 0 0 0 0 0 0]; s1=[1,0;1,1]; % of corroded nuclear img=rgb2gray (Imread (' girl.jpg ')); [Row,col]=size (IMG); Figure,imshow (IMG); For I=1:row for J=1:col if (IMG (i,j) >100) IMG1 (i,j) =1; else IMG1 (i,j) =0; End End End Figure,imshow (IMG1); F=IMG1; s1=[1,0;1,1]; For i=1:row-1 for j=1:col-1 if (F (i,j) &&f (i+1,j) &&f (i+1,j+1)) % if the position of 1 in S is all 1 then 1 F (i,j) =1; % positive Judgment 1 else F (i,j) =0; End End End Figure,imshow (F);
Test results:
1/Original:
2. After conversion to two value image:
3, the result after corrosion:
MATLAB implementation of two-value image corrosion algorithm source code