How to draw a line on a image between the pixels?

11 visualizaciones (últimos 30 días)
Varshini Guddanti
Varshini Guddanti el 22 de Sept. de 2016
Respondida: Image Analyst el 22 de Sept. de 2016
When I use the line command :
line([1,512],[99,99],'Color','r','LineWidth',2)
I'm getting a line at the centre of a pixel's area. But I want the line to be outside the pixels i.e between two pixels.
Can anyone help me out!!

Respuestas (3)

Image Analyst
Image Analyst el 22 de Sept. de 2016
To burn a line into the image (if that's what you want to do), see attached demo.
If you want to put the line into the graphics overlay above the image, use the line() function.

Walter Roberson
Walter Roberson el 22 de Sept. de 2016
Graphics devices that use pixels (that is, any graphics device you are likely to encounter!) work by adjusting the brightness at each pixel. You cannot draw between pixels because it is pixels that are the drawing mechanism.
Is it possible that what you really mean is that you have an image that you are displaying into a larger area than the number of array locations would require, so each image pixel is occupying multiple device pixels, and you want to draw between image pixels?
Another possibility is that you are rather indirectly talking about problems with anti-aliasing, that your lines might not appear sharp. If so then see the AlignVertexCenters line property.
  1 comentario
Varshini Guddanti
Varshini Guddanti el 22 de Sept. de 2016
Yeah. I now tried to change each pixel value to black to display a line instead of using line() function. Thanks though!

Iniciar sesión para comentar.


Dalibor Knis
Dalibor Knis el 22 de Sept. de 2016
Editada: Dalibor Knis el 22 de Sept. de 2016
Raster image consists of pixels with no space in between them. So you cannot draw a line between pixels. Might you managed that you would be breaking into another space :-)
But if you want to draw a line anywhere between pixel centers that all you need is to specify line end-points locations as decimals.
e.g:
imagesc(ones(10,10))
line([2 2 3 3 2], [2 3 3 2 2],'color','r')
line([2.4 2.4 2.6 2.6 2.4], [2.4 2.6 2.6 2.4 2.4],'color','r')
The outer square connects neighboring pixel centers. The inner square is in between.

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by