Glenn Linderman on  wrote...
| Hi Walter, and all,
| 
| I guess for my first (accidentally private) reply to Walter, I had a 
| version of ImageMagick that didn't work for -fx. I just upgraded to 
| 6.2.9, and experiments with -fx started becoming more realistic. But 
| there are still things I don't understand.
| 
| On approximately 8/16/2006 9:03 PM, came the following characters from 
| the keyboard of Walter Dnes:
| > On Wed, Aug 16, 2006 at 11:36:54AM -0700, Glenn Linderman wrote
| >
| >   
| >> Experimentally, I have found that duplicating a picture to two
| >> identical layers, choosing layer mode "screen", and varying selections
| >> for opacity depending on how dark a picture is, can nicely brighten
| >> a picture without that "washed out" look that comes from simply
| >> choosing the "brighten" operation.
| >>
| >> Does anyone have a clue how to produce that same effect in ImageMagick?
| >>     
| >
| >   I've got a couple of "convert" formulas that preferentially brighten
| > darker pixels.  Note that they analyze individual pixels, and a
| > 2560x1920 image takes 30 seconds on an AMD64 3000+ with 2 gigs of ram.
| >
| >   The best effect is from logarithmic brightness boost.  I call the
| > script "logg".  It looks like so...
| >
| > #!/bin/bash
| > convert ${1} -fx "ln(u*(${3}-1)+1)/ln(${3})" ${2}
| >
| >   It's invoked like...
| >
| > logg input_image output_image 3
| >
| > The 3rd parameter is a positive number (float) that must be greater than
| > 1.  The larger the 3rd parameter, the more brightening you get.
| >   
| Indeed, this does work nicely for reasonable values of the 3rd 
| parameter. You can achieve the "washed out" look as the 3rd parameter 
| gets up high. But it is less pronounced than standard brightness, and 
| produced better results for my picture.
| 
| However, I don't understand the math behind this one, how did you come 
| up with that formula, and how do you know the resulting numbers stay in 
| range?
| 
The bulk of the formula (like that for sigmoidal contrast) is basically
to set the threshold level where the maximum change is to happen
(threshold point), and scale/translate the graph so that black
remains black and white remains white.

Graph it, and the simpler one without scaling and translation formula

    ln(u*(${3}-1)


| I am also rather amazed at the significant effect the +1 has to the 
| overall result. It would seem that for pixel values ranging up to 65535, 
| multiplied by a positive number, that adding 1 wouldn't have a 
| significant impact. But I can see the difference if I omit it!
| >   Another script is "pwrr".  It uses a power curve for a similar
| > brightening effect.
| >
| > #!/bin/bash
| > convert ${1} -fx u^${3} ${2}
| >
| >   It's invoked like...
| >
| > pwrr input_image output_image 0.75
| >
| > The 3rd parameter is a positive number (float) less than 1.  The lower
| > the 3rd parameter, the more brightening you get.
| >   
| OK, this one also works better than it was: with the 6.0.8 version of 
| IM, it produced only a white or black image. Now it does do a reasonable 
| brightening job ... quite nice on my old slide, actually.
| 
| I don't understand the math here, either. My first pixel has a red 
| component of 38550 (when converted to Q16), but when I do the u^.5 
| operation, it becomes 50263. That is NOT the square root of 38550. What 
| exactly is -fx doing under the covers that I don't understand?
| 
-fx uses a color of the range  0.0 to 1.0  it does this to make the math
a lot easier for DIY handling.  Most color math uses this range, rather
than the Quality Dependany integer value.


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
    "Mr. Worf, scan that ship."     "Aye, Captain... 300 DPI?"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to