Removing unwanted components in a binary image?
2 次查看(过去 30 天)
显示 更早的评论
Heloo... am working on pothole images. Below is the binary image of pothole attached and i wanted to remove the unwanted components sorrounding the pothole and i want only the pothole image as the output without any unwanted areas, could anyone help me?
thanks in advance...:)![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/271921/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/271921/image.jpeg)
2 个评论
回答(2 个)
KALYAN ACHARJYA
2020-2-16
编辑:KALYAN ACHARJYA
2020-2-16
BW=bwareafilt(bw_im,1);
result=bw_im-BW;
imshow(result);
If you are more interested to control the small area objects use this function
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/271927/image.png)
2 个评论
KALYAN ACHARJYA
2020-2-17
Apply imclose on the resultant binary image with proper structuring element objects
Image Analyst
2020-2-16
You need to define what you want. For example, do you want just the largest blob with bwareafilt(bw, 1)? Or blobs larger than a certain area with bwareaopen(bw, someArea)? Do you want to fill holes with imfill(bw, 'holes')? Also you should make sure your initial segmentation gives the pothole(s) as white, not black, since binary operations are done on true/white/1 valued pixels, not false/black/0 valued objects.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!