make gridlines and enter the x and y coordinates of an object to change its position on the page.

2 Ansichten (letzte 30 Tage)
Hi, I have an image that I need to trace and know the position of its x-y coordinates.
So far I have been able to trace and get the x-y coordinate information from the results of the traced image. But after the coordinates came out, the location of the point was not what I wanted.
Is there a way to enter the x -y values to change its position? And maybe I was wondering if there is a way to make gridlines so its easier when i trace the image.
Thank you!

Akzeptierte Antwort

Image Analyst
Image Analyst am 13 Okt. 2020
You can overlay gridlines on the image with xline() and yline()
[rows, columns, numColors] = size(rgbImage)
for row = 1 : 20 : rows
yline(row, 'Color', 'r', 'LineWidth', 2);
end
for col = 1 : 20 : columns
xline(col, 'Color', 'r', 'LineWidth', 2);
end
If you want to edit/change the x and y values you can do that by double clicking the array in the workspace panel to bring it up in the Variable Editor, then you can just type in the values you want. Or of course you can just do it from the command line if you want:
x(9) = 100; % Change point #9
y(9) = 800;
or whatever.
  2 Kommentare
Grishelda Athallah
Grishelda Athallah am 14 Okt. 2020
Undefined function or variable 'yline'.
Error in TRACEMASK (line 10)
yline(row, 'Color', 'r', 'LineWidth', 2);
i've tried but error, what does it mean?
Image Analyst
Image Analyst am 14 Okt. 2020
You must have an old version of MATLAB. You blew right past that part when you originally posted where it asked you for your version number for some reason. Why did you not fill out the entire form when you posted?
Anyway, you can replace yline with this:
[rows, columns, numColors] = size(rgbImage)
hold on;
for row = 1 : 20 : rows
plot([1, columns], [row, row], 'Color', 'r', 'LineWidth', 2);
end
for col = 1 : 20 : columns
plot([col, col], [1, rows], 'Color', 'r', 'LineWidth', 2);
end
hold off;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by