Image 标签图像边缘不连续(Matlab)

Image 标签图像边缘不连续(Matlab),image,matlab,computer-vision,Image,Matlab,Computer Vision,我想手动在图像上画线来精确,在图像上手动标记边缘,并输出相应的边缘映射二进制图像。我使用MatlabR2018A和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)

我想手动在图像上画线来精确,在图像上手动标记边缘,并输出相应的边缘映射二进制图像。我使用MatlabR2018A和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,标记的白色点相当离散

问题: 是否有任何方法可以解决此问题,使标记的边是连续的


您的直线只是给定点的线性插值。要获得连续版本,请使用interp1

或者,您可以使用

yy = interp1(x,y,min(x):max(x));

谢谢我还需要确保x,y是唯一的对并且是单一类型的。
yy = interp1(x,y,min(x):max(x));