Canny Edge Detection on CUDA

Hi all. I’ve implemented a variant of the Canny edge detector using CUDA 1.1 and updated for 2.0 beta. It uses some nice separable convolution functions for 3x3 Sobel and variable size Gaussian kernels that are a bit different from the SDK version although many of the principles were kept. Also, I’ve implemented an interesting function to account for hysteresis processing between data from disparate thread blocks. Most of the optimization were made during 1.1 and geared towards coalesced read/writes and achieving a high occupancy ratio using few registers and minimizing shared memory.

I’ve submitted two versions:
One version can be compiled for Matlab use into a .mexw32, the other interfaces with GLUT and openCV so you need those respective libraries. I believe the ladder accepts various image formats from jpg and tif to avi movie format so long as width and height ratios are multiples of 16.

Source Code Page

A paper was also written about the findings. Some general testing showed a significant speedup 60x+ of the CUDA version over Matlab’s edge function during CUDA 1.1.


Feel free to modify, comment the code.

Yuancheng Luo
Undergraduate, UMIACS at the University of Maryland College Park

Hi devnk!

I have tried to implement your algorithm using openCV on my computer but obviously I still have problems to run the separable gaussian function. I have noticed that the gaussian filter crash with image 16 pixels multiple.
exemple : 512512 : crash ! and 513513 : work width two strips of noise < 16 pixels on the right and bottom…

Anyone meet that problem?

Thanks a lot :biggrin:

Up ! …and some details… d_gaussianSeparablePassX() is the origin of the crash.

Hai…i was thinking of using cuda with opencv…is it still a novice in cuda…suppose like the object detection…is it possible??

yes that’s possible ;) you would be able to find some topic about it on the web :)

okay…let me go around and see what i can…