How to plot some points on an image?
145 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have an image, and I have the coordinates of a few points which I'd like to draw on the image. When using the hold on & plot() functions, the coordinates of the image is from the bottom left corner of the window! not the corner of the figure! Someone help me please!
Thanks,
1 个评论
Geoff Hayes
2016-2-24
Hamed - can't you just apply an offset (to the y-coordinate) which is the number of rows of the image? For example, if your y-coordinate is 50 and the number of rows in your image is 500, then the transformed y-coordinate would be 500-50=450.
回答(3 个)
Image Analyst
2016-2-24
You'd have to show us your code. The origin for both the image array and the plotting coordinates is at the upper left, not the bottom left. Run this code:
imshow('cameraman.tif');
axis on
hold on;
% Plot cross at row 100, column 50
plot(50,100, 'r+', 'MarkerSize', 30, 'LineWidth', 2);
Are you sure you're not making the common beginner mistake of mixing up the order of row,column and x,y - remember (x,y) is (column,row) not (row,column).
0 个评论
MathWorks Computer Vision Toolbox Team
2024-11-25
As demonstrated in the two previous answers, fixing the axes of the image first and then using hold on and plot function should work correctly. Simply calling axis on before hold on, as in the first answer, should fix the axes.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!