How to draw a line on an image in matlab?

Viewed 102559

I have two points lets say:

  • P(x,y) [point lies at the top of image]
  • P'(x',y') [point lies at bottom of image]

Now i want to draw a line betwen these two points....and the line should appear on image means should be visible.

how to do this????

6 Answers

Like this:

figure;
hold on;
imagesc(img);
line([x1,x2],[y1,y2],'Color','r','LineWidth',2)
hold off

Where y is the "down" direction and x is the "right" direction in the image. Change the color and width as necessary to be visible.

load clown
image(X)
colormap(map)
c = size(X,2)
mid = round(c/2)
X(:,mid) = 1
image(X)
Related