user1872384
user1872384

Reputation: 7147

How to use kCIInputBoostShadowAmountKey?

I would like to boost the shadows in an UIImage, akin to the one in Mac OS:

enter image description here

Is kCIInputBoostShadowAmountKey the correct key to use?

If yes, how to use it?

I'm able to use CIFilter with CIColorControls to edit the saturation and brightness:

CIContext *context3 = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CIColorControls"];
[filter setValue:outputImage forKey:kCIInputImageKey];
[filter setValue:@0.3f forKey:kCIInputSaturationKey];
//[filter setValue:@1.0f forKey:kCIInputBoostShadowAmountKey]; this is not working.. since it's not in CIColorControls...
CIImage *outputImage3 = [filter valueForKey:kCIOutputImageKey];
_outputImage.image = [UIImage imageWithCGImage:[context3 createCGImage:outputImage3 fromRect:outputImage3.extent]];

Update:

Got it it's CIHighlightShadowAdjust. But which parameter to set?

CIImage *inputImage;
NSNumber *inputRadius;
NSNumber *inputShadowAmount; // this one?
NSNumber *inputHighlightAmount;
NSNumber *_inputRadius;

Upvotes: 3

Views: 600

Answers (1)

samwize
samwize

Reputation: 27373

I was searching for the key too. Somehow there isn't, but you can use the string "inputHighlightAmount" directly.

let parameters = [
        kCIInputImageKey: self,
        "inputHighlightAmount": highlight,
        "inputShadowAmount": shadow,
        ] as [String : Any]
let filter = CIFilter(name: "CIHighlightShadowAdjust", parameters: parameters)

Upvotes: 2

Related Questions