Why imerode( ) is not giving intended results ?

1 次查看(过去 30 天)
% 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