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.
采纳的回答
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 个评论
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.
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Images 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
