How to join two points, on a 'map', created with the command 'ginput'?

조회 수: 2 (최근 30일)
Balanica Cristian
Balanica Cristian 2020년 5월 10일
답변: Stijn Haenen 2020년 5월 11일
So, this is my code for the two dots. But I don't know how to unite them like in the picture. (don't know how to make that dotted line)
Code:
harta=imread('harta.jpg');
imshow(harta)
[xA,yA]=ginput(1);
[xB,yB]=ginput(1);
harta=insertMarker(harta,[xA yA],'*','color','r');
harta=insertMarker(harta,[xB yB],'*','color','r');
imshow(harta)

채택된 답변

Mehmed Saad
Mehmed Saad 2020년 5월 10일
편집: Mehmed Saad 2020년 5월 10일
one way to do that is using line and then getting the frame
harta = imread('harta.jpg');
imshow(harta)
[xA,yA]=ginput(1);
[xB,yB]=ginput(1);
harta=insertMarker(harta,[xA yA],'*','color','r');
harta=insertMarker(harta,[xB yB],'*','color','r');
imshow(harta)
hold on,line([xA xB],[yA yB],'LineStyle',':','Color','r'),hold off
harta = getframe;
harta = harta.cdata;
imshow(harta)
There must be someother command which directly can do that.
insertShape maybe
Edit1: InsertShape will draw solid line
imshow(harta)
[xA,yA]=ginput(1);
[xB,yB]=ginput(1);
harta=insertMarker(harta,[xA yA],'*','color','r');
harta=insertMarker(harta,[xB yB],'*','color','r');
harta = insertShape(harta,'line',[xA yA xB yB],'Color','r');
imshow(harta)

추가 답변 (1개)

Stijn Haenen
Stijn Haenen 2020년 5월 11일
close all
clear
figure1=figure(1);
axes('Parent',figure1,...
'Position',[0 0 1 1]);
set(figure1,'Units','Normalized');
mapsIm=imread('maps.jpg');
imshow(mapsIm);
a=ginput_norm(2);
annotation(figure1,'line',[a(1,1) a(2,1)],...
[a(1,2) a(2,2)],'LineStyle','--');

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by