how to clean the background noise, separated the object and background in dilate and erode ....

this is my code :
BWs=edge(image1,'canny'); se90=strel('line',3,90); se0=strel('line',3,0); BWsdil=imdilate(BWs,[se90 se0]); BWdfill=imfill(BWsdil,'holes'); BWnobord=imclearborder(BWdfill,1); seD=strel('disk',3); BWfinal=imerode(BWnobord, seD); BWfinal=imerode(BWfinal, seD); BWfinal=invertimage(BWfinal); axes(handles.axes1); imshow(BWfinal); imagemorfologi1=BWfinal; gambar=(imagemorfologi1); nama = strcat('image/dilasierosi/dilasi_',as,'.jpg'); imwrite(gambar,nama); end
and the this is a result : (maybe you can download this, if you want to help me ...)
so, what the problem is? yes I like how the background in order to dilate and erote results are not visible and only the passage of object that looks ... so please help me, thanks before.... ( maybe if the object black the background is white , or if the object white the background is black ).... that something missing in my code and must be added .... ?

3 Comments

my code :
BWs=edge(image1,'canny');
se90=strel('line',3,90);
se0=strel('line',3,0);
BWsdil=imdilate(BWs,[se90 se0]);
BWdfill=imfill(BWsdil,'holes');
BWnobord=imclearborder(BWdfill,1);
seD=strel('disk',3);
BWfinal=imerode(BWnobord, seD);
BWfinal=imerode(BWfinal, seD);
BWfinal=invertimage(BWfinal);
axes(handles.axes1);
imshow(BWfinal);
imagemorfologi1=BWfinal;
gambar=(imagemorfologi1);
nama = strcat('image/dilasierosi/dilasi_',as,'.jpg');
imwrite(gambar,nama);
end
Why are you starting a new thread? This seems just like your thread: http://www.mathworks.com/matlabcentral/answers/13665-how-to-make-im-using-dilate-and-erode-in-matlab-and-then-i-want-to-separate-the-background-and

Sign in to comment.

Answers (0)

Categories

Asked:

on 15 Aug 2011

Community Treasure Hunt

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

Start Hunting!