I have a pile of files say 1.jpg, 2.jpg, 3.jpg,... N.jpg, all same size, depth, etc. I need to merge them together by averaging them. They would all have equal weight in the final image. Obviously I could loop through the images and perform the math on corresponding pixels. ( I may have to do this anyway to later allow for various blending methods to be implemented. ) But I'm assuming there is a way to do this is a more concise way. Any suggestions?
Ultimately I'm interested in some sort of HDR stacking method to sets of bracketed exposures.
Thanks!
-- Bob
Magick++ to average several images
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Magick++ to average several images
convert 1.jpg 2.jpg 3.jpg ... N.jpg -average result.jpgBob-O-Rama wrote:I have a pile of files say 1.jpg, 2.jpg, 3.jpg,... N.jpg, all same size, depth, etc. I need to merge them together by averaging them. They would all have equal weight in the final image. Obviously I could loop through the images and perform the math on corresponding pixels. ( I may have to do this anyway to later allow for various blending methods to be implemented. ) But I'm assuming there is a way to do this is a more concise way. Any suggestions?
Ultimately I'm interested in some sort of HDR stacking method to sets of bracketed exposures.
Thanks!
-- Bob
(Too bad there are not equivalent multi-image operators such as -multiply, -minimum and -maximum that work on more than 2 or 3 images at a time).
I am not sure of your HDR and bracketing issues.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Magick++ to average several images
There is, it is called -flatten but you need to set -background color appropriately first!fmw42 wrote:(Too bad there are not equivalent multi-image operators such as -multiply, -minimum and -maximum that work on more than 2 or 3 images at a time).
EG: here are your -multiply, -minimum and -maximum equivelents...
Code: Select all
convert *.jpg -background white -compose multiply -flatten result.jpg
Code: Select all
convert *.jpg -background white -compose darken -flatten result.jpg
Code: Select all
convert *.jpg -background black -compose lighten -flatten result.jpg
I myself like to add up the channels of difference images
Code: Select all
convert image1 image2 -compose difference -composite \
-separate -background black -compose Plus -flatten \
difference.png
http://www.imagemagick.org/Usage/compare/#difference
as well as Channels and Masks, Removing a Known Background
http://www.imagemagick.org/Usage/channels/#mask_bgnd
Of course without HDRI being enabled to handle data overflow, there is no equivalent for -average, which is why it has its own separate operation.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Magick++ to average several images
anthony wrote:There is, it is called -flatten but you need to set -background color appropriately first!fmw42 wrote:(Too bad there are not equivalent multi-image operators such as -multiply, -minimum and -maximum that work on more than 2 or 3 images at a time).
EG: here are your -multiply, -minimum and -maximum equivelents...Code: Select all
convert *.jpg -background white -compose multiply -flatten result.jpg
Code: Select all
convert *.jpg -background white -compose darken -flatten result.jpg
Note the color of the background used to so that it does play a part in the results.Code: Select all
convert *.jpg -background black -compose lighten -flatten result.jpg
I myself like to add up the channels of difference imagesSee IM Examples, Comparing Images, Difference imagesCode: Select all
convert image1 image2 -compose difference -composite \ -separate -background black -compose Plus -flatten \ difference.png
http://www.imagemagick.org/Usage/compare/#difference
as well as Channels and Masks, Removing a Known Background
http://www.imagemagick.org/Usage/channels/#mask_bgnd
Of course without HDRI being enabled to handle data overflow, there is no equivalent for -average, which is why it has its own separate operation.
Thanks for the information. I did not know you could use -compose options with -flatten.