MATLAB: Find out the first while pixel from right side

image analysisimage processingimage segmentation

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 at every column from right side and display only that pixel rest all pixel in same row to be black .

Best Answer

[m,n]=size(yourImage);
[~,idx]=max(fliplr(yourImage),[],2);
newImage= ( (n+1-idx)==(1:n) );