Sir, how to find area & coordinates of white pixels in binary image?
1 view (last 30 days)
Show older comments
How to find area & coordinates of white pixels in binary image?
2 Comments
Answers (1)
Image Analyst
on 26 Dec 2024
Edited: Image Analyst
on 26 Dec 2024
To get all the rows and columns of the white pixels, you can do
[rows, columns] = find(binaryImage);
You'll get two vectors and a given index will give you the same pixel. For example to get the row and column of the 37th pixel, you can do
r = rows(37)
c = columns(37)
If you want to use x,y terminology, you can do
[y, x] = find(binaryImage);
because rows are y and columns are x.
To crop you can do
row1 = min(rows);
row2 = max(rows);
col1 = min(columns);
col2 = max(columns);
binaryImage = binaryImage(row1:row2, col1:col2);
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!