2

The ImageIO package doesn't work with .tif images and I cannot create a BufferedImage (Class I'm more familiar with) from a .tif file.

How do I easily get the pixel value of a TIFF image in Java? How can I do it FAST?

I'm not experienced with image processing and some sample code would be greatly appreciated!

Thanks!

Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154

1 Answers1

2

You will need the Java Advanced Imaging API: JAI in order to work with TIFF images.

From the JAI API description:

TIFF

In addition to the baseline specification, the encoder and decoder support PackBits, modified Huffman and CCITT bilevel encodings (fax), JPEG-in-TIFF (per TIFF Technical Note #2), and DEFLATE compression schemes, can handle images with 16- and 32-bit integral samples and 32-bit floating point samples, and can read and write tiled images of all supported data types. The decoder in addition can decompress LZW-compressed imagery.

Additional features may be addressed in the future.

A single page of a multi-page TIFF file may loaded most easily by using the page parameter with the "TIFF" operator which is documented in the class comments of javax.media.jai.operator.TIFFDescriptor. A code sample is included here to show a means of loading a single page of a multi-page TIFF file using the ancillary codec classes directly.

Try out some of these tutorials.

Costis Aivalis
  • 13,680
  • 3
  • 46
  • 47
  • Thanks, I heard about JAI before and it's good to have a confirmation that it's what I actually need! Did you ever use it? The API barely sounds like english to me and I'm having a hard time figuring out how to get a single pixel out of a tif... :/ Do you know if there is a simple getPixel(x,y) function or do I have to become an image processing expert first?? – Marsellus Wallace Sep 14 '11 at 20:32
  • There is a bunch of tutorials that will get you started. I have used it for a face recognition application and everything worked fine. I had no need to process TIFF files though. – Costis Aivalis Sep 14 '11 at 20:35
  • There is always the possibility to convert your TIFF to PNG. Take a look at this posting: http://stackoverflow.com/questions/2291358/how-do-i-convert-a-tif-to-png-in-java – Costis Aivalis Sep 14 '11 at 20:55