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.

 Risposta accettata

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 Commenti

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);
zy, did either of those work for you?
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.
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.
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);
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.
"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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by