distance line from a point
이전 댓글 표시
Hi all, lets say i have a binary image, and i want to find the distance of a line (the one with the blue) from my mesh which is pictured in the above image.

The red points are the "aces" on the image. The values with 1 in my binary image

Any help?
답변 (1개)
darova
2019년 5월 8일
But you already have those pixels/points:
n = 100; % number of pixels
x0 = round( linspace(min(x),max(x),n) ); % coordinates/columns of points/pixels
y0 = round( linspace(min(y),max(y),n) ); % coordinates/rows of points/pixels
Please look at the picture, because i did my best

Perpendicular vector p:
Then use equation of a line from two points:
We have to find x,y then distance:
Accept the answer please if i helped you
댓글 수: 5
pasta pontikaki
2019년 5월 9일
darova
2019년 5월 9일
I lied to you on the first picture. (x1,y1) and (x2,y2) are first and last points
I used min() and max() to indicate first and last points and build a line

Above code can be written as:
x1 = min(x);
x2 = max(x);
y1 = min(y);
y2 = max(y);
n = 100;
x0 = linspace(x1,x2,n);
x0 = round(x0); % rounding because pixels position must be integer
y0 = linspace(y1,y2,n);
y0 = round(y0);
pasta pontikaki
2019년 5월 11일
편집: pasta pontikaki
2019년 5월 11일
darova
2019년 5월 11일
You are right
Can you please unaccept my answer so other peaple can help you?
pasta pontikaki
2019년 5월 11일
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

