columnAverage()
Calculates the average color for a specified column of an image.
Declaration
class func columnAverage() -> any CIFilter & CIColumnAverageReturn Value
The generated image.
Discussion
This method applies the column average filter to an image. This effect calculates the average color for a vertical column over a region defined by extent. The width of the resulting image is set by the width of the extent. The height of the resulting image is always 1 pixel.
The column average 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 an image containing the average values in the columns from the middle of the image:
func columnAverage(inputImage: CIImage) -> CIImage {
let filter = CIFilter.columnAverage()
filter.inputImage = inputImage
filter.extent = CGRect(x: 0, y: inputImage.extent.height/3, width: inputImage.extent.width, height: inputImage.extent.height/3)
return filter.outputImage!
}[Image]