vec_math
Class ImageMoments

java.lang.Object
  extended by vec_math.ImageMoments
All Implemented Interfaces:
Serializable

public class ImageMoments
extends Object
implements Serializable

Similar to one-dimension power sums or CentralMoments this class calculates image moments meaning statistic properties in a two-dimensional image. Suppose you have an array of pixel values I_ij = I(x,y) Sampled at integer x/y pixel values, thus representable as a two-dimensional double array ADU[y][x] like returned from astro.fits.FitsTools#getAsArray (note the counter-intuitive indexing within the array; this stems from the FITS standard. Passing this to the constructor of this class immediately calculates I_0, x_c and y_c via the formulars:

   I_0=ΣADU_ij,
xc=Σ(x_ij·ADU_ij)/I_0,
yc=Σ(y_ij·ADU_ij)/I_0.
Further calls to #getImageMoment first check, if the moment to n,k has already been cached, otherwise it is calculated according to M_nk=Σ(x_ij-xc)n(y_ij-yc)k/I_0

See Also:
Serialized Form

Nested Class Summary
private static class ImageMoments.DualIndex
          Helper class that combines to integer indices, both hermitian, to a single key.
static class ImageMoments.Focus
          This class reads an fits image and calculates the requested image moment.
 
Field Summary
private  double[][] adu
          This is the image array, innner index is y!.
private  double bias
          If a bias is set, only adus above this are considered.
private  Map<ImageMoments.DualIndex,Double> cache
          Cache is updated at each call to #getImageMoment with no hit.
private  double high
          The multiplicator to the RN for maximum ADU still considered BG.
private  double low
          The multiplicator to the RN for minimum ADU still considered BG.
private  double readnoise
          The standard deviation estimate for background rejection.
private  double sum0
          Once the image is set, this is the ADU-sum.
private  double xc
          Once the image is set, this is the center-of-gravity, x coordinate.
private  double yc
          Once the image is set, this is the center-of-gravity, y coordinate.
 
Constructor Summary
ImageMoments(double[][] image)
          Takes an image array and readily calculates the count sum plus the center of gravity.
ImageMoments(double[][] image, double bias, double rn)
          Takes an image array and readily calculates the count sum plus the center of gravity.
ImageMoments(double[][] image, double bias, double rn, double hi, double lo)
          Takes an image array and readily calculates the count sum plus the center of gravity.
 
Method Summary
private  double calculateMnk(int n, int m)
           
 Point2D getCenter()
          Returns xc yc as a Point2D object.
 double getMoment(int x0, int y0)
          If the queried moment has not been calculated, we evaluate it by M_nk=Σ(x_ij-xc)n(y_ij-yc)k/I_0.
 void setImage(double[][] image, double bs, double rn, double hisig, double losig)
          Sets a new pixel array, erasing the cache, but immediately calculating the new count sum plus center of gravity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adu

private double[][] adu
This is the image array, innner index is y!.


bias

private double bias
If a bias is set, only adus above this are considered.


readnoise

private double readnoise
The standard deviation estimate for background rejection.


high

private double high
The multiplicator to the RN for maximum ADU still considered BG.


low

private double low
The multiplicator to the RN for minimum ADU still considered BG.


sum0

private double sum0
Once the image is set, this is the ADU-sum.


xc

private double xc
Once the image is set, this is the center-of-gravity, x coordinate.


yc

private double yc
Once the image is set, this is the center-of-gravity, y coordinate.


cache

private Map<ImageMoments.DualIndex,Double> cache
Cache is updated at each call to #getImageMoment with no hit.

Constructor Detail

ImageMoments

public ImageMoments(double[][] image)
Takes an image array and readily calculates the count sum plus the center of gravity.


ImageMoments

public ImageMoments(double[][] image,
                    double bias,
                    double rn)
Takes an image array and readily calculates the count sum plus the center of gravity.


ImageMoments

public ImageMoments(double[][] image,
                    double bias,
                    double rn,
                    double hi,
                    double lo)
Takes an image array and readily calculates the count sum plus the center of gravity.

Method Detail

setImage

public void setImage(double[][] image,
                     double bs,
                     double rn,
                     double hisig,
                     double losig)
Sets a new pixel array, erasing the cache, but immediately calculating the new count sum plus center of gravity.


getMoment

public double getMoment(int x0,
                        int y0)
If the queried moment has not been calculated, we evaluate it by M_nk=Σ(x_ij-xc)n(y_ij-yc)k/I_0. The moment is also cached for further queries. The special case with x0=y0=0 returns the ADU-sum, I_0, while queries with x0=1,y0=0 or x0=0,y0=1 return the center of gravity coordinate.

Parameters:
x0 - The leading index in M_nk
y0 - The trailing index in M_nk

getCenter

public Point2D getCenter()
Returns xc yc as a Point2D object.


calculateMnk

private double calculateMnk(int n,
                            int m)