Page 1 of 1

2-3 zone tone correction

Posted: 2012-03-23T07:34:55-07:00
by markmarques
First, I do not know if this is the place for this topic but here it goes ...
using Imagemagick in windows tru CLI .

I am trying to make a script in order to correct some images based on this idea :
http://ftp2.bmtmicro.com/dlc/Multi-Zone_Adjustment.pdf
I have partially made ( rough approach ) the 2 zone adjustments but I hit the problem that the "-composite" operator "aparently" is not the last one ...

I have tried several aproaches but with no sucess mainly because have not figure out yet if it is possible to use the "-composite" as a partial parentisis .
Something like this using a batch script

Code: Select all

 
convert image1.png ( -clone 0 -gamma 0.4 ) ( -clone 0 -gamma 3 ) ( -clone -colorspace gray -blur 0x5 ) ( -delete 0 -combine minus -composite ) ( -clone 2 -gamma 05 ) ( -composite -gamma 2.2 PNG:x1.png) 
The previous code is not working due to the 1st "-composite" call ...
How can I avoid using a partial "image for each combine ? ...


Does some one else have a another idea how to aproach the initial 2-3 Zone paper ?
I think the idea is to enhance the image with the maximus dinamic range for each 3 zones...

Re: 2-3 zone tone correction

Posted: 2012-03-23T10:35:21-07:00
by fmw42
convert image1.png ( -clone 0 -gamma 0.4 ) ( -clone 0 -gamma 3 ) ( -clone -colorspace gray -blur 0x5 ) ( -delete 0 -combine minus -composite ) ( -clone 2 -gamma 05 ) ( -composite -gamma 2.2 PNG:x1.png)
There is no such thing as -combine minus. Do you mean -compose minus ... -composite. If so -composite only works on two images at a time. You might want to do them by pairs or use something like -flatten.

see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/

For your problem of adjusting the midtones, shadows and highlights, there are numerous ways to separate midtones, hightlights and shadows. You can try my bash unix scripts, balance, colorbalance, graytoning, duotonemap, duotonemap, tonemap1, tonemap2, tonemap3, tonemap4, see link below, if you are on Windows with Cygwin. Otherwise, you can look at the code (or explanation at the bottom of the examples pages) to see what I am doing and convert that to windows syntax. See http://www.imagemagick.org/Usage/windows/

The most used concept and similar to your paper is to create binary masks at threshold values that will separate midtones, shadows and hightlights. (By default, I used the mean +- standard deviation as the threshold points, but they can be manually overridden). Then blur the masks to create tapers that overlap. Then process the images once for each region with different brightness-contrast-saturation values. You can use -brightness-contrast and modulate 100,Sat,100 to adjust the saturation. Then use the masks to composite the regions together. In most of my scripts, I just -level (or +level) to adjust the brightness/contrast. But in my duotonemap, I used -gamma.

Alternately, you can convert from RGB to HSL (or HSB), then adjust the brightness and contrast of the L (or b) channel separate from the S channel for each separate region again using masks to combine and then convert back to RGB. Here again I just used -level.

My script, balance, I used a simpler concept (no masks) of just a two part linear transform. The endpoints of the lines are used to specify the values for the transforms of the shadows, midtones and hightlights.

I have used variations of these concepts in my scripts mentioned above.

Re: 2-3 zone tone correction

Posted: 2012-03-25T18:53:19-07:00
by anthony
fmw42 wrote:There is no such thing as -combine minus. Do you mean -compose minus ... -composite. If so -composite only works on two images at a time. You might want to do them by pairs or use something like -flatten.
In composition it is recommended you use either MinusSrc or MinusDst to exactly specify which image should be subtracted.

Note that in photoshop subtraction is done by using LinearBurn whcih will subtract what ever image you negated before applying the composition. This may be a useful alturnative.
IM Examples wrote:The Linear Burn Compose Method also allows you to do something very tricy. Say you have one image, and what to subtract many other images from it. By using 'Linear Burn', Negating all but the first image, and setting a 'white' starting background color, you can use Flatten or other multi-image layering operators, to do that subtraction. I did say it was tricky!

Re: 2-3 zone tone correction

Posted: 2012-03-25T18:56:14-07:00
by anthony
markmarques wrote:I am trying to make a script in order to correct some images based on this idea :
http://ftp2.bmtmicro.com/dlc/Multi-Zone_Adjustment.pdf
I have partially made ( rough approach ) the 2 zone adjustments but I hit the problem that the "-composite" operator "aparently" is not the last one ...
See IM examples... Color Modifications, Duo-Tone Effect
http://www.imagemagick.org/Usage/color_mods/#duotone

that can do both two and three tone coloring. Though it can not do fine control of the position of the midtone. Fred's Scripts can do that better, as it uses much more methematical methods to generate the Color LookUp Table (CLUT).

Re: 2-3 zone tone correction

Posted: 2012-03-26T04:33:27-07:00
by markmarques
Well thanks for the fast answer ...
I suppose my problem is that "-compose Minusdst -composite" works in pairs of images ...
Perhaps would be a good idea do implicitly write something about it in de "usage" docs ?

Changing subject : I will try the "-flatten" idea approach ...

thanks...

Re: 2-3 zone tone correction

Posted: 2012-03-26T10:52:42-07:00
by fmw42
markmarques wrote:Well thanks for the fast answer ...
I suppose my problem is that "-compose Minusdst -composite" works in pairs of images ...
Perhaps would be a good idea do implicitly write something about it in de "usage" docs ?
see the very first line at http://www.imagemagick.org/Usage/compose/#compose

Re: 2-3 zone tone correction

Posted: 2012-03-27T00:03:21-07:00
by anthony
markmarques wrote:Well thanks for the fast answer ...
I suppose my problem is that "-compose Minusdst -composite" works in pairs of images ...
Perhaps would be a good idea do implicitly write something about it in de "usage" docs ?

Changing subject : I will try the "-flatten" idea approach ...

thanks...

Code: Select all

   convert  images....  -negate \
                \( -clone 0 -negate \) -swap 0 +delete \
                -compose LinearBurn -background white -flatten \
                result.png
This does the following
  • read in images, and negate them all (assumes all opaque)
  • clone first image and negate it back, re-add to start of list
  • flatten using LinearBurn onto a white starting canvas
The first flatten compose is the first (non-negated) image on to white (negated black).
The result is 'zero' (negated white) subtracted from first image -> first image
Then each image following is subtracted (using negated linear burn) from that image.

The second and later images can be smaller images with virtual canvas offsets, if you want.

I have added this to Layers, Evaluate-Sequence, Subtract
Whcih is another method that does the same thing (but only with equal sized images)
Unfortunatally it is broken in that its argument order is incorrect!
It subtracts the current image from the next image!!! Arrrgghhh...