Search code examples
matlabimage-processingbinary-image

Find the lowest white pixel


I have this binary image.enter image description here

How do i find the coordinate of the lowest white pixel?


Solution

  • If in your matrix you have 0 and 1 values representing white and black

    you can find white pixels with

       [row,col,v] = find(A);
    

    Then the lowest pixel has coordinates

    x = max(row) 
    y = col(find(row==max(row))) 
    

    If you have more than one lowest pixel maybe you can simply take the coordinates of one of them. For example:

    mrow = max(row);
    
    y = col(find(row==mrow(1)))%if you wanna take the lowest pixel on the left