问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/7421904/getting-the-pixel-value-of-a-tiff-image-in-java