gemutlich wrote:anthony wrote:rather than multiply, you can also square, or even square root an image using -gamma, -pow, and the new operator -function polynomial (for square only)
...
But then if you only do it once, I suppose it does not matter how you do it.
Maybe I should be a bit more specific about what I want to do. In fact, I will need to do this more than once and so a script is what I will eventually have to write.
What I want to do is characterize a camera in terms of its thermal behaviour. The dark current depends on the temperature of the sensor. It doubles each time the temperature rises by the sensor specific doubling temperature.
It is possible to take a dark field image by leaving the lens cap on and to subtract this image from all images taken at the same exposure settings and the same temperature. Unfortunately, the dark current is also noisy. Thus, the dark field image contains a predictable part and an unpredictable part (noise). This noise is what I am after.
For this reason I am taking a sequence of dark images and average them to compute the predictable part of the dark current.
Now the question: If I use -gamma, -pow or -function how are they handled internally? Are they stored as float or as 16-bit values? Can it handle negative pixel values?
How would I get the variance over an entire image? Is there a way to sum or average all pixel values and spit out this number? It seems that -fx in combination with -formt can do something like this but I am a bit confused how exactly to compute and print out this value.
What I was thinking is to first compute the average over all images. Then subtract this average image from each image (needs to handle negative pixel values) and compute the variance of each image. Since all images are the same size I can then simply compute the average over the variances.
Thanks in advance!
Marcus
I believe that IM can handle negatives internally to any program, but cannot store them in an image unless you use HDRI configuration of IM and an appropriate file format such as MIFF, PFM, possibly TIFF. Normal IM configurations such as Q8, Q16 (default) and Q32 without HDRI will clip values at 0 and quantumrange (255, 65535, etc). Perhaps Anthony or Magick can clarify/correct this with more detail.
see
http://www.imagemagick.org/script/high- ... -range.php
http://www.imagemagick.org/Usage/basics/#hdri
Perhaps you can bias your difference relative to mid-range for storage. The later subtract the bias. Then you won't need HDRI.
The variance is just the square of the standard deviation. So once you get the std, you can square manually or using fx as in:
convert xc: -format "%[fx: $std*$std]" info:
where $std is the standard deviation stored in a variable.
To compute the std over any one image is simple:
convert image -format "%[standard-deviation]" info:
This will print to the terminal and computes the std over all channels combined and returns the value in the range 0 to quantumrange (Q8->255, Q16->65535)
If you need to compute the std per channel, you can either separate channels or use -fx
convert image -channel r -separate -format "%[standard-deviation]" info:
returns red channel std in the range 0 to quantumrange
or
convert image -format "%[fx:standard_deviation.r]" info:
returns red channel std in range 0 to 1
If you want to send the result to a variable:
std=`convert image -format "%[standard-deviation]" info: 2>&1`
echo $std
or to a file
convert image -format "%[standard-deviation]" info: 2>&1 stdfile.txt
This is all for unix. If you are on windows, some changes are needed. See
http://www.imagemagick.org/Usage/api/#windows
P.S. For any two images you can use the compare function with -metric to get various statistics. see
http://www.imagemagick.org/Usage/compare/#statistics
compare -metric XYZ image1 image2 null:
where XYZ is any one of a number of metrics, such as rmse (root mean squared error), psnr (peak signal to noise ratio), etc. You might be able to use this between your image and your averageimage and get a meaningful statistic for your analysis rather than the variance. I would suggest that rmse is probably closest to a std.