How could I Remove the border outside a number?
2 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/443823/image.png)
hi,everyone:
could you tell me the way to delete the border outside the number '5' ?
thank you!
0 Comments
Answers (1)
Image Analyst
on 4 Dec 2020
As long as the box is not touching the 5, you can label it and call bwlabel to get blobs 1-6 and 8. Blob #7 will be the box.
% Make sure it's binary
mask = yourImage > 128;
[labeledImage, numRegions] = bwlabel(mask);
% Extract blobs 1-6 and 8
maskWithoutBox = ismember(labeledImage, [1,2,3,4,5,6,8]);
If the box touches the 5, then you're going to have to do tricker things (morphology like imopen or imerode) to separate them.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!