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 & CIPersonSegmentationReturn 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:
inputIImageA CIImage containing the image to segment.
qualityLevelThe size and quality of the resulting segmentation mask. 0 is accurate,
1is balanced, and2is 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]