问题
I'm looking for a way to apply a CIFilter to a portion of an image defined by a mask. Something like this, given an image:
Source http://imageshack.us/scaled/landing/213/browserpreviewtmp1p.jpg
And a mask:
I apply some variation of
CIFilter *filter = [CIFilter filterWithName:@"CIColorControls" keysAndValues: kCIInputImageKey, beginImage,@"inputSaturation", @0, @"inputContrast", @1, @"inputBrightness", @0, nil];
And get this:
Result http://imageshack.us/a/img689/5297/browserpreviewtmpd.jpg
How can I do this?
回答1:
You can use another couple CIFilters! You can take the top image and multiply it by the mask using CIMultiplyBlendMode, then add it to the bottom image using CIAdditionCompositing.
来源:https://stackoverflow.com/questions/13999751/applying-cifiler-to-a-masked-portion-of-an-image