Type Method

morphologyRectangleMaximum()

Blurs a rectangular area by enlarging contrasting pixels.

Declaration

class func morphologyRectangleMaximum() -> CIFilter & CIMorphologyRectangleMaximum

Return 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:

width

A float representing the width in pixels of the working area as an NSNumber.

height

A float representing the height in pixels of the working area as an NSNumber.

inputImage

A 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
    }
Two photographs of a beach at sunset with multiple palm trees. The photo on the left is clear and crisp. In the photo on the right, a morphology rectangle maximum blur has been applied, resulting in the palm trees becoming lighter and less distinct.

See Also

Filters

class func bokehBlur() -> CIFilter & CIBokehBlur

Applies a bokeh effect to an image.

class func boxBlur() -> CIFilter & CIBoxBlur

Applies a square-shaped blur to an area of an image.

class func discBlur() -> CIFilter & CIDiscBlur

Applies a circle-shaped blur to an area of an image.

class func gaussianBlur() -> CIFilter & CIGaussianBlur

Blurs an image with a Gaussian distribution pattern.

class func median() -> CIFilter & CIMedian

Calculates the median of an image to refine detail.

class func morphologyMaximum() -> CIFilter & CIMorphologyMaximum

Blurs a circular area by enlarging contrasting pixels.

class func morphologyMinimum() -> CIFilter & CIMorphologyMinimum

Blurs a circular area by reducing contrasting pixels.

class func morphologyRectangleMinimum() -> CIFilter & CIMorphologyRectangleMinimum

Blurs a rectangular area by reducing contrasting pixels.

class func noiseReduction() -> CIFilter & CINoiseReduction

Reduces noise by sharpening the edges of objects.

class func zoomBlur() -> CIFilter & CIZoomBlur

Creates a zoom blur centered around a single point on the image.