optics
Class OpticalImage

java.lang.Object
  extended by optics.Optics
      extended by optics.OpticalSurface
          extended by optics.OpticalPlane
              extended by optics.OpticalImage
All Implemented Interfaces:
Diagram2DComponent
Direct Known Subclasses:
WaveFrontImage

public class OpticalImage
extends OpticalPlane

Class to implement an OpticalImage, being a OpticalPlane conatining an image. The actual image is held as two-dimensional RealDataArray from jfftw, so held as double[] array.


Field Summary
protected  ColourScale colourScale
          Colourscale used for image display
protected  jfftw.RealDataArray data
          The image RealDataArray.
protected  Grid grid
          The image grid giving sampling and size information
protected  double max
          Maximum value of the image
protected  double waveLength
          Image wavelength, defaults to GREEN
 
Fields inherited from class optics.OpticalPlane
blockedNormal, maxRadius, planeNormal
 
Fields inherited from class optics.OpticalSurface
CLEAR, group, REFLECTING, REFRACTING, refractiveIndex, surfacePoint, surfaceType
 
Fields inherited from class optics.Optics
DEFAULT_WAVELENGTH, errorStream, fmt, MICRONS
 
Constructor Summary
OpticalImage(double z, int w, int h)
          Form a OpticalImage with specified position, size and sampling interval defaults to unity
OpticalImage(Position p, java.awt.image.BufferedImage bi, int band, double dx, double dy)
          Form an OpticalImage with specfied position and load a band of a BufferedImage.
OpticalImage(Position p, int w, int h)
          Forms an OpticalImage with specified position, size and sampling interval defaults to unity.
OpticalImage(Position p, int w, int h, double dx, double dy)
          Form a OpticalImage with specified reference point, sizrand sampling interval.
OpticalImage(Position p, jfftw.RealDataArray da, double dx, double dy)
          Forms an OpticalImage from a RealDataArray, which is assumed to be two-dimensional.
 
Method Summary
 void add(int i, int j, double value)
          Method to add to the specifed pixel value
 boolean add(javax.vecmath.Point2d p, double value)
          Method to add a value to the closest pixel to the point in the plane taking into account samplein and the image centre.
 void add(javax.vecmath.Point2i pt, double value)
          Method to add to the specifed pixel value
 boolean add(Ray ray)
          Boolean method to add an Intensity ray, returns true to ray strikes the plane withinside the image.
 int add(RayPencil pencil)
          Method to add IntensityRaypencil to the OpticalImage and return the number of ray sucessfully added
 void calculateIntensityRange()
          Method to calcuate the intensity range
 void clear()
          Method to clear the image data by setting it to zero.
 void draw(java.awt.Graphics2D g)
          Overload of draw method to draw plane of correct height.
 java.awt.image.BufferedImage getBufferedImage()
          Method to get the image as a displayable BufferedImage of type double.
 ColourScale getColourScale()
          Method get the colour scale, may be null if not set.
 jfftw.RealDataArray getDataArray()
          Method get the underlying RealDataArray
 Grid getGrid()
          Method to get the image grid giving size and sampling parameters.
 int getHeight()
          Method get the height of the image
 javax.vecmath.Point2d getLocation(int i, int j)
          Method to get the two-dimensional location of the specified pixel in plane.
 javax.vecmath.Point2d getLocation(javax.vecmath.Point2i p)
          Method to get the location of the specified pixel in the plane
 double getMaxIntensity()
          Method to get the Maximum intensity in the OpticalImage
 double getMaxRadius()
          Method to get the maximum radius of the plane.
 double getMinIntensity()
          Method to get the Minumum intensity in the OpticalImage
 double getPixel(int i, int j)
          Method to get the specified value
 double getPixel(javax.vecmath.Point2d p)
          Get the pixel value closes to the specifed Point2d taking the sample interval and centre into account.
 double getPixel(javax.vecmath.Point2i pt)
          Method to get the specified value
 Position getPosition(int i, int j)
          Method to get the position of the specifed pixel as a three-dimensional Poistion.
 Position getPosition(javax.vecmath.Point2i p)
          Method to get the Position of the specifed pixel as a three-dimensional Poistion
 javax.vecmath.Point2i getSample(javax.vecmath.Point2d p)
          Get the pixel location closest to the specified Point2d taking sample interval and centre into account.
 SourcePoint getSourcePoint(int i, int j)
          Method to get a SourcePoint for specied pixel with fixed brightness given by the pixel value.
 SourcePoint getSourcePoint(javax.vecmath.Point2i pt)
          Method to get a SourcePoint for specied pixel with fixed brightness given by the pixel value.
 double getWaveLength()
          Method to get the wavelength
 int getWidth()
          Method get the width of the image
 OpticalImage imagedThrough(LensSystem lens, double imagePlane, double mag, int raysPerPixel)
          Method to image the OpticalImage through a given OpticalGroup The current plane of the OpticalImage is used as the object plane.
 OpticalImage imagedThrough(LensSystem lens, double mag, int raysPerPixel)
          Method to image the Optical Image through a given OpticalGroup at a given magnification.
 void setColourScale(ColourScale cs)
          Method to set the colour scale for display
 void setPixel(int i, int j, double value)
          Method to set the specifed pixel.
 void setPixel(javax.vecmath.Point2i pt, double value)
          Method to set the specifed pixel.
 void setRange(double xSize, double ySize)
          Method to set the sample grid by specifing the image size.
 void setSampleGrid(double dx, double dy)
          Method to set the sample grid.
 void setSurfacePoint(Position p)
          Overloaded method to set the surface point also sets the grid centre.
 void setTestGrid(int xgap, int ygap)
          Method to build a test grid with a series of white lines of unit intensity and one pixel wide.
 void setWaveLength(double lambda)
          Method to set the wavelength
 
Methods inherited from class optics.OpticalPlane
clone, distance, getBounds, getCurvature, getEdgePlane, getNormal, getPlaneNormal, pointInPlane, scale, setMaxRadius, setPlaneNormal, toString
 
Methods inherited from class optics.OpticalSurface
distance, edit, entranceAperture, exitAperture, fromString, fromTokens, getGroup, getIndex, getNormal, getPoint, getRefractiveIndex, getSurfacePoint, getSurfaceType, getSurfaceType, makeStandAlone, pointInPlane, setGroup, setRefractiveIndex, setSurfaceType
 
Methods inherited from class optics.Optics
getDefaultWaveLength, getErrorStream, getFormatString, getName, getStaticName, getVersion, printError, setDefaultWaveLength, setErrorStream, setFormatString, setMicrons
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

grid

protected Grid grid
The image grid giving sampling and size information


data

protected jfftw.RealDataArray data
The image RealDataArray.


waveLength

protected double waveLength
Image wavelength, defaults to GREEN


colourScale

protected ColourScale colourScale
Colourscale used for image display


max

protected double max
Maximum value of the image

Constructor Detail

OpticalImage

public OpticalImage(Position p,
                    int w,
                    int h,
                    double dx,
                    double dy)
Form a OpticalImage with specified reference point, sizrand sampling interval. The image data is pre-set to zero.

Parameters:
p - the surface point, also specifes the image centre.
w - the width of the image in pixels
h - the height of the image in pixels
dx - the x sample interval
dy - the y sample internal

OpticalImage

public OpticalImage(Position p,
                    jfftw.RealDataArray da,
                    double dx,
                    double dy)
Forms an OpticalImage from a RealDataArray, which is assumed to be two-dimensional.

Parameters:
p - the surface point, also specifies the image centre.
da - the RealDataArray holding the data (not copied)
dx - the x sample internal.
dy - the y sample internal.

OpticalImage

public OpticalImage(Position p,
                    int w,
                    int h)
Forms an OpticalImage with specified position, size and sampling interval defaults to unity.

Parameters:
p - the surface point
w - the width of the image in pixels
h - the height of the image in pixels

OpticalImage

public OpticalImage(double z,
                    int w,
                    int h)
Form a OpticalImage with specified position, size and sampling interval defaults to unity

Parameters:
z - location of the OpticalImage
w - the width of the image in pixels
h - the height of the image in pixels

OpticalImage

public OpticalImage(Position p,
                    java.awt.image.BufferedImage bi,
                    int band,
                    double dx,
                    double dy)
Form an OpticalImage with specfied position and load a band of a BufferedImage. If the band specifed is not legal, then the centre band is taken automatically.

Parameters:
p - the poisition
bi - the BufferedImage
band - the image band.
dx - x sample interval.
dy - y sample interval.
Method Detail

setSampleGrid

public void setSampleGrid(double dx,
                          double dy)
Method to set the sample grid.

Parameters:
dx - x sample interval
dy - y sample interval

setRange

public void setRange(double xSize,
                     double ySize)
Method to set the sample grid by specifing the image size.

Parameters:
xSize - the horizontal size
ySize - the verstical size.

setSurfacePoint

public void setSurfacePoint(Position p)
Overloaded method to set the surface point also sets the grid centre.

Overrides:
setSurfacePoint in class OpticalSurface
Parameters:
p - the Surface point

getWidth

public int getWidth()
Method get the width of the image

Returns:
int width of the image

getHeight

public int getHeight()
Method get the height of the image

Returns:
int width of the image

getMaxRadius

public double getMaxRadius()
Method to get the maximum radius of the plane.

Overrides:
getMaxRadius in class OpticalPlane
Returns:
double The Maximum radius

setWaveLength

public void setWaveLength(double lambda)
Method to set the wavelength


getWaveLength

public double getWaveLength()
Method to get the wavelength

Returns:
double the wavelength

getDataArray

public jfftw.RealDataArray getDataArray()
Method get the underlying RealDataArray

Returns:
RealDataArray the underlying RealDataArray.

getGrid

public Grid getGrid()
Method to get the image grid giving size and sampling parameters.

Returns:
Grid the image grid.

clear

public void clear()
Method to clear the image data by setting it to zero.


setColourScale

public void setColourScale(ColourScale cs)
Method to set the colour scale for display

Parameters:
cs - the ColourScale

getColourScale

public ColourScale getColourScale()
Method get the colour scale, may be null if not set.

Returns:
ColourScale the current colourscale

setPixel

public void setPixel(int i,
                     int j,
                     double value)
Method to set the specifed pixel.

Parameters:
i - the i pixel index
j - the j pixel index
value - the value

setPixel

public void setPixel(javax.vecmath.Point2i pt,
                     double value)
Method to set the specifed pixel.

Parameters:
pt - the pxel location
value - the value

getPixel

public double getPixel(int i,
                       int j)
Method to get the specified value

Parameters:
i - the i pixel index
j - the j pixel index
Returns:
double the pixel value

getPixel

public double getPixel(javax.vecmath.Point2i pt)
Method to get the specified value

Parameters:
pt - pixel location
Returns:
double the pixel value

getPosition

public Position getPosition(int i,
                            int j)
Method to get the position of the specifed pixel as a three-dimensional Poistion.

Parameters:
i - the i pixel index
j - the j pixel index
Returns:
Position the Position

getPosition

public Position getPosition(javax.vecmath.Point2i p)
Method to get the Position of the specifed pixel as a three-dimensional Poistion

Parameters:
p - the Pixel location
Returns:
Position the Position

getSourcePoint

public SourcePoint getSourcePoint(int i,
                                  int j)
Method to get a SourcePoint for specied pixel with fixed brightness given by the pixel value.

Parameters:
i - the i pixel index
j - the j pixel index
Returns:
SourcePoint of the specified pixel.

getSourcePoint

public SourcePoint getSourcePoint(javax.vecmath.Point2i pt)
Method to get a SourcePoint for specied pixel with fixed brightness given by the pixel value.

Parameters:
pt - the pixel location
Returns:
SourcePoint of the specified pixel.

getLocation

public javax.vecmath.Point2d getLocation(int i,
                                         int j)
Method to get the two-dimensional location of the specified pixel in plane.

Parameters:
i - the i pixel index
j - the j pixel index
Returns:
Point2d the location.

getLocation

public javax.vecmath.Point2d getLocation(javax.vecmath.Point2i p)
Method to get the location of the specified pixel in the plane

Parameters:
p - pixel index.
Returns:
Point2d the location.

getSample

public javax.vecmath.Point2i getSample(javax.vecmath.Point2d p)
Get the pixel location closest to the specified Point2d taking sample interval and centre into account. This will be -1 if outside image

Parameters:
p - the point
Returns:
Point2i the pixel location

getPixel

public double getPixel(javax.vecmath.Point2d p)
Get the pixel value closes to the specifed Point2d taking the sample interval and centre into account. The returned value will be Double.NaN if it is outsize the image.

Parameters:
p - the point in the plane

add

public void add(int i,
                int j,
                double value)
Method to add to the specifed pixel value

Parameters:
i - the x pixel location
j - the j pixel location
value - value to be added

add

public void add(javax.vecmath.Point2i pt,
                double value)
Method to add to the specifed pixel value

Parameters:
pt - the pixel location
value - to be addeed

add

public boolean add(javax.vecmath.Point2d p,
                   double value)
Method to add a value to the closest pixel to the point in the plane taking into account samplein and the image centre.

Parameters:
p - the point in the image
value - the avlue to be added
Returns:
boolean true if within the image, else false.

add

public boolean add(Ray ray)
Boolean method to add an Intensity ray, returns true to ray strikes the plane withinside the image.

Not the ray is not propagated to the plane.

Parameters:
ray - the Intensity ray to be added.
Returns:
boolean true if inside image.

add

public int add(RayPencil pencil)
Method to add IntensityRaypencil to the OpticalImage and return the number of ray sucessfully added

Parameters:
pencil - the Raypencil
Returns:
int number of rays sucessfully added.

calculateIntensityRange

public void calculateIntensityRange()
Method to calcuate the intensity range

See Also:
getMaxIntensity(), getMinIntensity()

getMaxIntensity

public double getMaxIntensity()
Method to get the Maximum intensity in the OpticalImage

Returns:
double the maximum value

getMinIntensity

public double getMinIntensity()
Method to get the Minumum intensity in the OpticalImage

Returns:
double the minumum value

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Method to get the image as a displayable BufferedImage of type double. If the colourscale is not pretset it will deafult to a linear grey scale.

Note the actual data array is ued to make the displayable raster.

Returns:
BufferedImage displayable buffered image.

setTestGrid

public void setTestGrid(int xgap,
                        int ygap)
Method to build a test grid with a series of white lines of unit intensity and one pixel wide.

Parameters:
xgap - the x separation.
ygap - the y separation.

imagedThrough

public OpticalImage imagedThrough(LensSystem lens,
                                  double mag,
                                  int raysPerPixel)
Method to image the Optical Image through a given OpticalGroup at a given magnification. The location of the object and image planes are calculated using paraxial ray optics.

The reference point of the current optical image is set to the object plane.

Parameters:
lens - the Lens system
mag - the linear magnification
raysPerPixel - rays traced per pixel

imagedThrough

public OpticalImage imagedThrough(LensSystem lens,
                                  double imagePlane,
                                  double mag,
                                  int raysPerPixel)
Method to image the OpticalImage through a given OpticalGroup The current plane of the OpticalImage is used as the object plane. The output image is scaled by the magnification factor.

For large images and large number of rays this calcualtion can be rather slow.

Parameters:
lens - the optical group
imagePlane - Location of image plane
mag - magnification (used to scale output image only)
raysPerPixel - rays traced per pixels
Returns:
OpticalImage the image.

draw

public void draw(java.awt.Graphics2D g)
Overload of draw method to draw plane of correct height.

Specified by:
draw in interface Diagram2DComponent
Overrides:
draw in class OpticalPlane
Parameters:
g - the Graphics2D