Digital Image Processing HW6 1. A⊖B: cross-0 0 0 0 0 0 0 0 00000000 00001100 00011100 00111000 00110000 00000000 00000000 >> imerode(A,cross) ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 square-0 0 0 0 0 0 0 0 00000000 00001100 00001100 00110000 00110000 00000000 00000000 >> imerode(A,square) ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 資工三 49385002 陳俊志
0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 1 1 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 A⊕B: cross-0 0 0 1 1 1 1 0 00111111 01111111 11111111 11111111 11111110 11111100 01111000 >> imdilate(A,cross) ans = 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 square-0 0 1 1 1 1 1 1 00111111 11111111 11111111 11111111 11111111 11111100 11111100 >> imdilate(A,square) ans = 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 資工三 49385002 陳俊志
0
0
0
1 1 1 1 1 1 1 0
1 1 1 1 1 1 0 0
0 1 1 1 1 0 0 0
1 1 1 1 1 1 1 1
1 1 1 1 1 1 0 0
1 1 1 1 1 1 0 0
A○B: cross-0 0 0 0 0 0 0 0 00001100 00011110 00111110 01111100 01111000 00110000 00000000 >> imopen(A,cross) ans = 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 square-0 0 0 0 0 0 0 0 00011110 00011110 01111110 01111110 01111000 01111000 00000000 >> imopen(A,square) ans = 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 0 0 0 0 A●B: 資工三 49385002 陳俊志
0 1 1 1 1 0 0 0
0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0
0 1 1 1 1 0 0 0
0 0 0 0 0 0 0 0
cross-0 0 0 0 0 0 0 0 00011110 00111110 01111110 01111110 01111100 01111000 00000000 >> imclose(A,cross) ans = 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 0 square-0 0 0 0 0 0 0 0 00011110 00011110 01111110 01111110 01111000 01111000 00000000 >> imclose(A,square) ans = 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 0 0
0 1 1 1 1 0 0 0
0 0 1 1 0 0 0 0
1 1 1 1 1 0 0 0
1 1 1 1 1 0 0 0
1 1 1 1 1 0 0 0
2. a. >> rb=im2bw(r,graythresh(r)); 資工三 49385002 陳俊志
>> imshow(rb)
b. >> rbe=imerode(rb,cross); >> rbd=imdilate(rb,cross); >> rbo=imopen(rb,cross); >> rbc=imclose(rb,cross); >> imshow(rbe),figure,imshow(rbd),figure,imshow(rbo),figure,imshow(r bc)
erosion
資工三 49385002 陳俊志
dilation
opeining closing c. >> rbe=imerode(rb,square); >> rbd=imdilate(rb,square); >> rbo=imopen(rb,square); >> rbc=imclose(rb,square); >> imshow(rbe),figure,imshow(rbd),figure,imshow(rbo),figure,imshow(r bc)
erosion
dilation
opening closing d. >> rint=rb&~rbe; >> rext=rbd&~rb; >> rmor=rbd&~rbe; >> imshow(rint),figure,imshow(rext),figure,imshow(rmor)
資工三 49385002 陳俊志
internal boundary
external boundary
morphological gradient
e. >> rbc=imclose(imopen(rb,cross),cross); >> rbc4=bwlabel(rbc,4); >> max(rbc4(:)) ans = 88 >> figure,imshow(rbc)
f. >> rbc8=bwlabel(rbc,8); >> max(rbc8(:)) ans = 資工三 49385002 陳俊志
88
資工三 49385002 陳俊志