rowAverage()
Calculates the average color for the specified row of pixels in an image.
Declaration
class func rowAverage() -> any CIFilter & CIRowAverageReturn Value
Discussion
This method applies the row average filter to an image. This effect calculates the average color for a horizontal row over a region defined by extent. The height of the extent determines the width of the resulting image. The height is always 1 pixel.
The row 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 a filter that calculates the row average for the middle section of an image:
func rowAverage(inputImage: CIImage) -> CIImage {
let filter = CIFilter.rowAverage()
filter.inputImage = inputImage
filter.extent = CGRect(x: inputImage.extent.width/3, y: 0, width: inputImage.extent.width/3, height: inputImage.extent.height)
return filter.outputImage!
}[Image]