3
\$\begingroup\$

I have a number of photos. I want to add these images togther pixel-wise (not mean or median). I have Imagemagick installed, and I tried:

composite -compose plus IMG* ~/Desktop/sum.png

But the output image

enter image description here

wasn't noticeably brighter than the input images:

enter image description here

Since I have 30 input images, I expected the output to be much brighter.

Why isn't this working, and how do I sum images, using either Imagemagick, or other free tool?

\$\endgroup\$
2
  • \$\begingroup\$ As @asalamon74 has pointed out, imagemagick will only merge two images in the way you've described. If you want to merge more, you can write a relatively simple bash script to take in a directory and merge all images through a series of merges. i.e. ((im1 + im2) + im3) + im4 ... \$\endgroup\$
    – Myridium
    Commented Feb 16, 2017 at 2:32
  • 1
    \$\begingroup\$ It's not clear to me what you're trying to achieve, but the free app Star Stax looks like it might do some of what you want. \$\endgroup\$ Commented Feb 16, 2017 at 3:50

4 Answers 4

8
\$\begingroup\$

Imagemagick cannot be used to compose 30 images in one step. The documentation states:

Image Composition is the process of merging two (and only two) images in a variety of ways.

The following simple bash script creates a black 100x100 image (temp.png) and compose all the test_*.jpg images (assuming all of them are 100x100) one by one to this image.

convert -size 100x100 canvas:black temp.png
for f in test_*.jpg; do
  composite temp.png "${f}" -compose Plus temp.png
done
\$\endgroup\$
8
  • \$\begingroup\$ Is it possible to merge 32 images in 31 steps? \$\endgroup\$
    – Crowley
    Commented Feb 15, 2017 at 16:23
  • \$\begingroup\$ yes, you can compose 32 images in 31 steps \$\endgroup\$
    – asalamon74
    Commented Feb 15, 2017 at 19:19
  • 1
    \$\begingroup\$ Added an example \$\endgroup\$
    – asalamon74
    Commented Feb 16, 2017 at 12:18
  • 1
    \$\begingroup\$ Wouldn't it be better to merge images like in tournament tree? Number of opertaions will be the same but all the images will be used equally. \$\endgroup\$
    – Crowley
    Commented Feb 16, 2017 at 12:30
  • 1
    \$\begingroup\$ I've modified the code to use png temp image \$\endgroup\$
    – asalamon74
    Commented Feb 18, 2017 at 7:33
3
\$\begingroup\$

You can use GIMP.

  1. Open the 1st image.

  2. Open the 2nd image as a layer (Ctrl + Alt + O).

  3. Change layer mode to "Addition" (Dialogue - Layers - Mode).

  4. Open next image as a layer.

  5. Change layer mode to "Addition".

  6. Proceed until all images are added.

You can add all images at once (selecting them with Ctrl while opening as a layer) but you'll still have to change layer mode individually for every layer.

This procedure is also possible with any graphic editor which is capable to work with layers (Paint.net, Photoshop (not free!) etc).

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Is it not possible to first import all images as layers, and then select all of them at once, right click and choose to change their mode to "Addition"? I'm not familiar with GIMP. This just doesn't seem practical for 30 images. \$\endgroup\$
    – Myridium
    Commented Feb 16, 2017 at 13:13
  • 1
    \$\begingroup\$ No, it's not possible to select multiple layers in GIMP. \$\endgroup\$
    – Zenit
    Commented Feb 16, 2017 at 13:16
3
\$\begingroup\$

After attempting to apply the repeated composite technique with HDR images and ending up with clamped output, I discovered the -evaluate-sequence operator. Here's an example:

convert *.exr -evaluate-sequence Add output.exr

This takes all the .exr files (or whatever format you want) in the current directory and sums them into a new image, output.exr.

If that doesn't give proper HDR output you may need to ensure you have a version of image magick built with HDR enabled.

\$\endgroup\$
0
\$\begingroup\$

Thanks to asalamon74 for a solution using a bash script, which I modified to use PNG rather than JPEG, as szulat suggested.

convert -size 100x100 canvas:black temp.png

for f in IMG_*.jpg; do
  composite temp.png ${f} -compose Plus temp.png
done

I tested, and this works.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.