thisischris
thisischris

Reputation: 41

Python Image Library Additive Blending

How can I additively blend two images?

I am trying to create random polygons and I'd like to layer them up.

I have tried Image.Blend and Image.paste however they just 'replace' the pixel values.

I would like to intensify images if that makes sense. So two images that are half transparent, will layer down to a fully opaque image.

Any ideas?

Upvotes: 4

Views: 1297

Answers (1)

Jan Pöschko
Jan Pöschko

Reputation: 5580

This could be achieved with the ImageChops module: If you want the "average" of two images (channel-wise), simply use

ImageChops.add(image1, image2, 2)

(The last parameter causes the "sum" of the images to be divided by 2.) Depending on what exactly you want, ImageChops.multiply might also be useful.

Upvotes: 1

Related Questions