O2Plib.image
Class TiffPixelLoader

java.lang.Object
  extended by O2Plib.image.TiffPixelLoader

public class TiffPixelLoader
extends java.lang.Object


Field Summary
 boolean blackIsZeroFlag
          Black is Zero flag
 java.awt.image.ColorModel cm
           
static int count
          instance # of TiffPixelLoader
 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
 com.sun.media.jai.codec.ImageDecoder decoder
          Tiff Image Decoder
 java.lang.String fatalMsg
          Msg why failed if not null
 java.lang.String fileName
          filename path of image file
 java.awt.Image img
          Image structure.
 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
private static boolean justPixelsFlag
           
 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
 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
 javax.media.jai.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"
static java.lang.String VERSION
          Version for this module
 
Constructor Summary
TiffPixelLoader()
          TiffPixelLoader() - constructor
TiffPixelLoader(boolean flag)
          TiffPixelLoader() - constructor where set the debug flag
 
Method Summary
 java.lang.String doTiffLoad(java.lang.String path, boolean checkCacheFlag, boolean justPixelsFlag)
          doTiffLoad() - load the image and array grab of TIFF files
 java.awt.Image getImage()
          getImage() - get AWT Image from the raster.
 int getNbrRGBpixels(int[] pixels, int nPixels)
          getNbrRGBpixels() - test if red==green==blue for all pixels
 int[] getPixels()
          getPixels() - get unpacked pixels array from the raster.
 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
 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

VERSION

public static final java.lang.String VERSION
Version for this module

See Also:
Constant Field Values

dbugFlag

private static boolean dbugFlag
debugging flag


justPixelsFlag

private static boolean justPixelsFlag

count

public static int count
instance # of TiffPixelLoader


fileName

public java.lang.String fileName
filename path of image file


sampleModel

public java.awt.image.SampleModel sampleModel
Tiff sample model name


ri

public java.awt.image.RenderedImage[] ri
List of Rendered images that was read in the tiff file


pi

public javax.media.jai.PixelAccessor[] pi
List of PixelAccessors from the RenderedImages'


ras

public java.awt.image.Raster ras
Raster image read


decoder

public com.sun.media.jai.codec.ImageDecoder decoder
Tiff Image Decoder


cm

public java.awt.image.ColorModel cm

nRows

public int nRows
# of rows in the image


nCols

public int nCols
# of columns in the image


minX

public int minX
X upper left hand corner of image origin


minY

public int minY
Y upper left hand corner of image origin


nBands

public int nBands
# of samples/pixel


numPages

public int numPages
# of TIFF pages


numDataElements

public int numDataElements
# raster DataBuffer data elements/pixel


pixels

private int[] pixels
image of size nRows of nCols pixels. This is either 8-bit, 16-bit, 24-bit RGB, etc. If the data is 8-bits, 12-bits or 16-bits then the (R,G,B) channels of the pixels[] array data are scaled to 8-bits and are set to be the same. [TODO] If the image is 24-bit (R,G,B) or an index-colormap 8-bit RGB, then set the (R,G,B) channels separately to preserve the colors. The data is left in pixels[] if justPixelsFlag is set, else it is cleared and the data is left in img.


img

public java.awt.Image img
Image structure. The data is left in pixels[] if justPixelsFlag is set, else it is cleared and the data is left in img.


dataType

public 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)


sampleSizes

public int[] sampleSizes
bits/pixel is sample sizes [0:nBands-1] from sampleModel.getSampleSize()


isPackedFlag

public boolean isPackedFlag
set if pixel can be packed into a byte array


isPackedCMflag

public boolean isPackedCMflag
set if PackedColorModel


isComponentCMflag

public boolean isComponentCMflag
set if has ComponentColorModel


isComponentSMflag

public boolean isComponentSMflag
set if has ComponentSampleModel


isSinglePixelPackedSMflag

public boolean isSinglePixelPackedSMflag
set if has a SinglePixelPackedSampleModel


isMultiplePixelPackedSMflag

public boolean isMultiplePixelPackedSMflag
set if has a MultiplePixelPackedSampleModel


nBitsPerPixel

public int nBitsPerPixel
# bits/pixel is sampleModel.sampleSize[0]


nPixels

public int nPixels
# of pixels/image (is nRows*nCols)


blackIsZeroFlag

public boolean blackIsZeroFlag
Black is Zero flag


isRGBcolorImageFlag

public boolean isRGBcolorImageFlag
set if this is a RGB color image


useLogInputFlag

public boolean useLogInputFlag
"Use log of pixels if > 8-bits grayscale image"


fatalMsg

public java.lang.String fatalMsg
Msg why failed if not null

Constructor Detail

TiffPixelLoader

public TiffPixelLoader()
TiffPixelLoader() - constructor


TiffPixelLoader

public TiffPixelLoader(boolean flag)
TiffPixelLoader() - constructor where set the debug flag

Method Detail

setDbugFlag

public void setDbugFlag(boolean flag)
setDbugFlag() - flag


setUseLogFlag

public 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


readTiff

public java.awt.image.RenderedImage[] readTiff(java.lang.String fileName)
                                        throws java.io.IOException
readTiff() - read a tiff image file

Parameters:
fileName - is the file to be read
Returns:
image rendered raster instance that may be an array of images
Throws:
java.io.IOException

getTiffPixels

public int[] getTiffPixels(java.awt.image.Raster r,
                           boolean checkCacheFlag)
getTiffPixels() - get pixels from the raster

Parameters:
r - is the image raster instance
checkCacheFlag - to see if pixels data exists, then return it
Returns:
1D array encoding a raster 2D image of size width X height.

getTiffProperties

public void getTiffProperties(java.awt.image.Raster r)
getTiffProperties() - get properties of the Tiff image

Parameters:
r - is the image raster instance

getImage

public java.awt.Image getImage()
getImage() - get AWT Image from the raster. The data is left in pixels[] if justPixelsFlag is set, else it is cleared and the data is left in img.

Parameters:
r - is the image raster instance
Returns:
Image object encoding a raster 2D image of size width X height.

getPixels

public int[] getPixels()
getPixels() - get unpacked pixels array from the raster. The data is left in pixels[] if justPixelsFlag is set, else it is cleared and the data is left in img.

Parameters:
r - is the image raster instance
Returns:
1D array encoding a raster 2D image of size width X height.

doTiffLoad

public java.lang.String doTiffLoad(java.lang.String path,
                                   boolean checkCacheFlag,
                                   boolean justPixelsFlag)
doTiffLoad() - load the image and array grab of TIFF files

Parameters:
path - of the image
checkCacheFlag - to see if pixels data exists, then return it
justPixelsFlag - if just want to get the pixels[] not img.
Returns:
null if succeed, else error message

getNbrRGBpixels

public int getNbrRGBpixels(int[] pixels,
                           int nPixels)
getNbrRGBpixels() - test if red==green==blue for all pixels

Returns:
# of color pixels. 0 means gray value image

toString

public java.lang.String toString()
toString() - return string representation of this instance

Overrides:
toString in class java.lang.Object
Returns:
string instance