com.c3d.image
Class Jimage

java.lang.Object
  |
  +--com.c3d.image.Jimage
Direct Known Subclasses:
ByteImage, FloatImage, ShortImage

public abstract class Jimage
extends java.lang.Object
implements com.c3d.structured.Subscriptable, java.awt.image.ImageConsumer, com.c3d.structured.Struct, com.c3d.util.atomic.Universal

TeX \def\frac#1#2{(#1)\div(#2)} The class Jimage\footnote{\copyright Turing Institute, 1998} is an abstract class to support image processing operations. It also implements the java.awt ImageConsumer class enabling it to be loaded with image data from the java system. If Jimages are to be displayed, one obtains a statdard awt ImageProducer from the Jimage useing the {\tt getProducer} method. This can then be used to construct images that can be displayed in java awt windows. \subsection*{Numeric representation of pixels } The Java language only supports signed bytes and signed shorts. The internal representation of pixels is therefore always as signed numbers. Since the accuracy to which pixels are stored may vary between subclasses of the Jimage type, the following conventions are addopted. \begin{enumerate} \item When pixels are treated as real numbers, they are considered to be in the range $-1.0$ to plus $1.0$. All arithmetic operations on pixels should be compatible with this model. \item When 8 bit pixel data is input to the Jimage from the Java AWT, the 8 bit AWT data is interpreted such that a pixel value of 0 is treated as equal to -1.0 and a pixel value of 255 is treated as equal to 1.0. \item When data is stored internally as 16 bit pixels, these are treated as fixed point signed binary fractions. \end{enumerate} \begin{table} \caption{Table mapping different representations of pixels } \label{pixrep} \begin{tabular}{lrrrr} &unsigned& bytes& shorts& float\\ min value& 0 &-128& -2048& 0\\ maxval& 255& 127& 20477 &1\\ medianval $\mu$&127.5& -0.5 &-0.5 &0\\ range $\rho$&255 &255 &255 &1\\ \end{tabular} \end{table} As shown in table \ref{pixref} a pixel $p_r$in representation r is converted to a pixel $P_s$ in representation s by the operation: $$p_s=\mu_s+\frac{\rho_s(p_r-\mu_r)}{\rho_r}$$


Field Summary
static int ALPHAPLANE
           
static int BLUEPLANE
           
static int brho
          TeX signed byte pixel range
 java.awt.image.ColorModel colorModel
           
static float fmax
           
static float fmin
           
static float fmu
          TeX float median
static float frho
           
static int GREENPLANE
           
 int height
          TeX The number of pixels high and wide that the image occupies.
 int hints
          TeX required by image consumer but not used
static int MONOCHROME
           
 int planes
          TeX The number of pixels high and wide that the image occupies.
static int REDPLANE
           
static int RGB
           
static int smax
           
static int smin
           
static int srho
          TeX signed short pixel range
static int umin
          TeX lowest value of an unsigned pixel
static int urho
          TeX unsigned byte pixel range
 int width
          TeX The number of pixels high and wide that the image occupies.
 
Constructor Summary
Jimage()
           
 
Method Summary
abstract  Jimage abs()
           
 int arity()
          TeX Returns the number of planes in an image.
static float bpixelTofpixel(byte bpixel)
           
static short bpixelTospixel(short b)
           
static int bpixelToupixel(byte b)
           
static byte bsaturate(double i)
          TeX Return i in the range of byte pixels
 double cardinality()
          TeX Returns the number of pixels in an image
 com.c3d.util.atomic.Universal concat(com.c3d.util.atomic.Universal b)
           
 Jimage convolve(double[] k)
          TeX convolve with symetrical seperable kernel.
abstract  Jimage convolve(double[][] kernel)
           
 com.c3d.util.atomic.Universal divide(double n)
           
 float fmodulus()
          TeX Denote x.fmodulus() by $|x|$.
abstract  float fpixel(int x, int y, int plane)
          TeX Returns the pixel in the range -1 to +1.
static byte fpixelTobpixel(float fpixel)
           
static short fpixelTospixel(float fpixel)
          TeX $$p_s=\mu_s+\frac{\rho_s(p_r-\mu_r)}{\rho_r}$$
static int fpixelToupixel(float fpixel)
           
static float fsaturate(double i)
           
static float fsaturate(float i)
          TeX return i within the range of float pixels $(ifmax?fmax:i))$
 java.awt.Image getAWTImage()
           
 boolean getImage(java.lang.String fileName)
          TeX Load the image from the specified file.
 java.awt.image.ImageProducer getProducer()
           
 Jimage getScaledInstance(int nwidth, int nheight)
          TeX This replicates the functionality of the get scaled instance method of the AWT image class.
 Jimage getScaledInstance(int nwidth, int nheight, int ndepth)
          TeX This method allows the depth as well as area of an image to be altered if it is reduced the planes are aggregated if increased they are interpolated
 int hashCode()
           
 void imageComplete(int s)
           
 float l1Norm()
          TeX first sum the planes to a grey scale image and then return the sum of the absolute values of the pixels
 float l2Norm()
          TeX first sum the planes to a grey scale image and then return the sqrt of the sum of the squared values of the pixels
 boolean lessthan(com.c3d.util.atomic.Universal b)
          TeX one image less than another if all pixels less than corresponding ones, thus it can be implemented by injecting $<$ between the elements of a and b, and then applying $\times/$ to the result
 java.util.Enumeration members()
          TeX The members ar the planes, so that $op / i$ for i an image will reduce the image to one with a single plane
 com.c3d.util.atomic.Universal minus(double n)
           
 com.c3d.util.atomic.Numeric modulus()
           
 com.c3d.util.atomic.Numeric numberOfElements()
          TeX {\bf Methods implementing Struct}
abstract  Jimage oneOfThese()
          TeX Returns an instance of the particular sub class of images to which the parent belongs
 com.c3d.util.atomic.Universal plus(double n)
           
 void putJPEGImage(java.lang.String fileName, int quality)
          TeX Outputs the image to a jpeg file
 com.c3d.util.atomic.Universal reduce(com.c3d.operators.Doperator op)
           
 Jimage RGB2YUV()
          TeX $$ y=0.6 g + 0.3 r + 0.1 b$$ $$u = b-y$$ $$0=r-y-v$$
 int rgbpixel(int x, int y)
          TeX Converts the plane information into a pixel in the direct colour model of java.
 void setColorModel(java.awt.image.ColorModel cm)
           
 void setHints(int h)
           
abstract  void setPixel(int x, int y, int plane, double pix)
           
 void setPixel(int x, int y, int plane, int p)
           
 void setPixel(int x, int y, int plane, short p)
           
 void setProperties(java.util.Hashtable props)
           
 void setSubImage(int x, int y, int z, Jimage im)
          TeX Update an area of an image with another one.
 Jimage shift(int i)
           
abstract  short spixel(int x, int y, int plane)
          TeX return signed short pixel
static byte spixelTobpixel(short s)
          TeX convert a 12 bit short pixel to a signed byte
static float spixelTofpixel(int spixel)
           
static float spixelTofpixel(short spixel)
           
static int spixelToupixel(int spixel)
          TeX convert short pixel to unsigned
 Jimage sqr()
           
static short ssaturate(double i)
          TeX Return i in the rang eof short pixels
abstract  Jimage subImage(int x, int y, int dx, int dy)
           
 com.c3d.util.atomic.Universal subscript(int i)
          TeX Returns the ith plane
 com.c3d.util.atomic.Universal subscript(com.c3d.util.atomic.Universal I)
          TeX Subscription by a number returns the Ith plane of the image.
 float sum(int z)
          TeX Return the sum of the floating point pixels in the z plane
 com.c3d.util.atomic.Universal times(double n)
           
 java.lang.String toString()
           
 java.lang.String toString(char c)
           
abstract  int upixel(int x, int y, int plane)
           
abstract  com.c3d.util.atomic.Universal Upixel(int x, int y, int plane)
           
static byte upixelTobpixel(int upixel)
           
static float upixelTofpixel(int upixel)
           
static short upixelTospixel(int upixel)
          TeX convert short pixel from unsigned
static int usaturate(double i)
           
 Jimage warp(Jimage dx, Jimage dy)
          TeX Images dx and dy contain the discrepancy in x and y positions from which source pixels to be obtained let $r$ be the result, $s$ the source then $$r_{i,j}=s_{i+dx_{i,j},j+dy_{i,j}}$$
 Jimage YUV2RGB()
          TeX $$b=u+y$$ $$r=u+v$$ $$g=(y-0.3r-0.1b)/0.6$$
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

umin

public static final int umin
TeX lowest value of an unsigned pixel

smin

public static final int smin

fmin

public static final float fmin

smax

public static final int smax

fmax

public static final float fmax

urho

public static final int urho
TeX unsigned byte pixel range

brho

public static final int brho
TeX signed byte pixel range

srho

public static final int srho
TeX signed short pixel range

frho

public static final float frho

fmu

public static final float fmu
TeX float median

hints

public int hints
TeX required by image consumer but not used

colorModel

public java.awt.image.ColorModel colorModel

height

public int height
TeX The number of pixels high and wide that the image occupies.

width

public int width
TeX The number of pixels high and wide that the image occupies.

planes

public int planes
TeX The number of pixels high and wide that the image occupies.

REDPLANE

public static final int REDPLANE

GREENPLANE

public static final int GREENPLANE

BLUEPLANE

public static final int BLUEPLANE

ALPHAPLANE

public static final int ALPHAPLANE

MONOCHROME

public static final int MONOCHROME

RGB

public static final int RGB
Constructor Detail

Jimage

public Jimage()
Method Detail

fpixelTobpixel

public static byte fpixelTobpixel(float fpixel)

spixelTobpixel

public static final byte spixelTobpixel(short s)
TeX convert a 12 bit short pixel to a signed byte

bpixelTospixel

public static final short bpixelTospixel(short b)

bpixelToupixel

public static int bpixelToupixel(byte b)

upixelTobpixel

public static byte upixelTobpixel(int upixel)

upixelTospixel

public static short upixelTospixel(int upixel)
TeX convert short pixel from unsigned

spixelToupixel

public static int spixelToupixel(int spixel)
TeX convert short pixel to unsigned

upixelTofpixel

public static float upixelTofpixel(int upixel)

bpixelTofpixel

public static float bpixelTofpixel(byte bpixel)

fpixelTospixel

public static short fpixelTospixel(float fpixel)
TeX $$p_s=\mu_s+\frac{\rho_s(p_r-\mu_r)}{\rho_r}$$

spixelTofpixel

public static float spixelTofpixel(int spixel)

fpixelToupixel

public static int fpixelToupixel(float fpixel)

spixelTofpixel

public static float spixelTofpixel(short spixel)

fsaturate

public static float fsaturate(float i)
TeX return i within the range of float pixels $(ifmax?fmax:i))$

fsaturate

public static float fsaturate(double i)

bsaturate

public static byte bsaturate(double i)
TeX Return i in the range of byte pixels

ssaturate

public static short ssaturate(double i)
TeX Return i in the rang eof short pixels

usaturate

public static int usaturate(double i)

fpixel

public abstract float fpixel(int x,
                             int y,
                             int plane)
TeX Returns the pixel in the range -1 to +1.

spixel

public abstract short spixel(int x,
                             int y,
                             int plane)
TeX return signed short pixel

setPixel

public abstract void setPixel(int x,
                              int y,
                              int plane,
                              double pix)

setPixel

public void setPixel(int x,
                     int y,
                     int plane,
                     int p)

setPixel

public void setPixel(int x,
                     int y,
                     int plane,
                     short p)

upixel

public abstract int upixel(int x,
                           int y,
                           int plane)

rgbpixel

public int rgbpixel(int x,
                    int y)
TeX Converts the plane information into a pixel in the direct colour model of java. It has to convert from the signed form of pixels to an unsigned representation before packing into an integer. If the image is monochrome return the same brightness in all of the portions of the pixel

warp

public Jimage warp(Jimage dx,
                   Jimage dy)
            throws java.lang.CloneNotSupportedException
TeX Images dx and dy contain the discrepancy in x and y positions from which source pixels to be obtained let $r$ be the result, $s$ the source then $$r_{i,j}=s_{i+dx_{i,j},j+dy_{i,j}}$$

Upixel

public abstract com.c3d.util.atomic.Universal Upixel(int x,
                                                     int y,
                                                     int plane)

convolve

public abstract Jimage convolve(double[][] kernel)

convolve

public Jimage convolve(double[] k)
TeX convolve with symetrical seperable kernel.

abs

public abstract Jimage abs()

subImage

public abstract Jimage subImage(int x,
                                int y,
                                int dx,
                                int dy)

setSubImage

public void setSubImage(int x,
                        int y,
                        int z,
                        Jimage im)
TeX Update an area of an image with another one. The other one must not run off the edge of the one being written to. The source of the copying is the 0th plane of the source jimage.

sqr

public Jimage sqr()

l1Norm

public float l1Norm()
TeX first sum the planes to a grey scale image and then return the sum of the absolute values of the pixels

l2Norm

public float l2Norm()
TeX first sum the planes to a grey scale image and then return the sqrt of the sum of the squared values of the pixels

sum

public float sum(int z)
TeX Return the sum of the floating point pixels in the z plane

fmodulus

public float fmodulus()
TeX Denote x.fmodulus() by $|x|$. Returns the square root of the sum of values of the pixels
Specified by:
fmodulus in interface com.c3d.structured.Struct

members

public java.util.Enumeration members()
TeX The members ar the planes, so that $op / i$ for i an image will reduce the image to one with a single plane
Specified by:
members in interface com.c3d.structured.Struct

RGB2YUV

public Jimage RGB2YUV()
TeX $$ y=0.6 g + 0.3 r + 0.1 b$$ $$u = b-y$$ $$0=r-y-v$$

YUV2RGB

public Jimage YUV2RGB()
TeX $$b=u+y$$ $$r=u+v$$ $$g=(y-0.3r-0.1b)/0.6$$

getAWTImage

public java.awt.Image getAWTImage()

getProducer

public java.awt.image.ImageProducer getProducer()

oneOfThese

public abstract Jimage oneOfThese()
TeX Returns an instance of the particular sub class of images to which the parent belongs

getScaledInstance

public Jimage getScaledInstance(int nwidth,
                                int nheight,
                                int ndepth)
TeX This method allows the depth as well as area of an image to be altered if it is reduced the planes are aggregated if increased they are interpolated

getScaledInstance

public Jimage getScaledInstance(int nwidth,
                                int nheight)
TeX This replicates the functionality of the get scaled instance method of the AWT image class.

getImage

public boolean getImage(java.lang.String fileName)
TeX Load the image from the specified file. The file must be jpeg or gif.

putJPEGImage

public void putJPEGImage(java.lang.String fileName,
                         int quality)
                  throws java.io.IOException
TeX Outputs the image to a jpeg file

setProperties

public void setProperties(java.util.Hashtable props)
Specified by:
setProperties in interface java.awt.image.ImageConsumer

setHints

public void setHints(int h)
Specified by:
setHints in interface java.awt.image.ImageConsumer

setColorModel

public void setColorModel(java.awt.image.ColorModel cm)
Specified by:
setColorModel in interface java.awt.image.ImageConsumer

imageComplete

public void imageComplete(int s)
Specified by:
imageComplete in interface java.awt.image.ImageConsumer

subscript

public com.c3d.util.atomic.Universal subscript(com.c3d.util.atomic.Universal I)
TeX Subscription by a number returns the Ith plane of the image. Subscription by a 3tuple returns the pixel at position [plane,x,y]. All other case raise an array bounds exception.
Specified by:
subscript in interface com.c3d.structured.Subscriptable

subscript

public com.c3d.util.atomic.Universal subscript(int i)
TeX Returns the ith plane
Specified by:
subscript in interface com.c3d.structured.Subscriptable

arity

public int arity()
TeX Returns the number of planes in an image.
Specified by:
arity in interface com.c3d.structured.Subscriptable

cardinality

public double cardinality()
TeX Returns the number of pixels in an image
Specified by:
cardinality in interface com.c3d.structured.Struct

lessthan

public boolean lessthan(com.c3d.util.atomic.Universal b)
TeX one image less than another if all pixels less than corresponding ones, thus it can be implemented by injecting $<$ between the elements of a and b, and then applying $\times/$ to the result
Specified by:
lessthan in interface com.c3d.util.atomic.Universal

shift

public Jimage shift(int i)

numberOfElements

public com.c3d.util.atomic.Numeric numberOfElements()
TeX {\bf Methods implementing Struct}
Specified by:
numberOfElements in interface com.c3d.structured.Struct

toString

public java.lang.String toString(char c)
Specified by:
toString in interface com.c3d.util.atomic.Universal

toString

public java.lang.String toString()
Specified by:
toString in interface com.c3d.util.atomic.Universal
Overrides:
toString in class java.lang.Object

modulus

public com.c3d.util.atomic.Numeric modulus()
Specified by:
modulus in interface com.c3d.structured.Struct

reduce

public com.c3d.util.atomic.Universal reduce(com.c3d.operators.Doperator op)
Specified by:
reduce in interface com.c3d.structured.Struct

hashCode

public int hashCode()
Specified by:
hashCode in interface com.c3d.structured.Struct
Overrides:
hashCode in class java.lang.Object

times

public com.c3d.util.atomic.Universal times(double n)
Specified by:
times in interface com.c3d.structured.Struct

plus

public com.c3d.util.atomic.Universal plus(double n)
Specified by:
plus in interface com.c3d.structured.Struct

minus

public com.c3d.util.atomic.Universal minus(double n)
Specified by:
minus in interface com.c3d.structured.Struct

divide

public com.c3d.util.atomic.Universal divide(double n)
Specified by:
divide in interface com.c3d.structured.Struct

concat

public com.c3d.util.atomic.Universal concat(com.c3d.util.atomic.Universal b)
Specified by:
concat in interface com.c3d.structured.Struct