如何找到点击点的索引并将其添加到数组、列表或向量的末尾?
h=figure;
image(result);
locx = [];
locy = [];
while (ishandle(h))
pos = get(0, 'PointerLocation');
locx(end + 1) = pos(1);
locy(end + 1) = pos(2);
pause(1);
end
虽然我只单击了两个点来查看它们的 x、y 和索引,但许多 x 位置已保存在 locx 数组中。请建议解决方案和修复:
locx =
Columns 1 through 16
635 1116 231 758 771 591 596 46 116 116 116 1362 852 498 1920 1663
Columns 17 through 32
733 795 795 1920 1895 1806 1061 700 123 1102 1097 1615 1 226 233 233
Columns 33 through 43
191 854 836 1920 1920 1920 1920 1920 1905 1189 1912
我建议使用ginput https://www.mathworks.com/help/matlab/ref/ginput.html函数代替:
h = figure;
image(result);
[locx, locy] = ginput(2);
这将为您提供轴内的点,必须通过四舍五入将其转换为图像中的索引:
locx = round(locx);
locy = round(locy);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)