Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Images and ICC profiles

Reply
Thread Tools

Images and ICC profiles

 
 
David Bouchard
Guest
Posts: n/a
 
      05-06-2005
i,

I've been trying for a few days to convert images using icc profiles.
What i want to do seems fairly easy but i've had no luck so far :

- i've an image (jpg image)
- i've an icc profile
[ successfuly read using ICC_Profile.getInstance(new
FileInputStream("profiles/profile.icc")); ]

I just want to convert the image using this icc profile.
I've tried JAI, 'standard' java 1.4.2 apis but none worked.
Could someone who successfuly converted an image using an icc profle
provide java code ?

Thanks a lot,
David.

In the following code, when I uncomment (1) and comment (2), the image
is converted to grayscale
screen output : http://homepage.mac.com/d.bouchard/dev/color2gray.png

If I comment (1) and uncomment (2), the image is not converted (i.e.
nothing happens)

console output :

INFO TestICC2 - loading profile
INFO TestICC2 - GAMMA COMPONENT [0] [2.6015625]
INFO TestICC2 - GAMMA COMPONENT [1] [2.6015625]
INFO TestICC2 - GAMMA COMPONENT [2] [2.6015625]
INFO TestICC2 - WHITE POINT [0] [0.9538574]
INFO TestICC2 - WHITE POINT [1] [1.0]
INFO TestICC2 - WHITE POINT [2] [1.4311523]
INFO TestICC2 - MATRIX
INFO TestICC2 - 0.3535614 0.43249512 0.17814636
INFO TestICC2 - 0.19529724 0.6667633 0.13853455
INFO TestICC2 - 0.012313843 0.092926025 0.71951294

screen output : http://homepage.mac.com/d.bouchard/dev/color2icc.png

The code :

public TestICC2()
{
try
{
JFrame frame = new JFrame("test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
JPanel main = new JPanel(new BorderLayout());
frame.setContentPane(main);
ImageIcon ii = new ImageIcon(IMAGE);
JLabel srcLabel = new JLabel(ii);
main.add(srcLabel, BorderLayout.WEST);
frame.pack();
frame.setVisible(true);
logger.info("loading profile");
ICC_Profile profiles[] = new ICC_Profile[1];
// Color2Gray (1)
//profiles[0] =
ICC_ProfileGray.getInstance(ICC_ColorSpace.CS_GRAY );
// Color2ICC (2)
profiles[0] = ICC_Profile.getInstance(new
FileInputStream(PROFILE));
displayInfoProfil(profiles[0]);
BufferedImage src = new
BufferedImage(ii.getIconWidth(),
ii.getIconHeight(),
BufferedImage.TYPE_INT_RGB);
src.getGraphics().drawImage(ii.getImage(), 0, 0, this);
ColorConvertOp cco = new ColorConvertOp(profiles,
null);
BufferedImage dest = cco.filter(src, null);
JLabel destLabel = new JLabel(new ImageIcon(dest));
main.add(destLabel, BorderLayout.EAST);
frame.pack();
}
catch (Exception e)
{
logger.error("error", e);
}

}

public void displayInfoProfil(ICC_Profile profile)
{
if (profile instanceof ICC_ProfileRGB)
{
ICC_ProfileRGB iccPRGB = (ICC_ProfileRGB)profile;
int i , j;
for ( i = 0 ; i < iccPRGB.getNumComponents() ; i++ )
{
logger.info("GAMMA COMPONENT [" + i + "] ["
+ iccPRGB.getGamma(i) + "]");
}
float mwp[] = iccPRGB.getMediaWhitePoint();
for ( i = 0 ; i < mwp.length ; i++ )
{
logger.info("WHITE POINT [" + i + "] [" +
mwp[i] + "]");
}
float matrice[][] = iccPRGB.getMatrix();
StringBuffer sb = new StringBuffer();
logger.info("MATRIX");
for ( i = 0 ; i < matrice.length ; i++ )
{
sb.setLength(0);
sb.append("|");
for ( j = 0 ; j < matrice[i].length ; j++ )
{
sb.append(matrice[i][j] + "\t");
}
sb.append("|");
logger.info(sb.toString());
}
}
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ICC Profiles, Web Browsers, and Your Images Christian Bonanno Digital Photography 55 09-26-2005 06:19 AM
Using ICC profiles David Bouchard Java 4 05-11-2005 08:11 AM
Image conversion with icc profiles David Bouchard Java 4 05-04-2005 02:03 PM
Image conversion with icc profiles David Bouchard Java 0 05-02-2005 02:47 PM
ICC profiles for Nikon 8000, Canon i960 and Photoshop 7 C Digital Photography 3 12-29-2003 05:44 PM



Advertisments