blendWithMask()
Blends two images by using a mask image.
Declaration
class func blendWithMask() -> any CIFilter & CIBlendWithMaskReturn Value
The modified image.
Discussion
This method applies the blend with mask filter to an image. The effect uses values from the green mask image to interpolate between the input and background images. The mask image consists of shades of green that define the strength of the interpolation from zero (where the mask image is black) to the specified radius (where the mask image is green).
The blend with mask filter uses the following properties:
inputImageAn image with the type CIImage.
maskImageAn image that masks an area on the background image with the type CIImage.
backgroundImageAn image with the type CIImage.
The following code creates a filter that results in the replacement of green in the mask image with the detail of the input image:
func blendWithMask(inputImage: CIImage, backgroundImage: CIImage, maskImage: CIImage) -> CIImage {
let blendWithMaskFilter = CIFilter.blendWithMask()
blendWithMaskFilter.backgroundImage = backgroundImage
blendWithMaskFilter.inputImage = inputImage
blendWithMaskFilter.maskImage = maskImage
return blendWithMaskFilter.outputImage!
}[Image]