In binary image, how to convert large black pixels area into white ?
Show older comments
I am working on skew detection and correction. I had corrected the skewness of the image, but I found that there is large size of Black areas on all sides of the corrected image. I tried to convert the black pixels (large area only) to white using the following codes. But it is not working properly. Sometimes its also remove black pixel from the pictures itself and sometimes it does not remove the larger area of the black pixels.
<<

>>
measurements = regionprops(SkewCorrectedImage == 0, 'Area','PixelIdxList');
Regions = find([measurements.Area] >=200000);%%
theIndexes = vertcat(measurements(Regions).PixelIdxList);
c=SkewCorrectedImage;
(theIndexes)=1
2 Comments
Jan
on 7 Dec 2017
You should be able to set the added pixels to white directly in the code for rotating the image. This would be much smarter that using an auto-detection of the black triangles afterwards. So please post the code to obtain the shown image.
Y.L.K KHUMAN
on 7 Dec 2017
Edited: Y.L.K KHUMAN
on 7 Dec 2017
Answers (1)
Akira Agata
on 7 Dec 2017
You can easily do that by using imclearborder function, like:
BWout = ~yourBinaryImage;
BWout = imclearborder(BWout);
BWout = ~BWout;
1 Comment
Y.L.K KHUMAN
on 9 Dec 2017
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
