How to find the leftmost and rightmost white pixel in a binary image in Matlab ?
6 views (last 30 days)
Show older comments
Dhanraj yadav
on 24 Feb 2018
Answered: Image Analyst
on 24 Feb 2018
I have a binary image in which there is only one nonzero region.How I find the leftmost and rightmost white pixel and then connect them by a line.
0 Comments
Accepted Answer
Image Analyst
on 24 Feb 2018
Lots of ways. For example call bwconvhull() and then regionprops to get bounding box.
binaryImage = bwconvhull(binaryImage, 'union');
props = regionprops(binaryImage, 'BoundingBox');
leftColumn = props.BoundingBox(1);
topRow = props.BoundingBox(2);
Or simply use find()
[rows, columns] = find(binaryImage);
leftColumn = min(columns);
topRow = min(rows);
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!