<!--
{
  "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/paletteCentroid()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter(cm)paletteCentroidFilter"
  },
  "title" : "paletteCentroid()"
}
-->

# paletteCentroid()

Calculates the location of an image’s colors.

```
class func paletteCentroid() -> any CIFilter & CIPaletteCentroid
```

## Return Value

The modified image.

## Discussion

This method applies the palette centroid filter to an image. The filter locates colors in the input image that the palette image defines and `outputImage.extent` provides the location of the colors of the image. You can combine with other filters to create more sophisticated images.

The palette centroid filter uses the following properties:

- `inputImage`: An image with the type [`CIImage`](/documentation/CoreImage/CIImage).
- `paletteImage`: An image that has the dimensions of *N* x 1 where *N* represents the amount of colors in the image, with type [`CIImage`](/documentation/CoreImage/CIImage).
- `perceptual`: A Boolean value that specifies if the filter applies the color palette in a perceptual color space.

The following code creates a filter that calculates the extent of the palette color:

```swift
func paletteCentroid(inputImage: CIImage, paletteImage: CIImage) -> CIImage {
    let paletteCentroidFilter = CIFilter.paletteCentroid()
    paletteCentroidFilter.inputImage = inputImage
    paletteCentroidFilter.paletteImage = paletteImage
    paletteCentroidFilter.perceptual = false
    return paletteCentroidFilter.outputImage!
}
```

---

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)