how to show output of the distance between two point?I just find the highest location of white pixel.
1 view (last 30 days)
Show older comments
I want to find the distance from the highest point location (highestWhiteRow,thatColumn) to the lastRow,thatColumn.After that,the 1row is equal to 3meter. But i'm got stuck to display the result of distance between that two points.
true
%highest point location
row=find(sum(img8,2)==0,1,'last')+1;
col=find(img8(row,:)~=0);
row=row(ones(size(col)));
Points=[row(:) col(:)];
imshow(img8);
title('Highest Point Location')
hold on
plot(Points(:,2),Points(:,1),'rp','MarkerSize',10)
a=text(Points(1,2),Points(1,1),['This is (',num2str(Points(1,2)),',',num2str(Points(1,1)),')']);
set(a, 'FontName', 'Arial' ,'FontWeight', 'bold', 'FontSize', 12,'Color', 'green');
%highest distance
% Find the distance.
xd=240-Points(:,2);
yd=Points(:,1)-Points(:,1);
distance=sqrt(xd.*xd + yd.*yd);
Dmeter=distance.*3;%one row=3meter
D=text(['Distance is(',num2str(Dmeter),')']); %show result of distance
set(D, 'FontName', 'Arial' ,'FontWeight', 'bold', 'FontSize', 12, 'Color', 'yellow');
2 Comments
Jan
on 4 May 2015
The question is not clear. What do you want to show, what does "show" exactly mean (in the command window or as a diagram?)? What does the code demonstrate?
Please edit the question and post any details.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!