How to find first white pixel in an image?
7 views (last 30 days)
Show older comments
Zuraidasahana Zulkarnain
on 4 Feb 2013
I have done few process on my image and got stuck here. So far,this is the result that i got: http://s20.postimage.org/5dg34043h/Pra_processing.png. For now, all i need is to find the first white pixel in that image and do some mark on it. We'll start at the bottom right corner of the grid, scan each column of pixels from the bottom going upwards-starting from the rightmost column and proceeding to the left-until we encounter a first white pixel. We'll declare that pixel as our "start" pixel.
0 Comments
Accepted Answer
Image Analyst
on 4 Feb 2013
Edited: Image Analyst
on 4 Feb 2013
[row, column] = find(yourImage, 1, 'last');
0 Comments
More Answers (2)
Ainul
on 4 Feb 2013
Edited: DGM
on 14 Feb 2023
Hello guys..
I've got the same problem here and already use [row, column] = find(yourImage, 1, 'last'); but the result isn't show how it suppose to be..
Here is my code (from top left):
[row, column] = find(edge_s, 1, 'first');
hold on;
plot(row,column,'r.', 'MarkerSize',5,'LineWidth',5);
Result: Its being marked with red dot but the position isn't right.
Do you have any idea?
2 Comments
Jeff E
on 4 Feb 2013
The plot function accepts coordinates in X and then Y. You have provided it with Row (Y) and then Column (X). Switch them, and the point will be plotted correctly.
Prabira Sethy
on 10 Feb 2018
How to find middle white pixel in each row??
1 Comment
Image Analyst
on 10 Feb 2018
Define "middle". If the pixel half way between the first and last white pixel is not also white, then which column do you want to return?
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!