MATLAB Answers

How to find first white pixel in an image?

I have done few process on my image and got stuck here. So far,this is the result that i got: 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.


3 Answers

Answer by Image Analyst
on 4 Feb 2013
Edited by Image Analyst
on 4 Feb 2013
 Accepted answer

[row, column] = find(yourImage, 1, 'last');


Answer by Ainul
on 4 Feb 2013

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?


Jeff EA
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.

on 5 Feb 2013

well thanks.. It actually works... =)

Answer by Ainul
on 4 Feb 2013

Sorry.. The image is here:


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!