areaMaximumAlpha()
Finds the pixel with the highest alpha value.
Declaration
class func areaMaximumAlpha() -> any CIFilter & CIAreaMaximumAlphaReturn Value
A 1 x 1 size image containing the pixel with the maximum alpha value.
Discussion
This filter returns the pixel with highest alpha value in the region defined by extent.
The area maximum alpha filter uses the following properties:
inputImageAn image with the type CIImage.
extentA CGRect that specifies the subregion of the image that you want to process.
The following code creates a filter that results in a single pixel image containing the pixel with the highest alpha value:
func areaMaximumAlpha(inputImage: CIImage) -> CIImage {
let filter = CIFilter.areaMaximumAlpha()
filter.inputImage = inputImage
filter.extent = CGRect(
x: inputImage.extent.width/2-250,
y: inputImage.extent.height/2-250,
width: 500,
height: 500)
return filter.outputImage!
}[Image]