|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTiffLoader
public class TiffLoader
Class TiffLoader reads Tiff image into the class instance. variables.
It uses class Raster when reading the image. All image data is expressed as a collection of pixels. Each pixel consists of a number of samples. A sample is a datum for one band of an image and a band consists of all samples of a particular type in an image. For example, a pixel might contain three samples representing its red, green and blue components. There are three bands in the image containing this pixel. One band consists of all the red samples from all pixels in the image. The second band consists of all the green samples and the remaining band consists of all of the blue samples. The pixel can be stored in various formats. For example, all samples from a particular band can be stored contiguously or all samples from a single pixel can be stored contiguously. In the Java 2D(tm) API, all built-in image processing and display operators process samples which represent unsigned integral values. A collection of pixels is represented as a Raster, which consists of a DataBuffer and a SampleModel. The SampleModel allows access to samples in the DataBuffer and may provide low-level information that a programmer can use to directly manipulate samples and pixels in the DataBuffer. This class is generally a fall back method for dealing with images. More efficient code will cast the SampleModel to the appropriate subclass and extract the information needed to directly manipulate pixels in the DataBuffer. There is an option useLogInputFlag to add Log(grayscale) to take scaled log of grayscale data for maxBits>8-bits (e.g., 10-bits or 16-bits) for TIFF images prior to reading them. Scale log((2**nBitsPerPixel)-1) to 255: f'(g) = 255*log(g+1)/log((2**nBitsPerPixel)-1). This requires two JAI jar files: jai_core.jar and jai_codec.jar for TiffLoader.java to compile. These should be in the same class path as the Flicker.jar file.
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/
,
See the SUN license file for JAI at these web sites.
This work was produced by Peter Lemkin of the National Cancer
Institute, an agency of the United States Government. As a work of
the United States Government there is no associated copyright. It is
offered as open source software under the Mozilla Public License
(version 1.1) subject to the limitations noted in the accompanying
LEGAL file. This notice must be included with the code. The Flicker
Mozilla and Legal files are available on
http://open2dprot.sourceforge.net/Flicker
,
Flicker Home
Original: Date: 8-13-2003, Jai Evans.Field Summary | |
---|---|
private static boolean |
ALWAYS
Fixed value of true for DEBUGGING |
boolean |
blackIsZeroFlag
Black is Zero flag |
java.awt.image.ColorModel |
cm
|
static int |
count
instance # of TiffLoader |
int |
dataType
data type from sampleModel.getDataType() The types are defined as DataBuffer.TYPE_xxxx where xxxx is (BYTE, DOUBLE, FLOAT, INT, SHORT, UNDEFINED, USHORT) |
private static boolean |
dbugFlag
debugging flag |
ImageDecoder |
decoder
Tiff Image Decoder |
java.lang.String |
fatalMsg
Msg why failed if not null |
java.lang.String |
fileName
filename path of image file |
float[] |
gray2OD
[FUTURE] grayscale to OD lookup table [0:maxGray-1] if supplied as additional TIFF tags. |
java.awt.Image |
img
Image structure required for Flicker |
boolean |
isComponentCMflag
set if has ComponentColorModel |
boolean |
isComponentSMflag
set if has ComponentSampleModel |
boolean |
isMultiplePixelPackedSMflag
set if has a MultiplePixelPackedSampleModel |
boolean |
isPackedCMflag
set if PackedColorModel |
boolean |
isPackedFlag
set if pixel can be packed into a byte array |
boolean |
isRGBcolorImageFlag
set if this is a RGB color image |
boolean |
isSinglePixelPackedSMflag
set if has a SinglePixelPackedSampleModel |
int |
maxGray
maximum gray value |
int |
minX
X upper left hand corner of image origin |
int |
minY
Y upper left hand corner of image origin |
int |
nBands
# of samples/pixel |
int |
nBitsPerPixel
# bits/pixel is sampleModel.sampleSize[0] |
int |
nCols
# of columns in the image |
private static boolean |
NEVER
Fixed value of false for DEBUGGING |
int |
nPixels
# of pixels/image (is nRows*nCols) |
int |
nRows
# of rows in the image |
int |
numDataElements
# raster DataBuffer data elements/pixel |
int |
numPages
# of TIFF pages |
PixelAccessor[] |
pi
List of PixelAccessors from the RenderedImages' |
private int[] |
pixels
image of size nRows of nCols pixels. |
java.awt.image.Raster |
ras
Raster image read |
java.awt.image.RenderedImage[] |
ri
List of Rendered images that was read in the tiff file |
java.awt.image.SampleModel |
sampleModel
Tiff sample model name |
int[] |
sampleSizes
bits/pixel is sample sizes [0:nBands-1] from sampleModel.getSampleSize() |
boolean |
useLogInputFlag
"Use log of pixels if > 8-bits grayscale image" |
Constructor Summary | |
---|---|
TiffLoader()
TiffLoader() - constructor |
|
TiffLoader(boolean flag)
TiffLoader() - constructor where set the debug flag |
Method Summary | |
---|---|
java.lang.String |
doTiffLoad(java.lang.String path,
boolean checkCacheFlag)
doTiffLoad() - load the image and array grab of TIFF files |
java.awt.Image |
getImage()
getImage() - get pixels from the raster |
int |
getNbrRGBpixels(int[] pixels,
int nPixels)
getNbrRGBpixels() - test if red==green==blue for all pixels |
int[] |
getTiffPixels(java.awt.image.Raster r,
boolean checkCacheFlag)
getTiffPixels() - get pixels from the raster |
void |
getTiffProperties(java.awt.image.Raster r)
getTiffProperties() - get properties of the Tiff image |
static void |
main(java.lang.String[] args)
main() - test loader. |
java.awt.image.RenderedImage[] |
readTiff(java.lang.String fileName)
readTiff() - read a tiff image file |
void |
setDbugFlag(boolean flag)
setDbugFlag() - flag |
void |
setUseLogFlag(boolean flag)
setUseLogFlag() - flag to set the log flag This is used if the data has more than 8-bits of grayscale so the data is transformed by the log over the range of 255*log(10**nBits-1) to 0 |
java.lang.String |
toString()
toString() - return string representation of this instance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static boolean ALWAYS
private static boolean NEVER
private static boolean dbugFlag
public static int count
public java.lang.String fileName
public java.awt.image.SampleModel sampleModel
public java.awt.image.RenderedImage[] ri
public PixelAccessor[] pi
public java.awt.image.Raster ras
public ImageDecoder decoder
public java.awt.image.ColorModel cm
public int nRows
public int nCols
public int minX
public int minY
public int nBands
public int numPages
public int numDataElements
private int[] pixels
public java.awt.Image img
public int dataType
public int[] sampleSizes
public boolean isPackedFlag
public boolean isPackedCMflag
public boolean isComponentCMflag
public boolean isComponentSMflag
public boolean isSinglePixelPackedSMflag
public boolean isMultiplePixelPackedSMflag
public int nBitsPerPixel
public int nPixels
public boolean blackIsZeroFlag
public boolean isRGBcolorImageFlag
public float[] gray2OD
public int maxGray
public boolean useLogInputFlag
public java.lang.String fatalMsg
Constructor Detail |
---|
public TiffLoader()
public TiffLoader(boolean flag)
Method Detail |
---|
public void setDbugFlag(boolean flag)
public void setUseLogFlag(boolean flag)
public java.awt.image.RenderedImage[] readTiff(java.lang.String fileName) throws java.io.IOException
fileName
- is the file to be read
java.io.IOException
public int[] getTiffPixels(java.awt.image.Raster r, boolean checkCacheFlag)
r
- is the image raster instancecheckCacheFlag
- to see if pixels data exists, then return it
public void getTiffProperties(java.awt.image.Raster r)
r
- is the image raster instancepublic java.awt.Image getImage()
r
- is the image raster instance
public java.lang.String doTiffLoad(java.lang.String path, boolean checkCacheFlag)
path
- of the imagecheckCacheFlag
- to see if pixels data exists, then return it
public int getNbrRGBpixels(int[] pixels, int nPixels)
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |