i want to mark the highest point of any non-black pixel within the image to find the max point.

here is my image. I had ask before at https://www.mathworks.com/matlabcentral/answers/213198-i-want-to-mark-only-the-highest-middle-point-of-binary-image-but-it-show-the-min-point-too but i might ask in not clear question.
<<
the last of my output will be like this.
>>

 Accepted Answer

row=find(sum(BWImage,2)==0,1,'last')+1;
col=find(BWImage(row,:)~=0);
row=row*ones(size(col));
Points=[row(:) col(:)];
Points contains the row and column of the point or points at the top.

5 Comments

Basically the same answer I gave him in his duplicate question, though I used 'first' on the white profile instead of 'last' on the black profile to get the top row instead of the last row.
% Find the vertical profile
verticalProfile = sum(binaryImage, 2);
% Find the top row
topRow = find(verticalProfile, 1, 'first');
Guillaume did the same thing using min(). Seems did not clariff any thing there, because you give essentially a similar answer. Maybe he wants the center column in case the spike has a flat top???? In that case he can use regionprops() to find the centroid of the row containing the top.
% Find the vertical profile
for verticalProfile = sum(maxImage, 2);
% Find the top row
topRow = find(verticalProfile, 1, 'first');
hold on;
plot(topRow(1,:),'rs');
end
the mark is not on the whitetoprow..where am i got it wrong?
Well, execute the code I gave you and you should get this:
BWImage=imread('BWImage.png');
>> row=find(sum(BWImage,2)==0,1,'last')+1;
col=find(BWImage(row,:)~=0);
row=row*ones(size(col));
Points=[row(:) col(:)];
imshow(BWImage)
hold on
plot(Points(:,2),Points(:,1),'rs','MarkerSize',10)
So that code is doing what you asked.
As would have the code in your duplicate question. Anyway, please vote for his answer and mark it as Accepted so he can get "reputation points" for it.

Sign in to comment.

More Answers (1)

i want to ask how i can sect the column which have maximum number of black pixel

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!