Hello, I transferred Fred Weinhaus' autolevel script to Windows (i.e. VBS), because I often have to lighten bunches of under-exposed nighttime police photographs, see:
http://www.unfallrekonstruktion.de/ImageMagick/original.jpg http://www.unfallrekonstruktion.de/ImageMagick/corrected.jpg The VBS code, when translated to a DOS batch file, basically reads as follows: convert original.jpg -channel R -separate r.gif convert original.jpg -channel G -separate g.gif convert original.jpg -channel B -separate b.gif convert r.gif -contrast-stretch 0%,1% rc.gif convert g.gif -contrast-stretch 0%,1% gc.gif convert b.gif -contrast-stretch 0%,1% bc.gif convert rc.gif -gamma 3.56 rcg.gif convert gc.gif -gamma 4.23 gcg.gif convert bc.gif -gamma 2.84 bcg.gif convert rcg.gif gcg.gif bcg.gif -channel RGB -combine corrected.jpg ........ Fred's basic idea is to split the three channels R,G,B, adjust each of them separately and combine them again to a color photograph. As the above example shows, this works just fine. (Anthony: you may use the above photographs as an example, as the licence plates cannot be seen.) The gamm-values mentioned above are just abitrary examples. In the skript, I calculate them according to Fred's formula: gamma = ln(mean_value)/ln(0.5) This garantuees that in the corrected picture, the mean value is about half of the maximum pixel value (i.e. quantum range). A few remarks however: 1) It is not really clear to me what the difference between "-contrast-stretch" and "-linear-stretch" exactly is. 2) @ Fred: The mean value which is needed for the gamma formula can be computed without using the "quantumrange" value, just by identify photo.jpg -format "%[fx:mean]" 3) @ Fred: I think that "-contrast-stretch" does a better job on this as your computing of the "-level" values in your script. As far as I understood, "-contrast-stretch" actually lets you specify what percentage of the pixels will turn to pure black and pure white. (Correct ?) 4) The gamma adjustment according to the above formula could be easily implemented in IM itself, for instance if the user supplies a gamma value of zero, or by some "auto-correct" or "middle" option. Or is there any chance that I can get the result of the "identify" statement into just one "convert" command, so that I could do the above transformation in a simple batch file, instead of having to deal with a tedious VBS? Greetings from Münster Wolfgang Hugemann P.S.: I'll come back on that lens distortion issue in short term... _______________________________________________ Magick-users mailing list [email protected] http://studio.imagemagick.org/mailman/listinfo/magick-users
