% function [imageMask]=bresenhamLineH(ln,pt,imageSize); % % bresenhamLineH - Compute the line using bresenham's algorithm. % %Comments: % Coordinate system. We consider a right handed coordinate system with the center being on % the upper left corner of the image, the X axis move from left to right and the Y-axis % from top to bottom. In this case the Z-axis is positive in the forward direction. For this function % to work all the coordinates should be INTEGER numbers. No boundary checking is performed, so if the initial % point is out of bounds the program will crash. % %Usage: [imageMask]=bresenhamLineH(ln,pt,imageSize); %Example: [lineIm]=bresenhamLineH([2 -1 0]',[0 0]',[100 200]); figure, imagesc(lineIm); % %Arguments: % ln - A column array containing the coordinates of the line (i.e. 3x1 column vector) % pt - A point belonging to the line in image coordinates (i.e. 2x1 column vector) % imageSize - The size of the image as a row vector (Rows,Columns) % %Returns: % imageMask - A 2D array of size imageSize(1)ximageSize(2) that has ones where the line passes % %Written by : % Konstantinos Bitsakos % Department of Computer Science % University of Maryland, College Park % kbits at cs dot umd dot edu % % References: % Jack E. Bresenham, "Algorithm for computer control of a digital plotter", IBM Systems Journal, Vol. 4, No.1, January 1965, pp. 25-30 % % March 2008 % % This executable was compiled with Microsoft Visual C++ 6 under Windows XP and is tested on Matlab 7.3. Send me an email if you need the linux version.