0

Short;
I need to get the value of a specific pixel from a supplied high color depth image.

Details:
I am currently using Processing to make a Slit-scanning program. Essentially, I am using a greyscale image to pick frames from an animation, and using pixels from those frames to make a new image.

For example if the greyscale image has a black pixel, it takes the same pixel in the first frame, and adds it to an image. If its a white pixel, it does the same with the last frame.
Anything inbetween, naturally, picks the frames inbetween.

The gist is, if supplied a horizontal gradient, and a video of a sunset, then youd have the start of the sunset on the left, slowly transitioning to the end on the right.

My problem is, when using Processing, I seem to be only able to get greyscale values of 0-255 using the default library.
Black = 0
White = 255

This limits me to using only 256 frames for the source animation, or to put up with a pixaly, unsmooth end image.

I really need to be able to supply, and thus get, pixel values in a much bigger range. Say,
Black = 0
White = 65025

Is there any Java lib that can do this? That I can supply, say, a HDR Tiff or TGA image file, and be able to read the full range of color out of it?

Thanks,

darkflame
  • 998
  • 1
  • 9
  • 23

1 Answers1

0

Ok, found a great library for this; https://code.google.com/p/pngj/

Supports the full PNG feature set - including 16 bit greyscale or full color images. Allows me to retrieve rows from a image, then pixels from those rows.

PngReader pngr = new PngReader(new File(filename));
tmrows = pngr.readRows();
ImageLineInt neededline = (ImageLineInt)tmrows.getImageLine(y);

if (neededline.imgInfo.greyscale==true){

   //get the right pixel for greyscale
     value = neededline.getScanline()[x];

} else {          

   //get the right pixel for RGB
     value  = neededline.getScanline()[x*3];
}

You simply multiply by 3 as the scanline consists of RGBRGBRGB (etc) for a full color image without alpha.

darkflame
  • 998
  • 1
  • 9
  • 23