BradLarson / GPUImage2

GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
BSD 3-Clause "New" or "Revised" License
4.85k stars 605 forks source link

False colors after image is filtered with filterWithPipeline #283

Open domivarga opened 5 years ago

domivarga commented 5 years ago

I'm having an issue with image filtering. I want to create a pipeline with 3 filter but after the image is processed, the colors of the image is more pale than it should be. My function applies 3 adjustment to the image but if I set their values to the default ones (as the user did not set any changes for the image), the image is not look like the raw image, it looks pale. This makes the whole picture look wrong. I want to apply brightness, contrast and saturation adjustment to the picture with filterWithPipeline, as the following code snippet shows:

    class func createImageForPostcard(image: UIImage, intensities: Intensities) -> UIImage {
        let brightnessEffect = BrightnessAdjustment()
        let contrastEffect = ContrastAdjustment()
        let saturationEffect = SaturationAdjustment()

        brightnessEffect.brightness = intensities.brightness
        contrastEffect.contrast = intensities.contrast
        saturationEffect.saturation = intensities.saturation

        let filteredImage = image.filterWithPipeline { input, output in
            input --> brightnessEffect --> contrastEffect --> saturationEffect --> output
        }

        return filteredImage
    }

This is the raw image: firstimg

After applying the function with the default intensity values, it looks like this: secondimg

I do not understand why the color is modified because I set every intensity to the default value.

I would be really grateful if someone could tell me what should I do differently because I can't find any solution to get the well-filtered image.

domivarga commented 5 years ago

I have created a project where the issue can be tested:

https://github.com/domivarga/test-filter