I would like to draw lines on the images manually (to be precise, labeling edges on the image manually), and output the corresponding edge map (binary image). I use MATLAB R2018a with the function imfreehand
. But the edge map is rather discrete.
Here is my Matlab script.
% 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);
Top panel figure: I manually draw a diagonal line on img
Bottom panel figure: it is edgeMap
and the labeled points (white) are rather discrete.
Question: Are there any methods to tackle this issue such that the labeled edges are continuous?