Contents

personSegmentation()

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

Declaration

class func personSegmentation() -> any CIFilter & CIPersonSegmentation

Return Value

A 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 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:

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

[Image]

See Also

Filters