com.c3d.image.hips
Class HipsImage

java.lang.Object
  |
  +--com.c3d.image.hips.HipsImage
Direct Known Subclasses:
HipsByteImage, HipsFloatImage, HipsPoint3fImage, HipsShortImage

public class HipsImage
extends java.lang.Object

Read and write HIPS2 headers. Names have been kept the same as those in HIPS. All accessors are read-only. Parameters are stored as strings in a hash table, rather than there being different types.

The following methods are inherited by subclasses public int[] rgbPixels(int imageIndex) throws HipsException; public float[] getPixel(float x, float y, int imageIndex); These allow images of any type to provide enough information for display. and simple image querying.

If you want to use a HIPS image in a graphical application see the below-mentione classes

See Also:
HipsProducer, HIPS

Field Summary
protected static int BUFSIZ
           
protected  int cols_
           
protected  int fcol_
           
protected  int frow_
           
protected  boolean isDataLoaded_
           
protected  int num_frame_
           
protected  int numcolor_
           
protected  int ocols_
           
protected  java.lang.String orig_date_
           
protected  java.lang.String orig_name_
           
protected  int orows_
           
protected  java.util.Hashtable params_
           
protected static int PFAHC
          adaptive hierarchical encoding
protected static int PFAHC3
          3-d adaptive hierarchical encoding
protected static int PFASCII
          ASCII rep, with linefeeds after each row
protected static int PFBQ
          binquad encoding
protected static int PFBT
          binary tree encoding
protected static int PFBYTE
          Bytes interpreted as unsigned integers
protected static int PFCHAIN
          Chain code encoding (Mimaging)
protected static int PFCOLVEC
          Set of RGB triplets defining colours
protected static int PFCOMPLEX
          2 Float's interpreted as (real,imaginary)
protected static int PFDBLCOM
          Double complex's (2 Double's)
protected static int PFDOUBLE
          Double's (8 byte floats)
protected static int PFDVFFT2D
          double complex 2D VFFT
protected static int PFDVFFT3D
          double complex 3D VFFT
protected static int PFDVVFFT3D
          double 3D VVFFT in separated planes
protected static int PFFLOAT
          Float's (4 bytes)
protected static int PFFLOATPYR
          float pyramid
protected static int PFGEN
          C3D template image
protected static int PFGRLE
          gray scale run-length encoding
protected static int PFHIST
          histogram of an image (using ints)
protected static int PFINT
          Integers (4 bytes)
protected static int PFINTPYR
          integer pyramid
protected static int PFLSBF
          packed, least-significant-bit first
protected static int PFLUT
          LUT format (uses Ints) (Mimaging)
protected static int PFMIXED
          multiple frames in different pixel formats
protected static int PFMSBF
          packed, most-significant-bit first
protected static int PFOCT
          oct-tree encoding
protected static int PFPOLAR
          rho-theta format (Mimaging)
protected static int PFPOLYLINE
          2D points
protected static int PFQUAD
          quad-tree encoding (Mimaging)
protected static int PFQUAD1
          quad-tree encoding
protected static int PFRGB
          RGBRGBRGB bytes
protected static int PFRGBZ
          RGB0RGB0RGB0 bytes
protected static int PFRGISPLINE
          2D points with regions and interfaces
protected static int PFRGPLINE
          2D points with regions
protected static int PFRLEB
          run-length encoding, line begins black
protected static int PFRLED
          run-length encoding
protected static int PFRLEW
          run-length encoding, line begins white
protected static int PFSBYTE
          signed bytes
protected static int PFSHORT
          Short integers (2 bytes)
protected static int PFSPAN
          spanning tree format
protected static int PFSRLE
          monochrome run-scale encoding
protected static int PFSTEREO
          Stereo sequence (l, r, l, r, ...)
protected static int PFUINT
          unsigned ints
protected static int PFUKOOA
          Data in standard UKOOA format
protected static int PFUSHORT
          unsigned shorts
protected static int PFVFFT2D
          float complex 2D virtual-very fast FT
protected static int PFVFFT3D
          float complex 3D virtual-very fast FT
protected static int PFVVFFT3D
          float 3D VFFT in separated planes
protected  int pixel_format_
           
protected static int PLOT3D
          plot-3d format
protected  int rows_
           
protected  java.lang.String seq_desc_
           
protected  java.lang.String seq_history_
           
protected  java.lang.String seq_name_
           
protected  int sizedesc_
           
protected  int sizehist_
           
 
Constructor Summary
protected HipsImage()
           
  HipsImage(HipsImage hdr)
          Costruct a copy of a header.
  HipsImage(java.io.InputStream in)
          Read HIPS header from an input stream.
  HipsImage(int w, int h, int nImages, int nFramesPerImage, int type)
           
  HipsImage(java.lang.String fileName)
          Read header from a file.
 
Method Summary
protected static int b2i(byte b)
           
protected  float bilinearInterp(float p00, float p01, float p10, float p11, float fracx, float fracy)
           
protected static int[] byte2pixels(byte[] red)
           
protected static int[] byte2pixels(byte[] red, byte[] green, byte[] blue)
           
 int cols()
          The number of columns (x values) in the region of interest
protected  void copyFrom(HipsImage hdr)
           
 int fcol()
          The first column in the region of interest (starting at 0)
protected  boolean finishLine(java.io.InputStream in)
           
 int frow()
          The first row of the region of interest (starting at 0)
 int getHeight()
          The number of rows in the image (y values)
 java.lang.String getParam(java.lang.String paramName)
          Get a parameter
 float[] getPixel(float x, float y, int imageIndex)
          Return the pixel at the specified location and in the specified image in the sequence.
 float[] getPixel(int x, int y, int imageIndex)
          Return the pixel at the specified location and in the specified image in the sequence.
 int getWidth()
          The number of columns in the image (x values)
protected static byte i2b(int i)
           
protected static int[] int2pixels(int[] red)
          Convert a pixel array in the range 0-255 into ARGB pixels.
protected static int[] int2pixels(int[] red, int[] green, int[] blue)
          This only works for ints in the range 0-255, and is available as a utility for subclasses to use.
 boolean isDataLoaded()
          Determine whether this header has image data associated with it.
 boolean isMSB()
          Get the special byteorder parameter If this predicate is true then the image is in MSB order.
static void main(java.lang.String[] args)
           
 int num_frame()
          The number of image frames in the image file
 int numcolor()
          The number of color frames per image
 int numImage()
          The number of images in the sequence
 int numparam()
          The number of image parameters
 int numpix()
          The number of pixels in an image frame
 java.lang.String orig_date()
          The creation date of the image
 java.lang.String orig_name()
          The name of the creator of the image
 java.util.Hashtable params()
          Hashtable containing the image parameters
 int pixel_format()
          Integer code of hte pixel format
protected  void readFrame(byte[] data, int sz, java.io.InputStream in)
           
protected  boolean readFromStream(java.io.InputStream in)
           
protected  java.lang.String readLine(java.io.InputStream ins)
           
 int[] rgbPixels(int imageIndex)
          Get a java compatible pixel array in the default ARGB int model
 int rows()
          The number of rows (y values) in the region of interest
 HipsImage scale(double xScale, double yScale)
           
 java.lang.String seq_desc()
          The image description string
 java.lang.String seq_history()
          The sequence history
 java.lang.String seq_name()
          The name of theis image sequence
 void setMSB(boolean tf)
           
 void setParam(java.lang.String paramName, java.lang.String value)
          Set a parameter
 int sizedesc()
          The size in bytes of the image description
 int sizehist()
          The length in bytes of the sequence history
 int sizeimage()
          The size in bytes of an image frame
 int sizepix()
          The size in bytes of an image pixel
 HipsImage subImage(int srcX, int srcY, int width, int height)
           
protected static void swab(byte[] buf, int off)
           
protected static void swab2(byte[] buf, int off)
           
protected  int writeBytes(java.io.OutputStream out, java.lang.String s)
           
protected  void writeData(java.io.OutputStream out)
           
protected  void writeFrame(byte[] data, int sz, java.io.OutputStream out)
           
protected  int writeLine(java.io.OutputStream out, java.lang.String s)
           
 void writeToFile(java.lang.String fileName)
          Write the image to a file, given by fileName.
 void writeToStream(java.io.OutputStream out)
          Write the image to a OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orig_name_

protected java.lang.String orig_name_

seq_name_

protected java.lang.String seq_name_

num_frame_

protected int num_frame_

orig_date_

protected java.lang.String orig_date_

orows_

protected int orows_

ocols_

protected int ocols_

rows_

protected int rows_

cols_

protected int cols_

frow_

protected int frow_

fcol_

protected int fcol_

pixel_format_

protected int pixel_format_

numcolor_

protected int numcolor_

sizehist_

protected int sizehist_

seq_history_

protected java.lang.String seq_history_

sizedesc_

protected int sizedesc_

seq_desc_

protected java.lang.String seq_desc_

params_

protected java.util.Hashtable params_

isDataLoaded_

protected boolean isDataLoaded_

PFBYTE

protected static final int PFBYTE
Bytes interpreted as unsigned integers

PFSHORT

protected static final int PFSHORT
Short integers (2 bytes)

PFINT

protected static final int PFINT
Integers (4 bytes)

PFFLOAT

protected static final int PFFLOAT
Float's (4 bytes)

PFCOMPLEX

protected static final int PFCOMPLEX
2 Float's interpreted as (real,imaginary)

PFASCII

protected static final int PFASCII
ASCII rep, with linefeeds after each row

PFDOUBLE

protected static final int PFDOUBLE
Double's (8 byte floats)

PFDBLCOM

protected static final int PFDBLCOM
Double complex's (2 Double's)

PFQUAD

protected static final int PFQUAD
quad-tree encoding (Mimaging)

PFQUAD1

protected static final int PFQUAD1
quad-tree encoding

PFHIST

protected static final int PFHIST
histogram of an image (using ints)

PFSPAN

protected static final int PFSPAN
spanning tree format

PLOT3D

protected static final int PLOT3D
plot-3d format

PFMSBF

protected static final int PFMSBF
packed, most-significant-bit first

PFLSBF

protected static final int PFLSBF
packed, least-significant-bit first

PFSBYTE

protected static final int PFSBYTE
signed bytes

PFUSHORT

protected static final int PFUSHORT
unsigned shorts

PFUINT

protected static final int PFUINT
unsigned ints

PFRGB

protected static final int PFRGB
RGBRGBRGB bytes

PFRGBZ

protected static final int PFRGBZ
RGB0RGB0RGB0 bytes

PFMIXED

protected static final int PFMIXED
multiple frames in different pixel formats

PFINTPYR

protected static final int PFINTPYR
integer pyramid

PFFLOATPYR

protected static final int PFFLOATPYR
float pyramid

PFPOLYLINE

protected static final int PFPOLYLINE
2D points

PFCOLVEC

protected static final int PFCOLVEC
Set of RGB triplets defining colours

PFUKOOA

protected static final int PFUKOOA
Data in standard UKOOA format

PFSTEREO

protected static final int PFSTEREO
Stereo sequence (l, r, l, r, ...)

PFRGPLINE

protected static final int PFRGPLINE
2D points with regions

PFRGISPLINE

protected static final int PFRGISPLINE
2D points with regions and interfaces

PFCHAIN

protected static final int PFCHAIN
Chain code encoding (Mimaging)

PFLUT

protected static final int PFLUT
LUT format (uses Ints) (Mimaging)

PFAHC

protected static final int PFAHC
adaptive hierarchical encoding

PFOCT

protected static final int PFOCT
oct-tree encoding

PFBT

protected static final int PFBT
binary tree encoding

PFAHC3

protected static final int PFAHC3
3-d adaptive hierarchical encoding

PFBQ

protected static final int PFBQ
binquad encoding

PFRLED

protected static final int PFRLED
run-length encoding

PFRLEB

protected static final int PFRLEB
run-length encoding, line begins black

PFRLEW

protected static final int PFRLEW
run-length encoding, line begins white

PFPOLAR

protected static final int PFPOLAR
rho-theta format (Mimaging)

PFGRLE

protected static final int PFGRLE
gray scale run-length encoding

PFSRLE

protected static final int PFSRLE
monochrome run-scale encoding

PFVFFT3D

protected static final int PFVFFT3D
float complex 3D virtual-very fast FT

PFVFFT2D

protected static final int PFVFFT2D
float complex 2D virtual-very fast FT

PFDVFFT3D

protected static final int PFDVFFT3D
double complex 3D VFFT

PFDVFFT2D

protected static final int PFDVFFT2D
double complex 2D VFFT

PFVVFFT3D

protected static final int PFVVFFT3D
float 3D VFFT in separated planes

PFDVVFFT3D

protected static final int PFDVVFFT3D
double 3D VVFFT in separated planes

PFGEN

protected static final int PFGEN
C3D template image

BUFSIZ

protected static final int BUFSIZ
Constructor Detail

HipsImage

public HipsImage(java.io.InputStream in)
          throws HipsException
Read HIPS header from an input stream. Image data is not read. The data is read in subclasses of HipsImage
Parameters:
in - The input data stream.

HipsImage

public HipsImage(java.lang.String fileName)
          throws HipsException,
                 java.io.FileNotFoundException,
                 java.io.IOException
Read header from a file. Image data is not read.
Parameters:
fileName - The input file name.

HipsImage

public HipsImage(HipsImage hdr)
Costruct a copy of a header.
Parameters:
hdr - The header to be copied from.

HipsImage

public HipsImage(int w,
                 int h,
                 int nImages,
                 int nFramesPerImage,
                 int type)

HipsImage

protected HipsImage()
Method Detail

copyFrom

protected void copyFrom(HipsImage hdr)

subImage

public HipsImage subImage(int srcX,
                          int srcY,
                          int width,
                          int height)

scale

public HipsImage scale(double xScale,
                       double yScale)

int2pixels

protected static final int[] int2pixels(int[] red,
                                        int[] green,
                                        int[] blue)
This only works for ints in the range 0-255, and is available as a utility for subclasses to use.

int2pixels

protected static final int[] int2pixels(int[] red)
Convert a pixel array in the range 0-255 into ARGB pixels. The integers must be in the range 0-255

byte2pixels

protected static final int[] byte2pixels(byte[] red,
                                         byte[] green,
                                         byte[] blue)

byte2pixels

protected static final int[] byte2pixels(byte[] red)

getPixel

public float[] getPixel(int x,
                        int y,
                        int imageIndex)
Return the pixel at the specified location and in the specified image in the sequence. The implementation here is a dummy that returns {0,0,0}. Subclasses should override this behaviour
Parameters:
x - The x-location (column) of the pixel
y - The y-location (row) of the pixel
imageIndex - The index of the image in the sequence (starting at 0) for which the pixel value is required.
Returns:
Three floating point numbers.

getPixel

public float[] getPixel(float x,
                        float y,
                        int imageIndex)
Return the pixel at the specified location and in the specified image in the sequence. The implementation here is a dummy that returns {0,0,0}. Subclasses should override this behaviour

Floating point numbers are returned in the case that a non-integral pixel location is chosen. In this case bilinear interpolation is used to obtain the value of the pixel.

Parameters:
x - The x-location (column) of the pixel
y - The y-location (row) of the pixel
imageIndex - The index of the image in the sequence (starting at 0) for which the pixel value is required.
Returns:
Three floating point numbers.

bilinearInterp

protected float bilinearInterp(float p00,
                               float p01,
                               float p10,
                               float p11,
                               float fracx,
                               float fracy)

b2i

protected static final int b2i(byte b)

i2b

protected static final byte i2b(int i)

isDataLoaded

public boolean isDataLoaded()
Determine whether this header has image data associated with it. This will only be true for sub-classes of HipsImage.

readFrame

protected void readFrame(byte[] data,
                         int sz,
                         java.io.InputStream in)
                  throws java.io.IOException

finishLine

protected boolean finishLine(java.io.InputStream in)
                      throws java.io.IOException

writeFrame

protected void writeFrame(byte[] data,
                          int sz,
                          java.io.OutputStream out)
                   throws java.io.IOException

orig_name

public java.lang.String orig_name()
The name of the creator of the image

seq_name

public java.lang.String seq_name()
The name of theis image sequence

num_frame

public int num_frame()
The number of image frames in the image file

orig_date

public java.lang.String orig_date()
The creation date of the image

getHeight

public int getHeight()
The number of rows in the image (y values)

getWidth

public int getWidth()
The number of columns in the image (x values)

rows

public int rows()
The number of rows (y values) in the region of interest

cols

public int cols()
The number of columns (x values) in the region of interest

frow

public int frow()
The first row of the region of interest (starting at 0)

fcol

public int fcol()
The first column in the region of interest (starting at 0)

pixel_format

public int pixel_format()
Integer code of hte pixel format

numcolor

public int numcolor()
The number of color frames per image

numImage

public int numImage()
The number of images in the sequence

numpix

public int numpix()
The number of pixels in an image frame

sizepix

public int sizepix()
The size in bytes of an image pixel

sizeimage

public int sizeimage()
The size in bytes of an image frame

sizehist

public int sizehist()
The length in bytes of the sequence history

seq_history

public java.lang.String seq_history()
The sequence history

sizedesc

public int sizedesc()
The size in bytes of the image description

seq_desc

public java.lang.String seq_desc()
The image description string

numparam

public int numparam()
The number of image parameters

params

public java.util.Hashtable params()
Hashtable containing the image parameters

getParam

public java.lang.String getParam(java.lang.String paramName)
Get a parameter

setParam

public void setParam(java.lang.String paramName,
                     java.lang.String value)
Set a parameter

isMSB

public boolean isMSB()
Get the special byteorder parameter If this predicate is true then the image is in MSB order. If the predicate is false, it could be LSB or MSB.

setMSB

public void setMSB(boolean tf)

rgbPixels

public int[] rgbPixels(int imageIndex)
                throws HipsException
Get a java compatible pixel array in the default ARGB int model

readFromStream

protected boolean readFromStream(java.io.InputStream in)

writeToFile

public void writeToFile(java.lang.String fileName)
                 throws java.io.IOException
Write the image to a file, given by fileName. The image is written in standard HIPS2 format. The only difference between this and the standard HIPS2 format is that all paramters are stored as Strings, and were so converted when read in.
Parameters:
fileName - A String representing the name of the file in the local file system

writeToStream

public void writeToStream(java.io.OutputStream out)
                   throws java.io.IOException
Write the image to a OutputStream. The image is written in standard HIPS2 format. The only difference between this and the standard HIPS2 format is that all paramters are stored as Strings, and were so converted when read in.
Parameters:
fileName - A String representing the name of the file in the local file system

writeLine

protected final int writeLine(java.io.OutputStream out,
                              java.lang.String s)
                       throws java.io.IOException

writeBytes

protected final int writeBytes(java.io.OutputStream out,
                               java.lang.String s)
                        throws java.io.IOException

readLine

protected final java.lang.String readLine(java.io.InputStream ins)
                                   throws java.io.IOException

swab

protected static final void swab(byte[] buf,
                                 int off)

swab2

protected static final void swab2(byte[] buf,
                                  int off)

main

public static void main(java.lang.String[] args)

writeData

protected void writeData(java.io.OutputStream out)
                  throws java.io.IOException