【问题标题】:Get X Y coordinates of image获取图像的 X Y 坐标
【发布时间】:2021-07-10 08:41:27
【问题描述】:

我需要了解如何将获得的坐标形式的图像放入矩阵并保存。

clc
clear all
k=imread('l.jpg');
for i=1:4
figure(1),imshow(k)
axis on
hold on
title(i)
[x,y]=ginput(1)
pause
end

【问题讨论】:

  • 当您读取图像时,您已经得到了一个矩阵,并且像素的(行,列)位置正是您所说的(x,y)坐标。
  • 您已经在使用xy。如果你想在循环之后存储它们,你需要学习基本的matlab,阅读索引和数组

标签: matlab matrix coordinates


【解决方案1】:

正如 cmets 所建议的,这里有一种方法,它通过索引数组 xy 将值存储到数组中,并使用索引变量 i 在每次循环迭代时递增。您可能知道必须按下任何 Key 才能继续循环。本例使用内置MATLAB镜像'tire.tif'

clc;
clear;

Image = imread('tire.tif');
imshow(Image);
axis on
Number_Of_Coordinates = 4;

x = zeros(1,Number_Of_Coordinates);
y = zeros(1,Number_Of_Coordinates);

for i = 1: Number_Of_Coordinates
    title( i)
    [x(i),y(i)] = ginput(1);
    fprintf("Coordinates Stored: (%f,%f) -> Press and key to continue\n",x(i),y(i));
    pause
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    • 1970-01-01
    相关资源
    最近更新 更多