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

# sobelGradients()

Calculates the Sobel gradients for an image.

```
class func sobelGradients() -> any CIFilter & CISobelGradients
```

## Return Value

A [`CIImage`](/documentation/CoreImage/CIImage) containing the Sobel gradients.

## Discussion

This filter applies the Sobel operator to the color components of the input image. You would typically use the Sobel filter as part of an edge-detection algorithm for performing.

- `inputImage`: A [`CIImage`](/documentation/CoreImage/CIImage) containing the image to process.

The following code applies the [`sobelGradients()`](/documentation/CoreImage/CIFilter-swift.class/sobelGradients()) filter to an image.

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

![Two images arranged horizontally. The left image is a photograph of modern building with horizontal concrete beams and large tinted windows. The image on the right shows the result of applying the Sobel gradients filter. Edges in the image are highlighted and flat areas of the image are set to black.](images/com.apple.coreimage/media-4407283@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)