5 views (last 30 days)

I have to import a text file in Matlab that contains several random numbers representing X and Y co-ordinates. Then I have to show these points on a .png picture. The text file contains 20 such points. I used "dlmread" but it makes a single matrix of all these points while I need 20 such matrices. How can I make several Matrices using that text file and how can I show these points in the Picture.?

P.S The points are like:

1428 742

256 84

986 547... etc

These points represent the pixels of a picture and I have to show them in a different color, its like darts hitting the picture but I have no idea how to do it.

Image Analyst
on 15 Jan 2015

I fail to see why you need 20 matrices when all your x,y data is in the one matrix you get from dlmread(). How about just calling dlmread() and plot(), something like this:

data = dlmread(filename, ' ');

[rows, columns] = size(data);

imshow(yourImage);

hold on;

for row = 1 : rows

randomColor = rand(1,3);

plot(data(row, 1), data(row, 2), '.', ...

'Color', randomColor, 'MarkerSize', 3);

end

Image Analyst
on 30 Jan 2015

I'm sure you must have thought of the obvious idea to adjust xRect and yRect so that the rectangle is one pixel smaller:

xRect(row, 1:5) = [x1+1,x2-1,x2-1,x1+1,x1+1];

yRect(row, 1:5) = [y1+1,y1+1,y2-1,y2-1,y1+1];

Was there some reason why it didn't work?

Opportunities for recent engineering grads.

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

Start Hunting!
## 0 Comments

Sign in to comment.