GPUImage2 icon indicating copy to clipboard operation
GPUImage2 copied to clipboard

Strange artefacts/shadows when using normal blend of two images

Open jwoodrow opened this issue 5 years ago • 2 comments

When capturing still images (to create a gif) from the camera on which I apply a normal blend of the following image for example (transparent background):

Filter

I sendup with some kind of shadow or artefacting on the final image:

Resulting GIF

I managed to reduce it slightly by making the filter image larger (it's originally 480x640 but the artefacting happens less when using 960x1280):

Slightly better GIF

I can't seem to not get any of the grey borders (or shadows or artefacts or whatever it's called).

using PictureInput(image: filter, smoothlyScaleOutput: true, orientation: ImageOrientation.portrait) does not help and I'd even go as far as to say it makes things worse.

My blend workflow is this way: Camera -> xFlip (mirror effect) -> normalBlend (filter) -> pictureOutput (changing encodedImageFormat from jpg to png does not affect this)

any clues on where to look ?

jwoodrow avatar Feb 12 '19 14:02 jwoodrow

@jwoodrow the issue might be in the (#CliniqueiD) asset itself, try export a cleaner version of it (without shadows/antialiasing) ;)

zubco avatar Feb 12 '19 14:02 zubco

I think what you're seeing is the result of the way that premultiplied alpha is handled with images in the framework. This is something that was the subject of quite a bit of debate in the original GPUImage:

https://github.com/BradLarson/GPUImage/issues/2535 https://github.com/BradLarson/GPUImage/issues/1210#issuecomment-25182881

and honestly I'm not sure where we ended up on how to handle that. It either needs to be fixed in the input so that we don't use premultiplied alpha when loading images or in each shader that works with blended content. The former would be preferred, but I can't recall why I haven't implemented that yet.

BradLarson avatar Feb 13 '19 16:02 BradLarson