No BSD License  

Highlights from
Bresenham's Line

4.0

4.0 | 7 ratings Rate this file 35 Downloads (last 30 days) File Size: 2.18 KB File ID: #12939

Bresenham's Line

by Narupon Chattrapiban

 

08 Nov 2006 (Updated 08 Nov 2006)

Generate a line profile of a 2d image

| Watch this File

File Information
Description

Generate a line profile of a 2d image
using Bresenham's algorithm.

For a demo purpose, try

bresenham();

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
09 Nov 2006 scardanzan ivan

an image with an example , please

27 Nov 2006 julio choque

excellent

14 Mar 2007 Ryan Crow

Well done! Demo and visualization included.

26 Mar 2007 Canuck Hanks

Very nice with demo! Thanks!

09 Oct 2009 Tina Hegarty

Brilliant. You probably just saved me a few hours! Many thanks.

12 Apr 2010 Christian  
12 Apr 2010 Christian

Hi! Nice Code!

However, i think there is a little bug:

the code that i downloaded says:

----------
  if steep,
        myline(n) = mymat(x_n,y_n);
        outmat(x_n,y_n) = 0;
        X(n) = x_n;
        Y(n) = y_n;
    else
        myline(n) = mymat(y_n,x_n);
        outmat(y_n,x_n) = 0;
        X(n) = y_n;
        Y(n) = x_n;
    end
-------

...this does not work for me, i think the code within the if and else statements should be swapped:

---------
if steep,
        myline(n) = mymat(y_n,x_n);
        outmat(y_n,x_n) = 0;
        X(n) = y_n;
        Y(n) = x_n;
    else
        myline(n) = mymat(x_n,y_n);
        outmat(x_n,y_n) = 0;
        X(n) = x_n;
        Y(n) = y_n;
    end
-------

Best,
Christian

17 May 2010 Fernando G. del Cueto  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
bresenham Narupon Chattrapiban 22 Oct 2008 08:48:27
line profile Narupon Chattrapiban 22 Oct 2008 08:48:27
image Narupon Chattrapiban 22 Oct 2008 08:48:27
bresenham lorenzo tognalini 13 Jan 2011 06:42:49
image Pavel 25 Feb 2011 09:28:07
line profile Pavel 25 Feb 2011 09:28:10
bresenham Felix Tarik 29 Jan 2012 11:28:44
bresenham abc cde 08 Feb 2012 02:27:43

Contact us at files@mathworks.com