Entries tagged as bugSunday, May 2. 2010Averaging an image sequence with ImageMagick![]() Besides the fact that it was a pain to find out how ImageMagick’s -average option is to be used, it turned out to operate wrongly. The switch calculates the mean of an image sequence, i.e. the mean color values for every pixel. Say, if you have a bunch of images with file names like img*.jpg and want the average saved into avg.jpg, the command line is: $ convert img*jpg -average avg.jpg Pretty intuitive. The problem is that you define the mean image Ī[n] of n images I[k] as while ImageMagick does it recursively as
giving you wrong weights 1⁄2n−k+1 like e.g. for n=8 instead of the intended weights 1⁄n like
This misbehaviour can be proven e.g. by taking this sequence of a plain blue, green and red image: and averaging it with the above command. The result is too reddish:
The solution I found was to call convert recursively like this: #!/bin/bash i=0 for file in img*jpg; do echo -n "$file.. " if [ $i -eq 0 ]; then cp $file avg.jpg else convert $file avg.jpg -fx "(u+$i*v)/$[$i+1]" avg.jpg fi i=$[$i+1] done By this, the average of the above example images correctly becomes gray: There might be similar problems with the other image sequence operators, but I haven’t examined them. Maybe I should file a bug. Thursday, February 25. 2010Work around the image scaling "bug"![]() ![]() Eric Brasseur explained a “bug” in the scaling algorithm of current image processing software. It’s not really a bug, technically, or mathematically. Calculating the numerical average of the surroundings of a pixel as the new color value is a pretty correct approach to scale an image down—if it’s seen as a data matrix. Rather, it’s visually not the thing you’d expect. Technically speaking, the problem is that “the computations are performed as if the scale of brightnesses was linear while in fact it is an exponential scale.” In mathematical terms: “a gamma of 1.0 is assumed while it is 2.2.” Here’s an example of what might occur: The wrong way:
Obviously, this might not be what you intended. The right way: Continue reading "Work around the image scaling "bug""
Posted by Stephan Paukner
in Information Technology, Photography
at
19:45
| Comments (0)
| Trackbacks (0)
(Page 1 of 1, totaling 2 entries)
|
AboutCalendar
ArchivesCategoriesShow tagged entriesandroid antenna anti-spam apache astronomy austria automobile bash bluetooth bug career cloud collecting comic cooking cw debian diy dreams education electronics fail fashion finance flickr fun gentoo geography german gnu-linux gnucash google google earth graphics guitar hardware history image processing internet kernel kids language lifestyle linkroll literature ltd machine learning making mallorca mathematics matlab microsoft migration movies munich music nautilus numismatics octave pdf perl philately philosophy phone photo gear photography physics podcast politics postfix private programming public transport rant religion review salzburg samsung science security shtf social web software statistics storage sustainability symbian tablet time lapse transceiver tv usenet venice video virtualization wordplay work www yahoo youtube
Syndicate This BlogFollow meBookmarks
Powered by |