How to plot some points on an image?
253 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hamed Nazeri
am 24 Feb. 2016
Beantwortet: MathWorks Computer Vision Toolbox Team
am 25 Nov. 2024 um 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 Kommentar
Geoff Hayes
am 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.
Antworten (3)
Image Analyst
am 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);
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 Kommentare
MathWorks Computer Vision Toolbox Team
am 25 Nov. 2024 um 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 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!