flrs / blend_modes

Python package that implements image blend modes
MIT License
140 stars 29 forks source link

Implement Adobe-Style Overlay #8

Closed flrs closed 5 years ago

flrs commented 5 years ago

I took a look at Wikipedia's implementation of Overlay and used your code as a basis to implement it. For example, given your code, in the overlay function definition, if I replace: comp = img_in[:,:,:3] * (img_in[:,:,:3] + (2 * img_layer[:,:,:3]) * (1 - img_in[:,:,:3]))

with (using the Wikipedia formula):

a = img_in[:,:,:3]
b = img_layer[:,:,:3]
comp = np.less(a, 0.5)*(2*a*b) + np.greater_equal(a, 0.5)*(1 - (2*(1 - a)*(1 - b)))

Then the overlay blending mode gives a result that is indeed different from Soft Light and looks just like the results that After Effects gives me. For my purposes, this is the version of Overlay that I prefer, even if it's not what GIMP uses.

_Originally posted by @JohnTravolski in https://github.com/flrs/blend_modes/issues/6#issuecomment-451335343_

flrs commented 5 years ago

@JohnTravolski came up with the code above. Now, the next step is to implement and test it.

flrs commented 5 years ago

@JohnTravolski, I am working on implementing your code right now. Can you provide a 640px square PNG test image for your overlay function? Unfortunately I do not have the required licenses for the Adobe products. The way to do produce the test image is to use a 50% overlay blend of layer.png onto orig.png and then export it as a PNG.

flrs commented 5 years ago

@JohnTravolski, I am working on implementing your code right now. Can you provide a 640px square PNG test image for your overlay function? Unfortunately I do not have the required licenses for the Adobe products. The way to do produce the test image is to use a 50% overlay blend of layer.png onto orig.png and then export it as a PNG.

I have resolved this and added the picture for testing.

Also, version 2.0.1 was just released and it implements the Adobe-style overlay.