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

# personSegmentation()

Creates a mask where red pixels indicate areas of the image that are likely to contain a person.

```
class func personSegmentation() -> any CIFilter & CIPersonSegmentation
```

## Return Value

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

## Discussion

The person-segmentation filter creates a mask that contains red pixels in the areas of the input image that are likely to contain people.

The person-segmentation filter takes the following properties:

- `inputIImage`: A [`CIImage`](/documentation/CoreImage/CIImage) containing the image to segment.
- `qualityLevel`: The size and quality of the resulting segmentation mask. 0 is accurate, `1` is balanced, and `2` is fast.

The following code applies the person-segmentation filter to an image:

```swift
func personSegmentation(inputImage: CIImage) -> CIImage {
    let personSegmentationFilter = CIFilter.personSegmentation()
    personSegmentationFilter.inputImage = inputImage
    personSegmentationFilter.qualityLevel = 0
    return personSegmentationFilter.outputImage!
}
```

![An illustration of two images, side-by-side. The original image, on the left, contains a single individual against a background of a field, trees, and buildings. The other image, on the right, shows the individual after segmentation. The background is all set to black and the pixels that make up the individual are all set to red.](images/com.apple.coreimage/media-4407311@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)