【发布时间】:2018-06-27 14:36:58
【问题描述】:
我正在使用 MATLAB 函数 ginput 来标记我的图像数据以进行进一步处理。这是我的代码:
file_name = "test.jpg";
% Read the image
img = imread(file_name);
% Get the image dimension
imgInfo = imfinfo(file_name);
width = imgInfo.Width;
height = imgInfo.Height;
% Using ginput function to label the image
figure(1);
imshow(img);
hold on;
[x, y] = ginput(4); % Manually label 4 points
scatter(x, y, 100, 'ro', 'filled'); % Plot the marked points on img
hold off;
我的问题:
我发现输出x 和y 不是整数,因此它们不代表像素索引。
有时,max(x) > width 和 max(y) > height 这两个条件都满足。似乎表明我使用ginput 标记的 4 个点在图像之外(但实际上不是)。
我知道这个问题与图像坐标系设置有关,但我仍然不确定如何将从ginput 函数获得的x 和y 转换为实际的像素索引?
谢谢。
【问题讨论】: