morphologyRectangleMaximum()
Blurs a rectangular area by enlarging contrasting pixels.
Declaration
class func morphologyRectangleMaximum() -> any CIFilter & CIMorphologyRectangleMaximumReturn Value
The blurred image.
Discussion
This method applies the morphology rectangle maximum filter to an image. The effect targets a rectangular section of the image, calculating the median color values to find colors that make up more than half the working area. Using this calculation, the effect enlarges the pixels with contrasting colors to take up more of the working area. The effect is then repeated throughout the image.
The morphology rectangle maximum filter uses the following properties:
widthA
floatrepresenting the width in pixels of the working area as an NSNumber.heightA
floatrepresenting the height in pixels of the working area as an NSNumber.inputImageA CIImage representing the input image to apply the filter to.
The following code creates a filter that adds a blur to the input image while brighting the palm trees:
func morphologyRectangleMaximum(inputImage: CIImage) -> CIImage? {
let morphologyRectangleMaximumFilter = CIFilter.morphologyRectangleMaximum()
morphologyRectangleMaximumFilter.inputImage = inputImage
morphologyRectangleMaximumFilter.width = 5
morphologyRectangleMaximumFilter.height = 5
return morphologyRectangleMaximumFilter.outputImage
}[Image]