CANNY_ED_CVIP

canny_ed_cvip() - perform a Canny edge detection on the image.

Contents

SYNTAX

out_img = canny_ed_cvip( input_image, sigma, low_thresh, high_thresh )

Input Parameters include :

Output Parameters include :

DESCRIPTION

The Canny algorithm,developed in 1986,is an optimal edge detection method.The algorithm consists of four primary steps:

  1. Gaussian filter: The variance $\sigma$ of the gaussian function is given as an input.
  2. Find the magnitude and direction of the gradient.The equations are similar to Sobel or Prewitt edge detectors.Here the following masks are used: hor = 1/2*[-1 1;-1 1]; ver = 1/2*[-1 -1;1 1];
  3. Apply nonmaxima suppression. For more details on nonmaxima suppression look at reference 1.
  4. Apply two threshold(hystersis).The two threshold for hystersis are the inputs low_thresh and high_thresh.These numbers are in the range 0-10.If high_thresh is zero,then the hystersis based thresholding is not applied.

REFERENCE

1. Scott E Umbaugh. DIGITAL IMAGE PROCESSING AND ANALYSIS: Applications with MATLAB and CVIPtools, 3rd Edition.

EXAMPLE

%Read image

 input_image = imread('Mandrill.bmp');

% Gaussian variance

 sigma = 3;

% low threshold value for hystersis thresholding

 low_thresh1 = 1;
 low_thresh2 = 0;

% high threshold value for hystersis thresholding

 high_thresh1 = 3;
 high_thresh2 = -1;

% Call function

 out1 = canny_ed_cvip( input_image, sigma, low_thresh1, high_thresh1 );
 out2 = canny_ed_cvip( input_image, sigma, low_thresh2, high_thresh2 );

% Display input image

 figure;imshow(input_image);title('Input Image');

% Display output image ,you need to clip and stretch the output for a visible result.

 figure; imshow(hist_stretch_cvip(2*out1,0,1,0,0),[]);title('Canny edge detected Output Image with Hysterisis thresholding');
 figure; imshow(hist_stretch_cvip(2*out2,0,1,0,0.0045),[]);title('Canny edge detected Output Image with out Hysterisis thresholding');

CREDITS

Author: Mehrdad Alvandipour, May 2017
Copyright © 2017-2018 Scott E Umbaugh
For updates visit CVIP Toolbox Website