x,y coordinates in .txt to points on image
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Stijn Senhorst
le 9 Juin 2021
Commenté : Image Analyst
le 10 Juin 2021
Hi there,
I need some help with loading coordinates in a .txt to points in an image. In the attached .txt are all the coordinates. What is the best approache to do this?
thanks,
1 commentaire
Scott MacKenzie
le 9 Juin 2021
What do you mean by "to points in an image"? The x-y coordinates are in the range -10 to +10 (approximately), so if you intend to map them to an image (e.g., 1000x2000), then some scaling will be necessary. Explain your objective, if you can, please.
Réponse acceptée
Adam Danz
le 10 Juin 2021
- Read in the file using A = readmatrix(filename)
- Plot the values using the plot command where x is the first column of A and y is the second column of A. Use indexing A(:,i)
1 commentaire
Image Analyst
le 10 Juin 2021
And make sure you scale the (x,y) values
[rows, columns, numColors] = size(yourImage);
imshow(yourImage);
impixelinfo;
x = rescale(A(:, 1), 1, columns);
y = rescale(A(:, 2), 1, rows); % Or however you need to do it.
and make sure you call
hold on;
after you call imshow() but before you call plot() or else the plot will blow away your image.
And remember images are indexed (row, column) which is (y, x) -- not (x,y) like plot() uses. So don't call yourImage(x, y) and expect that the gray level will match the gray level under that coordinate. You'd need to use yourImage(y, x).
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!