Do iOS Core Image Blend Modes differ from Photoshop Blend Modes?
Asked Answered
H

0

6

I am using CIFilter and the CIHueBlendMode in order to blend an image (foreground) and a red layer (background)

I am doing the exact same thing in Photoshop CS6 with the Hue Blend Mode (copied the foreground image and used the same red to fill the background layer)

Unfortunately the results are very different: enter image description here (and the same applies to comparing CIColorBlendMode, CIDifferenceBlendMode and CISaturationBlendMode with their Photoshop counterparts)

My question is: Is it me? Am I doing something wrong here? Or are Core Image Blend Modes and Photoshop Blend Modes altogether different things?

// Blending the input image with a red image  
CIFilter* composite = [CIFilter filterWithName:@"CIHueBlendMode"];
[composite setValue:inputImage forKey:@"inputImage"];
[composite setValue:redImage forKey:@"inputBackgroundImage"];

CIImage *outputImage = [composite outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
imageView.image = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);

// This is how I create the red image:       
- (CIImage *)imageWithColor:(UIColor *)color inRect:(CGRect)rect
{
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef _context = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColorWithColor(_context, [color CGColor]);
    CGContextFillRect(_context, rect); 
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return [[CIImage alloc] initWithCGImage:image.CGImage options:nil];
}
Heterogamete answered 9/3, 2013 at 10:13 Comment(4)
I can't give a comprehensive answer to this, but I think it has to do with Photoshop and Core Image using different color models. The Wikipedia article on blend modes notes: "Photoshop’s hue, saturation, color, and luminosity blend modes are based on a color space with dimensions that the article HSL and HSV calls hue, chroma, and luma. Note that this space is different from both HSL and HSV..." – while Core Image seems to use HSL.Membrane
That's an interesting thought and definitely a good starting point for further research on my behalf. Thanks!Heterogamete
If it is an issue of different color models, the PS model could be done in Core Image. You would just need custom filters to transform both ways.Manzo
Does the issue still exist till date?Ivied

© 2022 - 2024 — McMap. All rights reserved.