I am trying to replace the black/dark gray with a pure black image in this image using GPUImageChromaKeyBlendFilter but it seems to be replacing the whites too:
Here's my code:
stillImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"head.jpg"]];
blackImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"black.jpg"]];
filter = [[GPUImageChromaKeyBlendFilter alloc] init];
[(GPUImageChromaKeyBlendFilter *)filter setColorToReplaceRed:0.27 green:1.0 blue:1.0];
[(GPUImageChromaKeyBlendFilter *)filter setThresholdSensitivity:self.myslider.value];
[stillImageSource addTarget:filter];
[blackImageSource addTarget:filter];
[filter addTarget:self.mygpuimageview];
[stillImageSource processImage];
[blackImageSource processImage];
How can I make this work?
I notice in this post, Brad mentions the issue is due to removing luminance:
https://github.com/BradLarson/GPUImage/issues/2256
"This has to do with the color-matching calculation within the chroma keying filter. It attempts to remove the luminance component and only match on chrominance, so for white or black colors it has a hard time matching the target color due to the lack of chrominance. You could try digging into the chroma keying shader and seeing you you could improve the color matching algorithm in there."
Is there a way to keep luminance in account too when keying? I am very new to GPUImage and image manipulation in general so I have no idea how to even modify the code for luminance.