问题
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
回答1:
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!
来源:https://stackoverflow.com/questions/37558409/working-with-erosion-and-dilatation