Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...