Page 1 of 1
Magick++ to average several images
Posted: 2008-11-03T14:34:01-07:00
by Bob-O-Rama
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
Re: Magick++ to average several images
Posted: 2008-11-03T15:20:57-07:00
by fmw42
Bob-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
convert 1.jpg 2.jpg 3.jpg ... N.jpg -average result.jpg
(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.
Re: Magick++ to average several images
Posted: 2008-11-03T17:47:44-07:00
by anthony
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).
There is, it is called
-flatten but you need to set
-background color appropriately first!
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
Note the color of the background used to so that it does play a part in the results.
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
See IM Examples, Comparing Images, Difference images
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.
Re: Magick++ to average several images
Posted: 2008-11-03T18:16:48-07:00
by fmw42
anthony wrote: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).
There is, it is called
-flatten but you need to set
-background color appropriately first!
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
Note the color of the background used to so that it does play a part in the results.
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
See IM Examples, Comparing Images, Difference images
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.