View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Detect lines in grayscale image using Hough Transform

4.0 | 19 ratings Rate this file 91 Downloads (last 30 days) File Size: 423 KB File ID: #9226 Version: 1.0
image thumbnail

Detect lines in grayscale image using Hough Transform


Tao Peng (view profile)


02 Dec 2005 (Updated )

Detection of lines (line segments) in a grayscale image using gradient-based Hough Transform.

| Watch this File

File Information

Hough transform for line detection based on image's gradient field.

1. Operates on grayscale images, NOT B/W bitmaps.
2. NO loops involved in the implementation of Hough transform, which makes the operation fast.
3. Able to detect the two ends of line segments.


This file inspired Load Gaus().

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (26)

nice code, please describe with some more excercise

30 Dec 2013 hao

hao (view profile)


Comment only
08 Jun 2013 Perig Vennetier

02 May 2013 Lucia Morales-Rivas

I think matlab R2010b fails importing the image as an argument of your function, I used "imread" instead. Nice results, thanks.

20 Apr 2013 xin

xin (view profile)

Great code !The author show us with the parameter
domain with the color image.It's vivid!The result is very fantastic!

14 Feb 2013 Sid

Sid (view profile)

26 Sep 2012 Gintautas

06 Jul 2012 Ryan

Ryan (view profile)

14 Feb 2012 Nitin

Nitin (view profile)

17 Dec 2011 majid

majid (view profile)

this m code works so well.
but is there any paper ,journal or web page that describe this algorithm?

12 Dec 2011 ole andersen


13 Nov 2011 Manuel

Manuel (view profile)


03 Nov 2011 György Kovács

Unfortunately the comments are not synchronized with the new input and output parameters. What is 'varargin' and 'varargout'?

Comment only
31 Aug 2011 James Kerns

08 Aug 2011 Paul Johnson

doesnt work

20 Jul 2010 m f

m f (view profile)

Hey, I was wondering, is it possible to move the point that rho is measured from from the top left corner of the image to the center of the image?

Comment only
05 Mar 2009 zhiyang

Hi, I'm a 3rd year university student doing an individual project on digital image processing. I need to detect the needle of a dial gauge. I'm new to MATLAB and would like to ask a few questions.

1. I've loaded the Hough_Grd file on to the editor, and loaded it with my image. But how do I view the final resulting image after the line detection? All I see is the matrix numbers.

2. Is there a way to detect specific lines that go through a point?

Sorry if posting my questions here is not appropriate, and thank you for your time.

Comment only
25 Nov 2008 Fady Soliman

Satisfiable results, was looking for the resulting line coordinates and at last i found it here, thank you very much

20 Jun 2008 Mona Carlos

03 May 2008 Vinh Nguyen

28 Apr 2008 yuan xinzhe

15 Dec 2007 venkatesh sathyanaayaa

01 Nov 2007 K K


Comment only
12 Mar 2007 Tao Peng

Hi, Eugene: "accumarray" is a Matlab function available from versions 7.0 (R14). If you are using an older version of Matlab, that is the problem.

Comment only
10 Mar 2007 Eugene Kon

Exanples no works!!!!

error message:
??? Undefined function or variable 'accumarray'.

??? Undefined function or variable 'accumarray'.
Error in ==> Hough_Grd.m
On line 260 ==> accum = accumarray( sub2ind(prm_accumsize, sub_rho, sub_theta), ...

Comment only
27 May 2006 David Holden

Contact us