RGB to 8bit gray

Hello,

I have the following code which is giving a gray image from a colour. The problem is that the output image is very dark. If I save the image to RGB and use ColorSpace grayS = ColorSpace.getInstance(ColorSpace.CS_GRAY); then the image is at the right brightness, but not 8-bit (remains RGB).

Here is the code:

BufferedImage rgb2gray(BufferedImage image){

BufferedImage raw_image=image;

ColorConvertOp xformOp=new ColorConvertOp(null);

BufferedImage bi = new BufferedImage(raw_image.getWidth(), raw_image.getHeight(), BufferedImage.TYPE_USHORT_GRAY);

xformOp.filter(raw_image, bi);

return bi;

}

P.S. There is a major problem with the account names an registrations. Every time I need a new account as the previous is not working. DO SOMETHING!!! (This applies to the admins)

Thanks

[860 byte] By [gmfa] at [2007-11-15]