在 "imfreehand" 之前缩放

Zoom before a "imfreehand"

我正在尝试使用 imfreehand 以 LAB 颜色 space 测量图像特定区域的值。

但是,我想测量一些相当小的部分;有没有一种方法可以在执行 imfreehand 之前放大图像?就像您如何放大图像以在 Matlab 中检查它一样?

问题示例:

我的想法:

您可以使用 input 执行此操作。当命令行等待输入时,用户仍然可以随意修改图形(缩放、平移等)。

这是一个最小的例子:

% --- Load and display sample image
rgb = imread('pears.png');
imshow(rgb);

input('');

% [ Press any key when you are ready ]

imfreehand

你也可以用这个技巧做一点命令行界面,有时候会很方便。这是一个示例:

% --- Load and display sample image
rgb = imread('pears.png');
imshow(rgb);

% --- Main CLI loop
while true

    % Display
    clc
    fprintf('Please make a choice:\n');
    fprintf('\t[d] Draw freely\n');
    fprintf('\t[Other] Quit\n');

    c = input('?>', 's');
    switch (c)

        case 'd'
            imfreehand
            break;

        otherwise
            break;

    end
end

当然,您可以添加更多案例。这种界面通常非常方便,是开发 GUI 的廉价替代方案。

希望这对您有所帮助,