File Exchange

image thumbnail

Canny Edge Detector

version (3.75 KB) by Halim Can
Performs Canny Edge Detector with some additional features.


Updated 21 Jan 2009

View Version History

View License

It was my course project for Machine Vision, so do not expect something quite professional. I think it performs quite nicely already, so I don't think any of you will have any problems. It has quite a description in the beginning of the code, also suitable for

help CannyEdgeDetector


Some methods and usages may not be preferably feasible, but they had to be included in the program, in order to provide the code working just like it is told in the original paper of Canny's. So it is quite suitable for also gaining the understanding of the concept, I suppose. I also tried to include as much feasible usages as I could, like the use of morphological operations.

Have fun, hope it works for you...

Cite As

Halim Can (2021). Canny Edge Detector (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (19)


Karthik Divakaruni

Karthik Divakaruni

Does the job , well enough !! Thanks a lot for sharing.

Halim Can

khader Mohammad, please make sure you included "image processing toolbox" in your matlab installation.

khader Mohammad


Erhan Go

Translation: Code proved to be useful for one of our assignments, Thanks...

Erhan Go

Ödevlerimizden birinde sorulardan biri buydu, teşekkürler...

Erhan Go

Johnny Sandaire


When I run this m file, I get the following errors:

??? Index exceeds matrix dimensions.

Error in ==> CannyEdgeDetector>parse_inputs at 222
imi = varargin{1};

Error in ==> CannyEdgeDetector at 60
[imi,sigma,method,Th,Tl,feature] = parse_inputs (varargin{:});

Any ideas how to get it to run?


ahh, sorry. its my fault. it takes the data as input, not the file path.


hi! I got a blank rectangle as a result.


1) i only rated this submission once, which hardly qualifies as 'permanent low rate'...
2) the image processing tbx (already) comes with EDGE, which does pretty much the same stuff (and some more) - but does not require the fuzzy logic tbx... it would have been prudent to (at least) mention the function in the help section as 'see also edge'...

Halim Can

So, after all these downloaders, no new feedbacks ?? Well, I hope it is not because the permanent low rates (specially given by us) for errors that are fixed SO easily.. Even not by editting the m-file, but only the requirements section.

Or should I and other people interpret this no comment situation as "there is no problem at all, this works flawlessly.."

Please give feedbacks, negative or positive, so that everyone knows if this function works, and if this was useful for you..


Halim Can

Fuzzy Logic Toolbox is going to be listed in the requirements list once the reviewing is done. I already posted the update. So, pls let's not worry about this anymore..


the function gaussmf is part of the fuzzy tbx, which you do not mention as a requirement...
therefore, a lot of people will get frustrated after downloading your submission...

Halim Can

1) I wasn't aware of what i was doing. It accidentally happened, tried to reverse it, but I think there is no option like that... anyway, thanks for compensating...

2) I couldn't find any missing functions. It works with me. But if you can give a little more detail about the error you encountered, maybe we will be able to diagnose...


1) authors must not rate their own submissions...
2) function missing...

Halim Can

Well, gaussmf is the gauss membership function, which does nothing but returning a gaussian shape. Or at least I used it for that purpose :).

It is included in Fuzzy Logic Toolbox, as far as I remember. It did not catch my attention when I was defining the "Required Products" section, sorry for that. But once you gain access to this fuzzy logic toolbox, this problem should not show up anymore.


??? Undefined function or method 'gaussmf' for input arguments of type 'double'.

Error in ==> CannyEdgeDetector at 67
G = gaussmf(-10:10,[sigma 0]);

MATLAB Release Compatibility
Created with R2007b
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!