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????
I have two points lets say:
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????
The simplest way to draw a line onto an image is to use PLOT.
If you want a different color, either change the letter to any of
rgbcmykw
, or use RGB triplets (red is[1 0 0]
). Have a look at the lineseries properties for more formatting options.Starting with version R2014a you can use insertShape as follows:
img = insertShape(img,'Line',[x1 y1 x2 y2],'LineWidth',2,'Color','blue');
You can also draw multiple lines with the same command, but x1,x2,y2,y3 must be column vectors with each row representing a new line.
insertShape also allows you to draw rectangles, circles, and polygons.
Like this:
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.
If you have the Computer Vision toolbox. You can simply use shapeInserter.
Check out http://www.mathworks.com/help/vision/ref/vision.shapeinserter-class.html
To specify lines, you have to use the line below. Otherwise, you may get a rectangle
Example:
Take a look at the properties to see what you can edit.
You could download and use hline and vline in conjunction with
hold on
, using the techniques from visiting Steve on Image Processing. Or just use his techniques. Either way it works.