Beruflich Dokumente
Kultur Dokumente
Morphological Filtering
Y X B X b Bx B X
bB xX
mask B
Y X B
>X=zeros(6,7);X(2:3,4:6)=1;X(4:5,3:5)=1;
>se=[0 1;1 1];
>Y=imdilate(X,se);
Y=X _ B {x : Bx X }
Erosion
mask B
X Y=X _ B
>X=zeros(6,7);X(2:3,4:6)=1;X(4:5,3:5)=1;
>se=[0 1;1 1];
>Y=imerode(X,se);
(X _ B)c =XcB^
X B (X _ B) +B
X
>X=zeros(6,9);X(3:5,2:4)=1;
>X(3:5,6:8)=1;X(5,5)=1;X(2,7)=1
mask B >se=strel('square',3);
>Y=imdilate(imerode(X,se),se);
%Y=bwmorph(X,’open’);
X B
X B (X + B) _ B
X
>X=zeros(6,9);X(3:5,2:4)=1;
>X(3:5,6:8)=1;X(5,5)=1;X(2,7)=1
mask B >se=strel('square',3);
>Y=imerode(imdilate(X,se),se);
%Y=bwmorph(X,’close’);
X B
>se=strel('line',10,45);
>se2=fliplr(flipud(se));
( X B)C X C Bˆ >X1=~imopen(X,se);
>X2=imclose(~X, se2);
>isequal(X1,X2)
( X B)C X C Bˆ >X1=~imclose(X,se);
>X2=imopen(~X, se2);
>isequal(X1,X2)
X * B= (X _ B1)(Xc _ B2)
>bw = [0 0 0 0 0 0;
0 0 1 1 0 0;
0 1 1 1 1 0;
0 1 1 1 1 0;
0 0 1 1 0 0;
X X*B 0 0 1 0 0 0]
origin
>se = [0 -1 -1;
1 1 -1; 0 1 0];
>bw2 = bwhitmiss(bw,se)
mask B1 mask B2
EE465: Introduction to Digital Image Processing 8
Boundary Extraction
X=X-(X _ B)
X X
>X=zeros(8,11);X(2:4,4:8)=1;X(5:7,2:10)=1;
> se=strel('square',3);
Y=X-imerode(X,se);
%Y=imdilate(X,se)-X;
EE465: Introduction to Digital Image Processing 9
Image Example
X X
Pseudo Iterations:
Codes expansion stop at the boundary
of
Region Y0=P
Filling
Yk=(Yk-1B)Xc, k=1,2,3…
Terminate when Yk=Yk-1,output YkX
MATLAB
Codes
of
Region
Filling
Y Z
>se=strel('square',3);
>r=round(size(Y,1)/2);
> c=round(size(Y,2)/2);
>Z=region_fill(Y,[r,c],se);
x x x x x x
x x
x x x x x x x x
B1 B2 B3 B4 B5 B6 B7 B8
X0=X
Xk=(…( (Xk-1 B1) B2 … B8)
where X B=X – X
*B
Stop the iteration when Xk=Xk-1
function y=thinning(x,iter)
Scheme
A
Scheme
> y=bwmorph(x,’thin’,inf);
B
MATLAB codes
circshift(A,z)
fliplr(flipud(B))
~A or 1-A
A &~B
imdilate(A,B)
imerode(A,B)
imopen(A,B)
imclose(A,B)
bwhitmiss(A,B)
A&~(imerode(A,B))
region_fill.m
bwmorph(A,’thin’);