Manipulating multi-image MIFF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
algae
Posts: 2
Joined: 2018-03-29T15:33:33-07:00
Authentication code: 1152

Manipulating multi-image MIFF

Post 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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Manipulating multi-image MIFF

Post 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)
algae
Posts: 2
Joined: 2018-03-29T15:33:33-07:00
Authentication code: 1152

Re: Manipulating multi-image MIFF

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Manipulating multi-image MIFF

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply