Hi,
if i have a path consist of six points , and i have obstacle, what i want is to put nodes in all the path to count the minimum distance between
the obstacle and the path
example.jpg

댓글 수: 4

darova
darova 2019년 8월 3일
I showed distance with green color on the image. Am i correct? Is that all you want?
1Untitled.png
mohammed alany
mohammed alany 2019년 8월 3일
yes, i really want this
can you send the code please
darova
darova 2019년 8월 3일
What about pdist2()?
mohammed alany
mohammed alany 2019년 8월 3일
the problem i wanted all the coordinate of midpoints between each two nodes

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2019년 8월 4일

0 개 추천

What if you just take the average of the initial, known points?
x = sort(rand(9, 1));
y = sort(rand(9, 1));
plot(x, y, '.-', 'Color', [247, 148, 20]/255, 'MarkerSize', 40);
grid on;
xlabel('X');
ylabel('Y');
xAve = (x(1:end-1) + x(2:end))/2;
yAve = (y(1:end-1) + y(2:end))/2;
hold on;
plot(xAve, yAve, '.', 'Color', [206, 24, 18]/255, 'MarkerSize', 40);
legend('Original Points', 'Mid Points', 'Location', 'north');
0001 Screenshot.png

댓글 수: 3

mohammed alany
mohammed alany 2019년 8월 4일
many thanks for your reply,
but, is there any way to increase the number of Mid Points
like 10 mid pointes between each two was-points (x1,y1) and (x2,y2)
Image Analyst
Image Analyst 2019년 8월 4일
편집: Image Analyst 2019년 8월 4일
You could use linspace() instead of just averaging. Try this:
x = sort(rand(9, 1));
y = sort(rand(9, 1));
% Now we have sample data and can begin.
numPoints = 2; % # points in between, not including the knot endpoints.
xAve = x(1);
yAve = y(1);
for k = 2 : length(y)
inBetweenPoints = linspace(x(k-1), x(k), numPoints + 2); % 2 more to include the knots.
xAve = [xAve, inBetweenPoints(2:end)];
inBetweenPoints = linspace(y(k-1), y(k), numPoints + 2);
yAve = [yAve, inBetweenPoints(2:end)];
end
plot(xAve, yAve, '.', 'Color', [206, 24, 18]/255, 'MarkerSize', 40);
hold on;
plot(x, y, '.-', 'Color', [247, 148, 20]/255, 'MarkerSize', 40);
grid on;
xlabel('X');
ylabel('Y');
legend('Mid Points', 'Original Points', 'Location', 'north');
0001 Screenshot.png
You could also use interparc (File Exchange), or use splines (demo attached).
mohammed alany
mohammed alany 2019년 8월 4일
many thanks Image Analyst

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2019년 8월 3일

0 개 추천

Use bwdist().

댓글 수: 9

mohammed alany
mohammed alany 2019년 8월 3일
Many thanks for your replay,
but this is not binary images, can you show me how i can get all the mid points
between each two nodes as:
d = [1 1; 2 1; 2 2; 1 2]
midpoints = [1.25 1; 1.5 1;1.75 1; 2 1; 2 1.25; 2 1.5; 2 1.75; 2 2; 1.75 2; 1.5 2; 1.25 2; 1 2]
darova
darova 2019년 8월 3일
I can show you.
mohammed alany
mohammed alany 2019년 8월 3일
i hope this can help me
darova
darova 2019년 8월 3일
What kind of nodes do you like more?
3Untitled.png
mohammed alany
mohammed alany 2019년 8월 3일
red color is enough, can you send any help???
darova
darova 2019년 8월 3일
You mean equal distance between nodes?
Image Analyst
Image Analyst 2019년 8월 3일
If you don't have that image, then what do you have? A list of (x,y) coordinates of where the orange spots are?
mohammed alany
mohammed alany 2019년 8월 3일
dear Image Analyst,
i have list of (x,y) coordinates, which is six orange spots as in figure,
i would like to finde midpoints along the path in order to calculate
the minimum distance between the all path with obstacles,
in my case if i have just 6 nodes, i will find just the distance between the orange spots and obstacles and this is dosn't mean the minimum distance between the obstacle and the path
darova
darova 2019년 8월 4일
What about interparc()?

댓글을 달려면 로그인하십시오.

질문:

2019년 8월 3일

편집:

2019년 8월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by