Add Visible Line over Images (Modifed Version of the one in Doug's MATLAB Video Tutorials)

by

 

This is a modified version of the one shared in Doug's MATLAB Video Tutorials

cursorLine(x,y,innerThickness, outerThickness)
function cursorLine(x,y,innerThickness, outerThickness)
% Making a line visible over an image in MATLAB
% x : X axis co-ordinates of the points on the line
% y : Y axis co-ordinates of the points on the line
% innerThickness : Thickness of the black line (inner line)
% outerThickness : Thickness of the white line (outer line)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author : Anand P
% Email : anand@elementzonline.com
% Mobile : +91-9020616699
% Landline : +91-471-3106699
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

% Setting default values if no. of inputs are less than specified
if nargin == 3
    outerThickness = 4;
else
    if nargin == 2
        outerThickness = 4;
        innerThickness = 2;
    else
        if nargin < 2
            error('X and Y co-ordinates of the points on the line are mandatory');
        end
    end
end

% Display white line only if outer line width exceeds inner line width
if outerThickness > innerThickness
    h.thick = line(x,y);
    set(h.thick, 'color', [1 1 1]);
    set(h.thick, 'linewidth', outerThickness);
end

% Display black line only if inner line width is more than zero
if innerThickness > 0
    h.thin  = line(x,y);
    set(h.thin , 'color', [0 0 0]);
    set(h.thin , 'linewidth', innerThickness);
end
end

Contact us