How to make image background white?
1 view (last 30 days)
Show older comments
I have a binary image. I want to make the background white keeping the black straight lines intact.I mean those lines which intersecting image objects will remain intact. Picture has attached.
0 Comments
Accepted Answer
Jeff E
on 24 Dec 2019
I would start by closing in small gaps to get a solid hand.
imgin_close = imclose(imgin, strel('square', 3));
Then I would find the overlap between that solid hand, and the inverse of the original image, leaving me with just white lines on a black background. You may have some additional noise around the edges of the hand. The could be filtered out with something like bwareaopen, depending on your application.
imgin_lines = imgin_close & ~imgin;
imgin_lines = bwareaopen(imgin_lines, 3);
I would then take the inverse of that image to get just the black lines.
imgout = ~imgin_lines;
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!