Can I plot a dot at a specified pixel location?

I have a set of pixel locations, and I need to draw a dot at each of these know pixel locations. For example, I need to draw a dot in the figure at a point with pixel location (640,400), and then draw a dot at another point with pixel location (640,600).
The screen pixel size is 640x640.
Thank you.

 Respuesta aceptada

Image Analyst
Image Analyst el 5 de Jul. de 2014
if ndims(yourImage == 1)
% Grayscale image.
yourImage(row, column) = 255;
else
% Color image
yourImage(rows, column, :) = 255; % or [255,255,255] if that doesn't work.
end

8 comentarios

The above is to write it into an image. If you just want to put a dot into the overlay above the image but don't want to actually change the value of the image at that location, use plot():
hold on;
plot(x, y, 'w.', 'MarkerSize', 10);
Image Analyst
Image Analyst el 6 de Jul. de 2014
zy, did either of those work for you?
zy
zy el 7 de Jul. de 2014
Thank you for your help. But it seems that those did not work. I am still trying to get the result I need.
Do you have any other suggestions?
Thank you.
Image Analyst
Image Analyst el 7 de Jul. de 2014
Can you explain more what "did not work" means to you? I know they do put a dot in and on the image so I'm not sure why you say they don't work. Show me your script so I can see what you did.
zy
zy el 11 de Jul. de 2014
Is it correct that your way is to plot a dot at a pixel location by adjusting the brightness level ?
I downloaded an gray scale photo image, and applied your suggested code, but I did not find any change in the image. I don't quite understand.
marilyn=imread('marilyn.jpg'); figure if ndims(marilyn == 1) % Grayscale image. marilyn(300, 454) = 255; else % Color image marilyn(300, 454, :) = 255; % or [255,255,255] if that doesn't work. end imshow(marilyn);
Image Analyst
Image Analyst el 11 de Jul. de 2014
It might be possible that the image is demagnified so much that the one pixel you set was subsampled out when it went to display it. Try a different pixel, or enlarge your image by maximizing it, or use a smaller image, or set a range of pixels, like a rectangle, instead of just one small pixel.
Safwan Ibrahim
Safwan Ibrahim el 5 de Oct. de 2017
"or set a range of pixels, like a rectangle, instead of just one small pixel." Can you please tell us how can you do that ?
Like this
yourImage(row1:row2, column1:column2, :) = 255; % or [255,255,255] if that doesn't work.

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

zy
el 5 de Jul. de 2014

Comentada:

el 6 de Oct. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by