How to extract CMYK color values from a image (tiff) data byte array

1.3k views Asked by At

Basically I need to extract CMYK color values from a byte array containing image data (tif image). I am not interested in converting the values to rgb colorspase. I just need to extract the cyan, magenta, yellow, and key (black) values (ideally in hex but beggars can not by choosers). Can libraries like JAI or imageIO help me do that?

Edit : In line with the comments I received I tried the following

   Raster r = renderedImage.getData();
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
           for(int i =0; i<r.getWidth();i++ ){
               for(int j = 0; j<r.getHeight();j++){
                  baos.write((byte)r.getSample(i,j,0));
               }
           }
       byte [] cyanBand = baos.toByteArray();

However, the resulting values in the array do not look correct. I am following the correct approach?

Any ideas would be more than welcomed .

Thanks in advance

0

There are 0 answers