Page 1 of 1

problem with CDL: inverting and zero saturation

Posted: 2011-05-26T20:04:47-07:00
by aberkl
Hi all,

I am trying to use ASC CDL to
a) invert an image (negative)
b) removing all color (b&w negative)
c) I have to use CDL although I know there are other ways ;-)

this is my main code:

Code: Select all

convert -cdl cdl_Invert.txt rose: rose_invert.jpg
and here is cdl_Invert.txt:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ColorCorrectionCollection xmlns="urn:ASC:CDL:v1.2">
  <ColorCorrection id="cc06668">
    <SOPNode>
      <Slope> -1 -1 -1 </Slope>
      <Offset> 1 1 1 </Offset>
      <Power> 1 1 1 </Power>
    </SOPNode>
    <SATNode>
      <Saturation> 0 </Saturation>
    </SATNode>
  </ColorCorrection>
</ColorCorrectionCollection>
If I set <Saturation> 1 </Saturation> everything is fine, just that I get a "color negative". But the very moment I use <Saturation> 0 </Saturation> the result is a non-inverted b&w image. Looks like Slope and Offset then are ignored.

I am using ImageMagick 6.6.6-5 2010-12-12 Q16 http://www.imagemagick.org

Bug or disability? Your help would be most welcome!

Thanks a lot and greetings from Germany
Andreas

Re: problem with CDL: inverting and zero saturation

Posted: 2011-05-26T21:03:40-07:00
by fmw42
Standard CDL does not seem to support slope values less than 0 (though I suppose it could be made so, i.e. -1 to 1). See http://en.wikipedia.org/wiki/ASC_CDL

"s is slope (any number 0 or greater, nominal value is 1.0)"

You might request an enhancement from the IM developers, if they are willing to modify the standards of the CDL.

I tried:

convert rose: -cdl cdl.xml rose_invert.png

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ColorCorrectionCollection xmlns="urn:ASC:CDL:v1.2">
  <ColorCorrection id="cc06668">
    <SOPNode>
      <Slope> -1.0 -1.0 -1.0 </Slope>
      <Offset> 0.0 0.0 0.0 </Offset>
      <Power> 1.0 1.0 1.0 </Power>
    </SOPNode>
    <SATNode>
      <Saturation> 1.0 </Saturation>
    </SATNode>
  </ColorCorrection>
</ColorCorrectionCollection>
And just got a black image as if -1 was clipped at 0.

Re: problem with CDL: inverting and zero saturation

Posted: 2011-05-26T22:28:00-07:00
by aberkl
Hi Fred,
Standard CDL does not seem to support slope values less than 0 (though I suppose it could be made so, i.e. -1 to 1). See http://en.wikipedia.org/wiki/ASC_CDL "s is slope (any number 0 or greater, nominal value is 1.0)"
you are right, will try to find out if Wikipedia is correct here...
...<Slope> -1.0 -1.0 -1.0 </Slope><Offset> 0.0 0.0 0.0 </Offset>...
And just got a black image as if -1 was clipped at 0.
this seems to make sense to me: with a gain of -1 (Slope) you will crush everything to zero unless you offset it to +1.

probably using "logo" is a bit easier to see:

Code: Select all

convert -cdl cdl.xml logo: result.png
this one results in a "color negative", fair enough.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ColorCorrectionCollection xmlns="urn:ASC:CDL:v1.2">
  <ColorCorrection id="cc06668">
	<SOPNode>
	  <Slope> -1.0 -1.0 -1.0 </Slope>
	  <Offset> 1.0 1.0 1.0 </Offset>
	  <Power> 1.0 1.0 1.0 </Power>
	</SOPNode>
	<SATNode>
	  <Saturation> 1.0 </Saturation>
	</SATNode>
  </ColorCorrection>
</ColorCorrectionCollection>
this one gives a b&w image only, slope and offset seem to be ignored, just saturation is processed

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ColorCorrectionCollection xmlns="urn:ASC:CDL:v1.2">
  <ColorCorrection id="cc06668">
	<SOPNode>
	  <Slope> -1.0 -1.0 -1.0 </Slope>
	  <Offset> 1.0 1.0 1.0 </Offset>
	  <Power> 1.0 1.0 1.0 </Power>
	</SOPNode>
	<SATNode>
	  <Saturation> 0.0 </Saturation>
	</SATNode>
  </ColorCorrection>
</ColorCorrectionCollection>
finally if I use this one on the "color negative" image from above I get a b&w result from the already inverted image. But only with an intermediate step...

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ColorCorrectionCollection xmlns="urn:ASC:CDL:v1.2">
  <ColorCorrection id="cc06668">
	<SOPNode>
	  <Slope> 1.0 1.0 1.0 </Slope>
	  <Offset> 0.0 0.0 0.0 </Offset>
	  <Power> 1.0 1.0 1.0 </Power>
	</SOPNode>
	<SATNode>
	  <Saturation> 0.0 </Saturation>
	</SATNode>
  </ColorCorrection>
</ColorCorrectionCollection>
For now, thanks a lot for your response.

Best, Andreas

Re: problem with CDL: inverting and zero saturation

Posted: 2011-05-26T23:29:01-07:00
by aberkl
Hi Fred,

I got me the official ASC specs in the meantime and Wikipeda is right:
The input value, slope, ranges from 0.0 (constant output at Offset) to less than infinity
...
out = in * slope 0 ≤ slope < ∞
Since I need to stay conform with the ASC standards: no more need to fiddle around.

Thanks and best, Andreas