Skip to contents

canny finds edges in an image using the Canny algorithm.

Usage

canny(
  image,
  threshold1,
  threshold2,
  aperture_size = 3,
  L2_gradient = FALSE,
  target = "new"
)

Arguments

image

An Image object.

threshold1

A numeric indicating the first threshold for the hysteresis procedure

threshold2

A numeric indicating the second threshold for the hysteresis procedure

aperture_size

Aperture size for the Sobel operator (default: 3).

L2_gradient

A logical flag, indicating whether a more accurate L2 norm should be used to calculate the image gradient magnitude, or whether the default L1 norm is enough (default: FALSE).

target

The location where the results should be stored. It can take 3 values:

  • "new":a new Image object is created and the results are stored inside (the default).

  • An Image object:the results are stored in another existing Image object. Note that target has to be an 8-bit ("8U") single-channel image with the same dimensions as image, otherwise an error will be thrown.

Value

If target="new", the function returns an Image

object. If target is an Image object, the function returns nothing and modifies that Image object in place.

References

Canny J. A computational approach to edge detection. IEEE Trans Pattern Anal Mach Intell. 1986;8: 679–698. doi:10.1109/TPAMI.1986.4767851

Author

Simon Garnier, garnier@njit.edu

Examples

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
balloon_canny <- canny(balloon, 50, 50)