我不应该通过我自己的 Matlab 代码重建来进行形态学打开imreconstruct
。这是我的代码,但效果不佳:
S = input('Enter the structuring element: ');
Im = input('Enter the input image: ');
marker = imerode(Im,S);
mask = Im;
Im2 = imdilate(marker,S);
Im3 = min(Im2,Im);
i=1;
while Im3(i+1)~= Im3(i)
i=i+1;
Im2 = imdilate(Im3(i),S);
Im3(i+1) = min(Im2,Im);
end
imrecon = Im3;
有没有人更好的代码或可以编辑我的代码?请帮我。先感谢您。