Why imerode( ) is not giving intended results ?

조회 수: 6 (최근 30일)
Kishor
Kishor 2014년 2월 18일
답변: Jeff E 2014년 2월 18일
% MATLAB Code used by me , the output of this program is appended at the end % see the two unwanted white pixels in the last row of the eroded image
a=[0 0 0 0 0 0 0;0 1 0 1 0 1 0;0 1 0 1 0 1 0;0 1 0 1 0 1 0;0 1 1 1 1 1 0;0 0 0 1 0 0 0;0 0 0 1 0 0 0;];
b=[0 1;1 0 ];
a1=imdilate(a,b); a2=imerode(a,b); a3=imopen(a,b); a4=imclose(a,b);
subplot(2,3,1);imshow(a),title('Original image'); subplot(2,3,2);imshow(a1),title('Dilated image'); subplot(2,3,3);imshow(a2),title('Eroded image'); subplot(2,3,4);imshow(a3),title('Opened Image'); subplot(2,3,5);imshow(a4),title('Closed image');

답변 (2개)

Iain
Iain 2014년 2월 18일
Its cause your filter isn't 3x3.

Jeff E
Jeff E 2014년 2월 18일
Some (all?) morphological functions make assumptions about the value of pixels beyond the border of the image in cases where the processing kernel extends outside the image.
For erosion: Pixels beyond the image border are assigned the maximum value afforded by the data type.
So, you can think of your image as having an infinite field of white pixels beyond its border. If you do not want this default behavior, use the PADARRAY function.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by