Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

matlab - Working with erosion and dilatation

From the the previous link:

Working with an specific region generated by BoundingBox

The following code is based on it

se = strel('disk',9);

p_mask=imerode(Ic(BB,1).Image,se);
k_mask=imdilate(p_mask,se);

Ipointer=I2.*repmat( k_mask , [1 1 3]);

figure,imshow(Ipointer)

Mch=Ic(BB,1).Image-k_mask;
Mbch=bwareaopen(Mch,3000);
Ichaplet=I2.*repmat( Mbch , [1 1 3]);
figure,imshow(Ichaplet)

And so, I do not understand it

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

google is your friend. if you don't know what a function does, google matlab + its name and read the reference documentation.

se is your structure element. Here defined as a disk with radius 9 http://de.mathworks.com/help/images/ref/strel-class.html

Your binary image is eroded, then dilated (which is called Opening) https://en.wikipedia.org/wiki/Opening_(morphology)

Assuming white is considered foreground (I can only guess without your image) Opening will remove small white spots. Erosion shrink everything by nibbling around the contour. If you nibble enough you eat the hole object :) Dilation will resize those objects that have not been eroded completely. Dilation will add pixels around the contour.

bwareaopen will remove connected components smaller than 3000 pixels http://de.mathworks.com/help/images/ref/bwareaopen.html

I'm sure you can figure out the rest on your own!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...