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

# depthOfField()

Simulates a depth of field effect.

## Declaration

```swift
class func depthOfField() -> any CIFilter & CIDepthOfField
```

## Return Value

Return Value The modified image.

## Discussion

Discussion This method applies the depth of field filter to an image. The effect simulates changing the focus of the camera before taking a photograph. The depth of field filter uses the following properties: The following code creates a filter that results in the center cilantro being in focus while gradually blurring to the top and bottom of the image: func depthOfField(inputImage: CIImage) -> CIImage {     let depthOfFieldFilter = CIFilter.depthOfField()     depthOfFieldFilter.inputImage = inputImage     depthOfFieldFilter.radius = 5     depthOfFieldFilter.point0 = CGPoint(x: 2349, y: 846)     depthOfFieldFilter.point1 = CGPoint(x: 571, y: 3121)     depthOfFieldFilter.unsharpMaskRadius = 7     depthOfFieldFilter.unsharpMaskIntensity = 10     return depthOfFieldFilter.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)
- [cannyEdgeDetector()](coreimage/cifilter-swift.class/cannyedgedetector().md)
- [comicEffect()](coreimage/cifilter-swift.class/comiceffect().md)
- [coreMLModel()](coreimage/cifilter-swift.class/coremlmodel().md)
- [crystallize()](coreimage/cifilter-swift.class/crystallize().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)
