---
title: cannyEdgeDetector()
framework: coreimage
role: symbol
role_heading: Type Method
path: coreimage/cifilter-swift.class/cannyedgedetector()
---

# cannyEdgeDetector()

Applies the Canny edge-detection algorithm to an image.

## Declaration

```swift
class func cannyEdgeDetector() -> any CIFilter & CICannyEdgeDetector
```

## Return Value

Return Value A CIImage with the detected edges.

## Discussion

Discussion This filter performs a Canny edge-detection on the input image, producing a black-and-white image with the detected edges. White pixels indicate an edge, and black pixels indicate no edge. The Canny edge-detection filter uses the following properties: The following code applies Canny edge-detection to an image: func cannyEdgeDetector(inputImage: CIImage) -> CIImage {     let filter = CIFilter.cannyEdgeDetector()     filter.inputImage = inputImage     filter.gaussianSigma = 5     filter.perceptual = false     filter.thresholdLow = 0.02     filter.thresholdHigh = 0.05     filter.hysteresisPasses = 1     return filter.outputImage! }

## See Also

### Filters

- [blendWithAlphaMask()](coreimage/cifilter-swift.class/blendwithalphamask().md)
- [blendWithBlueMask()](coreimage/cifilter-swift.class/blendwithbluemask().md)
- [blendWithMask()](coreimage/cifilter-swift.class/blendwithmask().md)
- [blendWithRedMask()](coreimage/cifilter-swift.class/blendwithredmask().md)
- [bloom()](coreimage/cifilter-swift.class/bloom().md)
- [comicEffect()](coreimage/cifilter-swift.class/comiceffect().md)
- [coreMLModel()](coreimage/cifilter-swift.class/coremlmodel().md)
- [crystallize()](coreimage/cifilter-swift.class/crystallize().md)
- [depthOfField()](coreimage/cifilter-swift.class/depthoffield().md)
- [edges()](coreimage/cifilter-swift.class/edges().md)
- [edgeWork()](coreimage/cifilter-swift.class/edgework().md)
- [gaborGradients()](coreimage/cifilter-swift.class/gaborgradients().md)
- [gloom()](coreimage/cifilter-swift.class/gloom().md)
- [heightFieldFromMask()](coreimage/cifilter-swift.class/heightfieldfrommask().md)
- [hexagonalPixellate()](coreimage/cifilter-swift.class/hexagonalpixellate().md)
