Skip to main content

[JAVA2D] Color conversion

1 reply [Last post]
Anonymous

Reply viewing options

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

Hi Alexey,

Thank you for your answer.

I have changed our code to use the conversion you suggested.

About being able to change the colorconversion of images to colorimetric.

Since I know we are using both perceptual conversion for both Color objects
and images we do not need that anymore.

However we got the idea it might be possible having a two step process here
too as with the colorimetric color conversion of Color objects.

First convert the image to ciexyz colorspace and then convert this image to
the output colorspace.

Greetings

Roland.

2006/8/30, Alexey Ushakov :
>
> Hello Roland,
>
> The code that you've sent performs perceptual color conversion. Here is a
> hint that could reduce inaccuracy.
>
> Replace following line:
>
>
> ColorConvertOp colconv=new ColorConvertOp(
> colorspaceInput,colorspaceOutput,null);
>
> with
>
> ColorConvertOp colconv=new ColorConvertOp(null);
>
> Doing this you will avoid two unnecessary color transformation. In your
> case the whole transform is : Src_Img_CS -> Src_Img_CS -> Dst_Img_CS ->
> Dst_Img_CS. My suggestion reduces it to Src_Img_CS -> Dst_Img_CS
>
>
>
> Roland wrote:
>
> 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?
>
> Looks like we have no straightforward way in our api for doing this with
> images. Although, I think it might be possible through modifying ICC tags
> (icSigHead) in input and output ICC profiles. So, if you really want to have
> this option through image color conversion I'll find the exact procedure.
> (Otherwise you could perform per-pixel conversion using Color stuff)
>
> Best Regards,
>
> Alexey
>
>
>
> 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]