Skip to main content

Color conversion

2 replies [Last post]
Anonymous

Hi,

In a java project that we are doing, we have to convert images and colors
from a RGB colorspace to a CMYK colorspace.

For the colorconversion we use the following code:

float[] cieValues = colorspaceInput.toCIEXYZ(values);

float[] returnValues = colorspaceOutput.fromCIEXYZ(cieValues);

where colorspaceInput is defined by

ICC_Profile inputProfile = ICC_Profile.*getInstance*("srgb color space
profile.icm");

ColorSpace colorspaceInput = new ICC_ColorSpace( inputProfile);

and colorspaceOutput by

ICC_Profile outputProfile = ICC_Profile.*getInstance*("
EuropeISOCoatedFOGRA27.icc");

ColorSpace colorspaceOutput = new ICC_ColorSpace( outputProfile);
srgb color space profile.icm and EuropeISOCoatedFOGRA27.icc are icc
colorprofiles.

We have checked the values that result from this with somebody else who has
a lot of experience with color and who uses another

program programmed in another language for color conversion. He uses the
same input and output profiles for this test.

Unfortunately there were some differences between both programs, see the
list below.

Also visually the colors were off. For example colorconverting RGB(0.88,
0.88, 1.00) which should be light blue, resulted in a kind a somewhat purple
color when printing it on a printing press. (using just RGB on this same
press resulted in a light blue color by the way)

Am I doing the color correction correctly or do have to apply some other
settings that influence the colorcorrection?

Input RGB : 0.00, 0.00, 0.00

Java CMYK result: 0.85882354,0.8509804,0.7882353, 1.0

Check CMYK result: 0.85, 0.85, 0.78, 1.00

Input RGB : 0.88, 0.88, 1.00

Java CMYK result: 0.13577478, 0.13638514,0,0

Check CMYK result: 0.15, 0.13, 0.00, 0.00

Input RGB : 0.20, 0.00, 0.00

Java CMYK result: 0.7904326, 0.83591974,0.8076448,0.9207599

Check CMYK result: 0.51, 0.95, 0.84, 0.84

Input RGB : 0.00, 0.80, 0.00

Java CMYK result: 0.75292593, 0.00, 1.00, 0.00

Check CMYK result: 0.74, 0.00, 1.00, 0.00

Input RGB : 0.94, 0.94, 0.16

Java CMYK result: 0.13614099, 0.00, 0.92170596, 0.00

Check CMYK result: 0.18, 0.00, 0.83, 0.00

Greetings,

Roland.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Alexey Ushakov

Hello Roland,

Looks like you are comparing different types of color conversion:
colorimetric vs perceptual. Your java code performs colorimetric
transforms whereas checking program uses transforms to produce the
best perceptual match between input and output colors. To get the same
transform as you have in checking program you should skip toCIEXYZ step
in your transformations. Just use colorspaceOutput.fromRGB. There still
will be small differences (I've checked it) between java and your
checking program but not so noticeable that you have at the moment. I
guess they come from inaccuracies of the conversions between internal
data formats.

Best Regards,
Alexey

Roland wrote:

> Hi,
>
> In a java project that we are doing, we have to convert images and
> colors from a RGB colorspace to a CMYK colorspace.
>
> For the colorconversion we use the following code:
>
> float[] cieValues = colorspaceInput.toCIEXYZ(values);
>
> float[] returnValues = colorspaceOutput.fromCIEXYZ(cieValues);
>
>
>
> where colorspaceInput is defined by
>
> ICC_Profile inputProfile = ICC_Profile./getInstance/("srgb color space
> profile.icm");
>
> ColorSpace colorspaceInput = new ICC_ColorSpace( inputProfile);
>
> and colorspaceOutput by
>
> ICC_Profile outputProfile =
> ICC_Profile./getInstance/("EuropeISOCoatedFOGRA27.icc");
>
> ColorSpace colorspaceOutput = new ICC_ColorSpace( outputProfile);
>
> srgb color space profile.icm and EuropeISOCoatedFOGRA27.icc are icc
> colorprofiles.
>
>
>
> We have checked the values that result from this with somebody else
> who has a lot of experience with color and who uses another
>
> program programmed in another language for color conversion. He uses
> the same input and output profiles for this test.
>
> Unfortunately there were some differences between both programs, see
> the list below.
>
> Also visually the colors were off. For example colorconverting
> RGB(0.88, 0.88, 1.00) which should be light blue, resulted in a kind a
> somewhat purple color when printing it on a printing press. (using
> just RGB on this same press resulted in a light blue color by the way)
>
> Am I doing the color correction correctly or do have to apply some
> other settings that influence the colorcorrection?
>
>
>
> Input RGB : 0.00, 0.00, 0.00
>
> Java CMYK result: 0.85882354,0.8509804,0.7882353, 1.0
>
> Check CMYK result: 0.85, 0.85, 0.78, 1.00
>
>
>
> Input RGB : 0.88, 0.88, 1.00
>
> Java CMYK result: 0.13577478, 0.13638514,0,0
>
> Check CMYK result: 0.15, 0.13, 0.00, 0.00
>
>
>
> Input RGB : 0.20, 0.00, 0.00
>
> Java CMYK result: 0.7904326, 0.83591974,0.8076448,0.9207599
>
> Check CMYK result: 0.51, 0.95, 0.84, 0.84
>
>
>
> Input RGB : 0.00, 0.80, 0.00
>
> Java CMYK result: 0.75292593, 0.00, 1.00, 0.00
>
> Check CMYK result: 0.74, 0.00, 1.00, 0.00
>
> Input RGB : 0.94, 0.94, 0.16
>
> Java CMYK result: 0.13614099, 0.00, 0.92170596, 0.00
>
> Check CMYK result: 0.18, 0.00, 0.83, 0.00
>
> Greetings,
>
> Roland.
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body of the message "signoff JAVA2D-INTEREST". For general help, send
> email to listserv@java.sun.com and include in the body of the message
> "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Roland

Hi Alexey,

Thanks for your reply. I tried it too with the same results as you had.

For colorconverting images we use the following code:

ColorModel colorModelOutput = colorModelOutput = new
ComponentColorModel(colorspaceOutput,bits ,true,false,
Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);

or

ColorModel colorModelOutput = new ComponentColorModel(colorspaceOutput,bits
,false,false,Transparency.OPAQUE, DataBuffer.TYPE_BYTE);

WritableRaster raster = colorModelOutput.createCompatibleWritableRaster(width,
height);
BufferedImage bufferedImageColorConverted = new
BufferedImage(colorModelOutput, raster, false, null);
ColorSpace colorspaceInput=bufferedImageInput.getColorModel
().getColorSpace();
ColorConvertOp colconv=new ColorConvertOp(
colorspaceInput,colorspaceOutput,null);
colconv.filter(bufferedImageInput,bufferedImageColorConverted);

If I use perceptual when converting colors I would also like to use
perceptual when colorconverting images. Does the code above uses
colorimetric or a perceptual oriented colorconversion?
How can i change this if necessary?

Greetings,

Roland

2006/8/23, Alexey Ushakov :
>
> Hello Roland,
>
> Looks like you are comparing different types of color conversion:
> colorimetric vs perceptual. Your java code performs colorimetric transforms
> whereas checking program uses transforms to produce the best perceptual
> match between input and output colors. To get the same transform as you have
> in checking program you should skip toCIEXYZ step in your transformations.
> Just use colorspaceOutput.fromRGB. There still will be small differences
> (I've checked it) between java and your checking program but not so
> noticeable that you have at the moment. I guess they come from inaccuracies
> of the conversions between internal data formats.
>
> Best Regards,
> Alexey
>
> Roland wrote:
>
> Hi,
>
> In a java project that we are doing, we have to convert images and colors
> from a RGB colorspace to a CMYK colorspace.
>
> For the colorconversion we use the following code:
>
> float[] cieValues = colorspaceInput.toCIEXYZ(values);
>
> float[] returnValues = colorspaceOutput.fromCIEXYZ(cieValues);
>
>
>
> where colorspaceInput is defined by
>
> ICC_Profile inputProfile = ICC_Profile.*getInstance*("srgb color space
> profile.icm");
>
> ColorSpace colorspaceInput = new ICC_ColorSpace( inputProfile);
>
> and colorspaceOutput by
>
> ICC_Profile outputProfile = ICC_Profile.*getInstance*("
> EuropeISOCoatedFOGRA27.icc");
>
> ColorSpace colorspaceOutput = new ICC_ColorSpace( outputProfile);
> srgb color space profile.icm and EuropeISOCoatedFOGRA27.icc are icc
> colorprofiles.
>
>
>
> We have checked the values that result from this with somebody else who
> has a lot of experience with color and who uses another
>
> program programmed in another language for color conversion. He uses the
> same input and output profiles for this test.
>
> Unfortunately there were some differences between both programs, see the
> list below.
>
> Also visually the colors were off. For example colorconverting RGB(0.88,
> 0.88, 1.00) which should be light blue, resulted in a kind a somewhat
> purple color when printing it on a printing press. (using just RGB on this
> same press resulted in a light blue color by the way)
>
> Am I doing the color correction correctly or do have to apply some other
> settings that influence the colorcorrection?
>
>
>
> Input RGB : 0.00, 0.00, 0.00
>
> Java CMYK result: 0.85882354,0.8509804,0.7882353, 1.0
>
> Check CMYK result: 0.85, 0.85, 0.78, 1.00
>
>
>
> Input RGB : 0.88, 0.88, 1.00
>
> Java CMYK result: 0.13577478, 0.13638514,0,0
>
> Check CMYK result: 0.15, 0.13, 0.00, 0.00
>
>
>
> Input RGB : 0.20, 0.00, 0.00
>
> Java CMYK result: 0.7904326, 0.83591974,0.8076448,0.9207599
>
> Check CMYK result: 0.51, 0.95, 0.84, 0.84
>
>
>
> Input RGB : 0.00, 0.80, 0.00
>
> Java CMYK result: 0.75292593, 0.00, 1.00, 0.00
>
> Check CMYK result: 0.74, 0.00, 1.00, 0.00
>
> Input RGB : 0.94, 0.94, 0.16
>
> Java CMYK result: 0.13614099, 0.00, 0.92170596, 0.00
>
> Check CMYK result: 0.18, 0.00, 0.83, 0.00
>
> Greetings,
>
> Roland.
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body of the message "signoff JAVA2D-INTEREST". For general help, send email
> to listserv@java.sun.com and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]