MATLAB Answers

How to find first white pixel in an image?

Asked by 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

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');

  0 Comments


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. <http://postimage.org/image/okchtrlb5/> Do you have any idea?

  2 Comments

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.

Ainul
on 5 Feb 2013

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


Answer by Ainul
on 4 Feb 2013

Sorry.. The image is here:

http://postimage.org/image/okchtrlb5/

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today