Black point compensation

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
Miki
Posts: 3
Joined: 2014-04-03T21:50:46-07:00
Authentication code: 6789

Black point compensation

Post 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);
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Black point compensation

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Miki
Posts: 3
Joined: 2014-04-03T21:50:46-07:00
Authentication code: 6789

Re: Black point compensation

Post 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:
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Black point compensation

Post 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);
  }
}
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Miki
Posts: 3
Joined: 2014-04-03T21:50:46-07:00
Authentication code: 6789

Re: Black point compensation

Post 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
Post Reply