flrs / blend_modes

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

Source image gets affected by multiply operation #12

Closed fabiofidanza closed 5 years ago

fabiofidanza commented 5 years ago

I'm iterating over a set of images to blend them over a base image. On the second iteration, the source image (which stays the same during the process) and the overlayed image (which gets reloaded at every iteration) becomes empty. Is this by design?

i=0
for variant in variants: 
    warpedImage = np.zeros(baseLayer.shape, dtype=baseLayer.dtype)
    warpedImage[:,:,:] = 255

    variantImage = cv2.cvtColor(cv2.imread(variant).astype(np.float32),cv2.COLOR_RGB2RGBA);
    variantImage[:,:,3] = 255;

    cv2.warpPerspective(variantImage, transformMatrix, baseLayer.shape[:2],dst=warpedImage,borderMode=cv2.BORDER_TRANSPARENT)

    dstImage = bm.multiply(baseLayer,warpedImage,1)

    cv2.imwrite('images/output'+str(i)+'.png',dstImage)

    i += 1
flrs commented 5 years ago

I will check it out.

On Fri, Jul 12, 2019, 3:17 AM fabiofidanza notifications@github.com wrote:

I'm iterating over a set of images to blend them over a base image. On the second iteration, the source image (which stays the same during the process) and the overlayed image (which gets reloaded at every iteration) becomes empty. Is this by design?

` i=0

for variant in variants:

warpedImage = np.zeros(baseLayer.shape, dtype=baseLayer.dtype) warpedImage[:,:,:] = 255

variantImage = cv2.cvtColor(cv2.imread(variant).astype(np.float32),cv2.COLOR_RGB2RGBA); variantImage[:,:,3] = 255;

cv2.warpPerspective(variantImage, transformMatrix, baseLayer.shape[:2],dst=warpedImage,borderMode=cv2.BORDER_TRANSPARENT)

dstImage = bm.multiply(baseLayer,warpedImage,1)

cv2.imwrite('images/output'+str(i)+'.png',dstImage)

i += 1

`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/flrs/blend_modes/issues/12?email_source=notifications&email_token=ACJGIGYKSW2OSR7HPQGVCOTP7A4ZXA5CNFSM4ICEO5A2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G62FMRA, or mute the thread https://github.com/notifications/unsubscribe-auth/ACJGIG3WDHCVSUL4SRYXVMDP7A4ZXANCNFSM4ICEO5AQ .

flrs commented 5 years ago

This is related to #7, specifically with the remark that the functions mutate their inputs. This issue is confirmed. It is a bug.

flrs commented 5 years ago

Bug is fixed in release v2.1.0.