Draw an angled line, with a slope relative to a reference point.
function [yline xline] = drawslope(I, alpha, refpoint)
%
% function to draw a line at a desired angle <alpha>,
% which goes through a reference point <refpoint>
% function inputs:
% <I>: Image for which the drawing is desired.
% Range:3Dim, grayscale, or logical
% <alpha>: Angle in degrees, where 0 is complete
% horizontal
% Range: -Inf - +Inf (cyclic after +
% (-) 180 degrees of course)
% <refpoint> : Reference interception point with the slope
% Range: A varaible of size 2x1, where
% refpoint(1) is horizontal and (2) is vertical
% function outputs:
% <yline> : Y axis coordinates of both line ends
% <xline>: X axis coordinates of both line ends
%
% outputs should be used with plot
% function as following:
% plot(yline,xline,...plot specifiers)
%
% Example usage:
% Image = imread('someImage');
% image_centroid = [100 240];
% [yline xline] = drawslope(Image, -60, image_centroid);
% imshow(Image);
% hold on;
% plot(yline, xline, 'blue','LineWidth',2);
%
%
% Written by Elad Boneh, 15.8.2009
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Cite As
Elad (2024). Draw an angled line, with a slope relative to a reference point. (https://www.mathworks.com/matlabcentral/fileexchange/25370-draw-an-angled-line-with-a-slope-relative-to-a-reference-point), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Image Processing and Computer Vision > Image Processing Toolbox > Image Filtering and Enhancement > Image Arithmetic >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.