MATLAB: How to join two points, on a ‘map’, created with the command ‘ginput’

Image Processing Toolboxtwo dots

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)

Best Answer

  • 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)