Page 1 of 1

Why Colorize/Hue/Saturation/Luminize operators HSB-based?

Posted: 2012-08-13T05:22:08-07:00
by ippei
I want HueHSL/SaturationHSL/ColorizeHSL/LuminizeHSL composite operators. Are there any answers or suggestions?

I utilize ImageMagick to process a lot of PSD files created by various tools, mostly Adobe Photoshop series.
Adobe Photoshop has non-RGB-based (nor CMY-based) blending modes i.e. hue/saturation/color/luminosity,
and ImageMagick alike provides Hue/Saturation/Colorize/Luminize composite operators.

I believe most of the PSD managing tools including Adobe Photoshop work with HSL-like colorspace when blending layers with modes above,
in fact, a white pixel will never be color-ed with `color' blending mode.
(Strictly speaking, it's a variant of HSL. See http://en.wikipedia.org/wiki/HSL_and_HS ... r_software)

but I found that ones of ImageMagick are hard-coded to work with HSB colorspace in magick/composite.c,
for example, a white pixel may be color-ed by Colorize composition.

I think the development team has been conscious of Adobe Photoshop's blending modes, especially when designing its composite operators.
They are mostly work as other PSD managing tools do -- except these four operators...

Re: Why Colorize/Hue/Saturation/Luminize operators HSB-based

Posted: 2012-08-13T05:31:59-07:00
by magick
We can get a patch into the next point release of ImageMagick to use the HSL colorspace.

Re: Why Colorize/Hue/Saturation/Luminize operators HSB-based

Posted: 2012-08-14T02:45:48-07:00
by ippei
I got branches/ImageMagick-6 @ r8922-r8923, working well. Thank you, but...

It's hard for me to say,
now I know that it's better to use HCL from the point of view of Photoshop compatibility.
As of yesterday, I never believed ImageMagick supported HCL...

I sat down and explored the Subversion repository and finally I found HCL support was just added. (r8836 for trunk, r8838 for branches/ImageMagick-6)
The colorspace on which Photpshop's blending modes are based, I mentioned as a variant of HSL (Hue/Saturation/Lightness) yesterday, is luma/chroma/hue model. Yes it's called HCL in ImageMagick.

Thanks committers and contributors!

Re: Why Colorize/Hue/Saturation/Luminize operators HSB-based

Posted: 2012-08-14T13:15:48-07:00
by ippei
ConvertRGBToHCL()/ConvertHCLToRGB() doesn't work correctly!

I myself tried to replace the composite code with HCL version, then referring gem.c to copy & paste, and found it.
Here is a patch for branches/ImageMagick-6. I've not checked trunk yet.

Code: Select all

--- a/magick/gem.c
+++ b/magick/gem.c
@@ -142,5 +142,5 @@
                 b=x;
               }
-  m=luma-0.298839*r+0.586811*g+0.114350*b;
+  m=luma-(0.298839*r+0.586811*g+0.114350*b);
   *red=ClampToQuantum(QuantumRange*(r+m));
   *green=ClampToQuantum(QuantumRange*(g+m));
@@ -476,5 +476,5 @@
   else
     if (red == (Quantum) max)
-      h=fmod((g-b)/c,6.0);
+      h=fmod(6.0+(g-b)/c,6.0);
     else
       if (green == (Quantum) max)

Re: Why Colorize/Hue/Saturation/Luminize operators HSB-based

Posted: 2012-08-20T05:15:06-07:00
by magick
Can you revisit the HCL => RGB and RGB => HCL conversion? This command causes some white to improperly go to black:
  • convert rose: -define modulate:colorspace=HCL -modulate 150,100,100 show:

Re: Why Colorize/Hue/Saturation/Luminize operators HSB-based

Posted: 2012-09-12T18:33:40-07:00
by fmw42
With respect to this topic, has the -compose luminize/saturation/colorize methods been changed to use the new HCL colorspace?

It would seem so from some of my testing with -compose luminize that this is the case.

If so, can someone tell me in what release that change was made? I cannot see any comments in the changelog?

Also my results come closer to those of Photoshop using HCL than HSL or HSB, but they do not match perfectly. However, this is testing a script to emulate PS photofilters and not the conversion directly. If I can find a way to test that more directly, I will report back.



P.S. Is there a -define (similar to -define modulate:colorspace=HSL) to allow one to choose which colorspace to do the -compose luminize/saturation/colorize

Re: Why Colorize/Hue/Saturation/Luminize operators HSB-based

Posted: 2014-06-16T07:20:19-07:00
by michalfapso
Hi everyone, I just wanted to thank you all for contributing to ImageMagick. We needed to implement the color blending modes in our application, but ImageMagick produced different result than Gimp or Photoshop. I just had a quick look at the ImageMagick color blending (Hue, Saturate, Colorize, Luminize composite oprators), but it seems that alpha is not properly handled there. If you want to have a look at the Gimp-like color blending, I wrote the code here: http://stackoverflow.com/a/24207818/1341914.

Miso

Re: Why Colorize/Hue/Saturation/Luminize operators HSB-based

Posted: 2014-06-16T10:00:15-07:00
by fmw42
I believe that Photoshop uses something like IM HCLp. HCLp is as close as we have been able to reproduce the exact colorspace that PS uses. But they are not exactly the same. Until some one can tell us the exact colorspace that PS uses, an exact duplication is not possible.

see
viewtopic.php?f=1&t=23803&hilit=HCLp
viewtopic.php?f=2&t=21663

Does GIMP match Photoshop?