【发布时间】:2018-07-31 08:28:24
【问题描述】:
我想在图像上手动画线(准确的说是手动在图像上标注边缘),并输出对应的边缘图(二值图像)。我将 MATLAB R2018a 与函数 imfreehand 一起使用。但边缘图相当离散。
这是我的 Matlab 脚本。
% Read the image
img = imread('test.jpg');
img_size = size(img);
height = img_size(1);
width = img_size(2);
% Draw a line on the image manually
figure(1);
im(img);
h = imfreehand(gca, 'Closed', false);
% Get positions (x, y)
pos = h.getPosition();
x = int16( pos(:, 1) );
y = int16( pos(:, 2) );
% Create a binary image containing
% labeled edges
edgeMap = zeros(height, width);
for i = 1 : length(x)
edgeMap( y(i), x(i) ) = 1;
end
% Show the edgeMap
figure(2);
im(edgeMap);
顶面板图:我在img上手动画了一条对角线
底部面板图:它是edgeMap,标记点(白色)相当离散。
问题: 有什么方法可以解决这个问题,使得标记的边缘是连续的?
【问题讨论】:
标签: image matlab computer-vision