fast bresenham

Version 1.0.0.0 (21.2 KB) by sun peng
implement bresenham algo using C mex file for higher speed
1.5K Downloads
Updated 18 Dec 2006

View License

Two functions, LineTwoPnts and SegInmat, are provided.

LineTwoPnts lines two arbitray points.
for example:
------------
[rr, cc] = LineTwoPnts(-2,-3, 2,4);
disp('The line between (-2,-3) and (2,4): ');
disp('row: ');disp(rr);
disp('col: ');disp(cc);

The line between (-2,-3) and (2,4):
row:
-2 -1 -1 0 0 1 1 2

col:
-3 -2 -1 0 1 2 3 4

SegInMat returns value of a segment within a matrix
for example:
------------
mat = reshape(1:18, 3, 6);
elems = SegInMat(mat, 1,1, 3,5);
disp('mat:'); disp(mat);
disp('the values of line (1,1) and (3,5) within mat: ');
disp(elems);

mat:
1 4 7 10 13 16
2 5 8 11 14 17
3 6 9 12 15 18

the values of line (1,1) and (3,5) within mat:
1 5 8 12 15

Using C mex file for higher speed.

Have fun:)

Cite As

sun peng (2024). fast bresenham (https://www.mathworks.com/matlabcentral/fileexchange/13221-fast-bresenham), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

bresenham_mex/html/

Version Published Release Notes
1.0.0.0

Enhanced error checking;
add a VC8 project.