Page 1 of 1

Manipulating multi-image MIFF

Posted: 2018-03-29T16:00:26-07:00
by algae
Hello!

I'm trying to subtract a given image from each image in a multi-image MIFF file. I have a bunch of greyscale tiff files and I want to subtract the mean of all of them from each image. I tried this:

Code: Select all

magick *.tiff merged.miff
magick merged.miff -evaluate-sequence mean mean.miff
magick merged.miff -compose subtract mean.miff diff.miff
I was hoping to get a multi-image MIFF file named diff.miff that has the original images with the mean.miff subtracted from each image, but that's not what I get. I'm sure that there's some user error in here.

I'm using 7.0.7 Q16 HDRI here.

I'm actually trying to compute the temporal noise of the original tiff images. The usual way is to compute the stddev of each pixel location across all the images, then get the mean of the stddev values. Fred's stdimage script doesn't seem to quite do it for me.

If anyone can nudge me in the right direction, that would be great.

Thanks!

Re: Manipulating multi-image MIFF

Posted: 2018-03-29T17:08:07-07:00
by fmw42
Replace your last command with

Code: Select all

magick merged.miff null: mean.miff -compose minus -layers composite diff.miff
Note that compose minus will clip at 0 and 255 (or 65535 depending upon Level).

compose subtract will wrap around.

compose difference will make negative into positive (like an abs)

If you want compose minus to keep negatives, then add -define quantum:format=floating-point before the output.

You can do the same with tiff format if you want to see each result (tiff also needs the define)

Re: Manipulating multi-image MIFF

Posted: 2018-03-29T17:39:09-07:00
by algae
Ahh.. thanks for the quick response. I never would've been able to figure out that sequence.

How does one understand the semantics of all the operations? The manuals are a bit too terse for me to figure it out. For example, how would I have been able to deduce the need for the null: there? Is that really from the -layers op? If so, then the key was to recognize that I was missing the -layers op somehow...

Thanks!

Re: Manipulating multi-image MIFF

Posted: 2018-03-29T19:10:18-07:00
by snibgo
IM options include operators that modify images, and settings that don't directly modify images, but modify the behaviour of operators. See http://www.imagemagick.org/script/comma ... essing.php

"-compose" is a setting, not an operator. It needs an operator to actually do the work, and this is either "-composite" when you have just two inputs, or one of the "-layers" operators. When you have a list of images and you want to apply (eg subtract) the same image to each of them, the appropriate operator is "-layers composite".

See also http://www.imagemagick.org/script/comma ... php#layers etc.