How to plot some points on an image?
268 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hamed Nazeri
il 24 Feb 2016
Risposto: MathWorks Computer Vision Toolbox Team
il 25 Nov 2024 alle 17:10
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 Commento
Geoff Hayes
il 24 Feb 2016
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.
Risposte (3)
Image Analyst
il 24 Feb 2016
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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173001/image.png)
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 Commenti
MathWorks Computer Vision Toolbox Team
il 25 Nov 2024 alle 17:10
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 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!