Skip to content

My own implementation of canny edge detection (with CUDA version too)

Notifications You must be signed in to change notification settings

WeiChihChern/Canny-Edge-Implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Canny-Edge-Implementation

(My own implementation on Canny Edge runs on both CPU & GPU: CUDA)

In Edge.h, there are two class member functions to do canny edge detection: cannyEdge() & cannyEdge2()

cannyEdge2() is an optimized version of cannyEdge() in 2D convolution process, it separates the sobel kernel into two smaller kernels for faster convolution process and reduces one for-loop.

Update 6/30

  • Provided a docker image: docker pull wchern/dev:opencv
  • Added Makefile (make clean supported) for ubuntu. Just make to compile.
  • Added argument support for selecting benchmark parameteres (smalle or large image, number of iterations, instructions below)
  • Edited define marco for gcc (version 7.4.0) compiler & microsoft's compiler (SIMD vectorization available on g++)
  • Factorized a lot of codes
  • Removed atan() & sqrt(gx^2 + gy^2) for speed boost
  • Added thread control function to select number of threads according to image size
  • vectorized some for-loops
  • optimized nonMaxSuppression() & hysteresis_threshold() to reduce if statements

Update on 7/1

  • Vectorized a for-loop using omp inbranch for flow control

Update on 7/9

  • Revised hysteresis threshold's algorithm, using recursive DFS now with same performance
Input size Time (ms) (Avg. of 1000 runs) OpenMP Enable? Env
637 x 371 0.593 ms (before: 3.647 ms) Yes, 4 threads gcc 7.4.0, ubuntu 18.04 (docker), -O2 optimization, omp simd
3840 x 2160 20.65 ms (before: 106.775 ms) Yes, 8 threads gcc 7.4.0, ubuntu 18.04 (docker), -O2 optimization, omp simd

Parameter Usage: ./app_name -firstPara -secPara thirPara

  • -firstPara = valid inputs are -small or -large
  • -secPara = valid input is -iter
  • -thirPara = valid input is any positve integer number for iteration

1

CUDA implementation added 7/22 (See Edge_Cuda.cuh, tested on Windows with Cuda 10.1)

Can be further optimized and factorized tho!

About

My own implementation of canny edge detection (with CUDA version too)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published