Itest = zeros(9); Itest(1:3, 6:9) = 1; Itest(4:6, 4:7) = 1; Itest(7:9, 1:4) = 1; my1 = [ 0 1 0;1 1 0; 0 0 0]; my2 = [ 0 0 0; 0 1 1; 0 1 0]; my3 = [ 1 1 0; 1 1 0; 0 0 0]; figure('Name', 'Three asymmetric structuring elements'); subplot(1, 3, 1), imshow(my1, 'notruesize'), title('Element 1'); subplot(1, 3, 2), imshow(my2, 'notruesize'), title('Element 2'); subplot(1, 3, 3), imshow(my3, 'notruesize'), title('Element 3'); myst1 = strel(my1); myst2 = strel(my2); myst3 = strel(my3); Itestdilate1 = imdilate(Itest,myst1); Itestdilate2 = imdilate(Itest,myst2); Itestdilate3 = imdilate(Itest,myst3); figure('Name', 'Dilation using default (same) boundary handling'); subplot(2, 2, 1), imshow(Itest, 'notruesize'), title('Original'); subplot(2, 2, 2), imshow(Itestdilate1, 'notruesize'), title('Element 1'); subplot(2, 2, 3), imshow(Itestdilate2, 'notruesize'); title('Element 2'); subplot(2, 2, 4), imshow(Itestdilate3, 'notruesize'); title('Element 3'); Itestdilate1f = imdilate(Itest,myst1, 'full'); Itestdilate2f = imdilate(Itest,myst2, 'full'); Itestdilate3f = imdilate(Itest,myst3, 'full'); figure('Name', 'Dilation using full boundary handling'); subplot(2, 2, 1), imshow(Itest, 'notruesize'), title('Original'); subplot(2, 2, 2), imshow(Itestdilate1f, 'notruesize'), title('Element 1'); subplot(2, 2, 3), imshow(Itestdilate2f, 'notruesize'); title('Element 2'); subplot(2, 2, 4), imshow(Itestdilate3f, 'notruesize'); title('Element 3'); %Padding to get the traditional erosion Itestpad1 = padarray(Itest, [3, 3], 0, 'both'); Itestpad2 = padarray(uint8(255*double(Itest)), [3, 3], 128, 'both'); Itestpad1dilate = imdilate(Itestpad1, myst1); Itestpad2dilate = imdilate(Itestpad2, myst1); figure('Name', 'Dilation with padding'); subplot(2,2,1), imshow(Itestpad1), title('Original binary with 0 pad'); subplot(2,2,2), imshow(Itestpad2), title('Original uint8 with 128 pad'); subplot(2,2,3), imshow(Itestpad1dilate), title('Dilated with 0 pad'); subplot(2,2,4), imshow(Itestpad2dilate), title('Dilated with 128 pad'); Itestpad1du = Itestpad1dilate(4:12, 4:12); figure('Name', 'Dilation - comparison of boundary'); subplot(2,2,1), imshow(Itest), title('Original '); subplot(2,2,2), imshow(Itestpad1du), title('Dilated with 0 pad'); subplot(2,2,3), imshow(Itestdilate1f), title('Dilated using full option'); subplot(2,2,4), imshow(Itestdilate1), title('Dilated using same (default) option');