x,y coordinates in .txt to points on image

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 Comment

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.

Sign in to comment.

 Accepted Answer

  1. Read in the file using A = readmatrix(filename)
  2. 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 Comment

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).

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Release

R2021a

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!