flrs / blend_modes

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

Wrong transparency results in some specific cases #22

Open nico00 opened 3 years ago

nico00 commented 3 years ago

In some specific cases I got unexpected behaviours with transparency. To replicate the problem you can use the attached images (please note that images are 10x10 to better debug the code): bgr fgr

and the following code:

import blend_modes
fgr = cv2.imread("fgr.png", cv2.IMREAD_UNCHANGED)
bgr = cv2.imread("bgr.png", cv2.IMREAD_UNCHANGED)
res = blend_modes.multiply(bgr.astype(float), fgr.astype(float), opacity=1.).astype("uint8")
cv2.imwrite("res.png", res)

You will see that expected result (attached), that has been built with PS, is slightly different than the code result.

code_result expected_result

This problem is happening not only with multiply but also with other modes (normal works properly).

j05u3 commented 3 years ago

Is it maybe related to this?