<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIFilter-swift.class/depthToDisparity()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter(cm)depthToDisparityFilter"
  },
  "title" : "depthToDisparity()"
}
-->

# depthToDisparity()

Converts from an image containing depth data to an image containing disparity data.

```
class func depthToDisparity() -> any CIFilter & CIDepthToDisparity
```

## Return Value

An image containing the disparity data.

## Discussion

This method applies the depth-to-disparity filter. The filter takes depth data as an input and produces disparity data in the output image. You can use the output of this filter to create a stereo image.

The depth-to-disparity filter uses the following property:

- `inputImage`: An image with the type [`CIImage`](/documentation/CoreImage/CIImage).

The following code creates a filter that generates a depth map image:

```swift
func depthToDisparity(inputImage: CIImage) -> CIImage {
    let depthToDisparityFilter = CIFilter.depthToDisparity()
    depthToDisparityFilter.inputImage = inputImage
    return depthToDisparityFilter.outputImage!
}
```

![Two photographs of a small dog sitting on grass. The photo on the left shows the dog in the foreground with good light and a soft blur of the background. In the photo on the right, a depth-to-disparity filter is applied, resulting in a depth map created from the photo on the left. The dog in the photo and the ground are replaced with gray, and the background is replaced with white.](images/com.apple.coreimage/media-3598060@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)