How to expand a black region in a boolean image?
3 次查看(过去 30 天)
显示 更早的评论
I have a binary image in a matrix that I obtained by some image processing. When I say Binary Image I mean it has zeros and ones indicating complete black and complete white pixels. The image is mostly white and has some black spots. I now want to expand this black spots by some factor. How can I do it?
2 个评论
Matt Kindig
2013-6-28
I assume you have the image processing toolbox. In that case, I would look at the 'bwmorph' and 'imdilate' functions. Also, in general dilation is performed on the white pixels of a black and white image, so you might need to invert the image (using the ~ operator) first.
回答(1 个)
Chong
2013-6-28
编辑:Chong
2013-6-28
The two basic operators in morphological filters are dilation and erosion. In your case whereby your input is a binary image, erosion will reduce the white pixel area (foreground area) and indirectly enlarges the black pixel area (background). Dilation operator does the exact opposite operation.
Using Matlab, you may do this using imdilate( ) or imerode( ) commands
BW = imread('circbw.tiff');
SE = strel('square',3);
BW2 = imerode(BW,SE); % or BW2 = imdilate(BW, SE);
imshow(BW2)
SE are actually the structure element. It acts like a "filter region". In the example, SE is a 3x3 square "filter". You may change its shape and size according to your requirement. To learn more about structure element, you may refer to the link just now.
Applying imdilate/imerode will affect the entire foreground. If you only want to change size of only the black spots or only the white spots, you may replace the imerode( ) and try with imopen( )/ imclose( )
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!