Page 1 of 1

Black point compensation

Posted: 2014-04-03T22:31:43-07:00
by Miki
Hi all.
I've just started Magick.NET.
I need to convert RGB image to CMYK image by using ICC profile.
I could make color space modification successfully, but I couldn't use Black Point Compensation like -black-point-compensation option.
Has Magick.NET been implemented Black Point Compensation feature yet?
Thank you.

P.S.
This is a piece of code I wrote:

Code: Select all

MagickReadSettings setting = new MagickReadSettings();
setting.ColorSpace = ColorSpace.sRGB;
MagickImage image = new MagickImage(file, setting);
image.AddProfile(new ColorProfile(in_profile));
image.AddProfile(new ColorProfile(out_profile));
image.ColorSpace = ColorSpace.CMYK;
if (intent == "Perceptual")      image.RenderingIntent = RenderingIntent.Perceptual;
else if (intent == "Saturation") image.RenderingIntent = RenderingIntent.Saturation;
else if (intent == "Relative")   image.RenderingIntent = RenderingIntent.Relative;
else if (intent == "Absolute")   image.RenderingIntent = RenderingIntent.Absolute;
else                             image.RenderingIntent = RenderingIntent.Undefined;
image.CompressionMethod = CompressionMethod.Zip;
/************************************
 *  Need Black Point Compensation   *
 ************************************/
image.Write(file);

Re: Black point compensation

Posted: 2014-04-04T00:59:28-07:00
by dlemstra
It has not been implemented in Magick.NET yet. I have created the following work item for this: https://magick.codeplex.com/workitem/1202 to make sure it is implemented in the next release. Thank you for reporting this.

Re: Black point compensation

Posted: 2014-05-06T19:37:16-07:00
by Miki
Hi. It's Miki.
I gratefully appreciate you added a new BPC feature.
I downloaded ver 6.8.9.002 which includes that, and I used.
I could set BlackPointCompensation option,
though, color transforming with "BPC = true" made no effect on an image.
I expect that black becomes lighter than "BPC = false".

This is a black color patch before transforming:
R=0, G=0, B=0
http://kie.nu/1Tt6

the black after transforming with "BPC = true":
C=255, M=254, Y=253, K=254 (<-- should be lighter)
http://kie.nu/1Tt9

the black after transforming with "BPC = false":
C=255, M=254, Y=253, K=254
http://kie.nu/1Tta

Here is my code:

Code: Select all

internal void transformColor(string file, string in_profile, string out_profile)
{
    MagickImage image = new MagickImage(file);
    image.AddProfile(new ColorProfile(in_profile));
    image.AddProfile(new ColorProfile(out_profile));
    image.ColorSpace = ColorSpace.CMYK;
    image.RenderingIntent = RenderingIntent.Perceptual;
    image.BlackPointCompensation = true; // or false
    image.CompressionMethod = CompressionMethod.Zip;
    image.Write(file);
}
I wonder why BPC doesn't work.
I think Magick.NET does the right thing as far as I read source code.
https://magick.codeplex.com/SourceContr ... Readme.txt

So, Magick++ must be wrong somehow. (Magick.NET is made from Magick++, isn't it?)
Now I read Magick++ source code, and I lost my way.
http://www.imagemagick.org/script/magick++.php

What could I do? :cry:

Re: Black point compensation

Posted: 2014-05-06T21:54:37-07:00
by dlemstra
You should set the BlackPointCompensation property before you add the profile to the image:

Code: Select all

internal void transformColor(string file, string in_profile, string out_profile)
{
  using(MagickImage image = new MagickImage(file))
  {
    // Set the settings for the color transformation
    image.RenderingIntent = RenderingIntent.Perceptual;
    image.BlackPointCompensation = true; // or false
   
    image.AddProfile(new ColorProfile(in_profile));
    // The color transformation happens here (this is where the magick happens):
    image.AddProfile(new ColorProfile(out_profile));
    image.ColorSpace = ColorSpace.CMYK;
    image.CompressionMethod = CompressionMethod.Zip;
    image.Write(file);
  }
}

Re: Black point compensation

Posted: 2014-05-06T23:47:26-07:00
by Miki
>dlemstra

Holy smokes!
I made it.
It's just like a command line operation.

Black transformed with BPC = true:
C=221, M=225, Y=201, K=166 (<-- lighter!)
http://kie.nu/1Tue

Black transformed with BPC = false:
C=255, M=254, Y=253, K=254
http://kie.nu/1Tug

THANK YOU. :D