skyview.process.imagefinder
Class Border

java.lang.Object
  extended by skyview.process.ImageFinder
      extended by skyview.process.imagefinder.Border
Direct Known Subclasses:
MaxExposure, Radius, ScaledBorder

public class Border
extends ImageFinder

This class finds the best images to be used for sampling using a recursive rectangle algorithm. It looks for rectangles the boundaries of which can all be sampled from the same input image.
Two settings are used by this class:

CheckNaNs
is a flag whose value is ignored. If set, then images are checked to see if the data value corresponding to a pixel position is a NaN when looking for the best image. Images where a NaN is found are ignored. Note that this applies only to the boundaries of the rectangles that are checked. If there are NaNs in isolated regions or pixels these may still be used by this image finder.
CornersOnly
is a flag whose value is ignored. If set, then only the corners of rectanges are checked before the rectangle is filled in with values. This was essentially the behavior of the default image finder prior to v2.02 of Skyview.


Field Summary
protected  boolean checkNaNs
          Do we wish to check that the input image does not have a NaN value?
static int CONSUMED
           
protected  boolean cornersOnly
          Do we want to only check on the corners of the rectangles and not the edges.
protected  Transformer fromOut
          The transformation from the output pixels to the celestial sphere
protected  boolean[] imageUsed
          Is a given image used in the transformation
protected  int[] img
          The index giving the best image for each pixel
protected  Image[] input
          The input images.
static int NO_COVERAGE
           
static int NON_PHYSICAL
           
protected  Image output
          The output image
protected  int pixelCount
           
protected  int rectCount
           
protected  boolean retry
          Should we retry pixels when we get a no coverage?
static int SPLIT_X
           
static int SPLIT_XY
           
static int SPLIT_Y
           
protected  double[] t2
          Transformation temporaries
protected  double[] t3
           
static int UNCHECKED
           
 
Constructor Summary
Border()
           
 
Method Summary
protected  int bestFit(int pix, boolean[] valid, boolean secondTry)
          Find the best image to use for a given unit vector.
protected  int cornerMatch(int[] corners, boolean[] valid, boolean[] newValid)
          Check the corners of a rectangle.
protected  double criterion(double mn, int i)
           
protected  boolean edgeOff(int match, int p0, int pe, int dp, boolean[] valid)
          Check whether all pixels on an edge of a rectangle all have the same best fit image.
 int[] findImages(Image[] input, Image output)
          Find the best image for each output pixel.
protected  double[] getCelest(int pix)
          Get the celestial coordinates corresponding to a given pixel.
protected  double[] getImage(Image img, double[] inp)
          Convert an input unit vector to a position in an image.
protected  double minDist(double x, double y, double a, double b)
          Given a point at x,y in an image of size a,b in the rectangle 0,a 0,b find the minimum distance to the edge.
 void setStrict(boolean flag)
          Set a strict geometry.
 
Methods inherited from class skyview.process.ImageFinder
factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

t2

protected double[] t2
Transformation temporaries


t3

protected double[] t3

imageUsed

protected boolean[] imageUsed
Is a given image used in the transformation


fromOut

protected Transformer fromOut
The transformation from the output pixels to the celestial sphere


pixelCount

protected int pixelCount

rectCount

protected int rectCount

output

protected Image output
The output image


input

protected Image[] input
The input images.


checkNaNs

protected boolean checkNaNs
Do we wish to check that the input image does not have a NaN value?


cornersOnly

protected boolean cornersOnly
Do we want to only check on the corners of the rectangles and not the edges.


retry

protected boolean retry
Should we retry pixels when we get a no coverage?


UNCHECKED

public static final int UNCHECKED
See Also:
Constant Field Values

NO_COVERAGE

public static final int NO_COVERAGE
See Also:
Constant Field Values

NON_PHYSICAL

public static final int NON_PHYSICAL
See Also:
Constant Field Values

CONSUMED

public static final int CONSUMED
See Also:
Constant Field Values

SPLIT_X

public static final int SPLIT_X
See Also:
Constant Field Values

SPLIT_Y

public static final int SPLIT_Y
See Also:
Constant Field Values

SPLIT_XY

public static final int SPLIT_XY
See Also:
Constant Field Values

img

protected int[] img
The index giving the best image for each pixel

Constructor Detail

Border

public Border()
Method Detail

findImages

public int[] findImages(Image[] input,
                        Image output)
Find the best image for each output pixel.

Specified by:
findImages in class ImageFinder
Parameters:
input - An array of images from which the output image is to be interpolated.
output - An output image to be generated from the input. This method does not change the output image.
Returns:
An index array which for each pixel in the output image gives the best image to sample. Note that this has dimension int[nx*ny] where nx changes most rapidly. The values of the index array can be:
  • >= 0: The pixel is best indexed with the given image.
  • -1: [internal] The best image for this pixel has not yet been determined.
  • -2: This pixel is not on any of the input images.
  • -3: This pixel does not represent a physical coordinate.
  • -4: [in other methods] this pixel has already been processed.

setStrict

public void setStrict(boolean flag)
Set a strict geometry. This class ignores the strict geometry flag since it does boundary checking.

Overrides:
setStrict in class ImageFinder

edgeOff

protected boolean edgeOff(int match,
                          int p0,
                          int pe,
                          int dp,
                          boolean[] valid)
Check whether all pixels on an edge of a rectangle all have the same best fit image.

Parameters:
std - The value each edge is to be compared against.
p0 - The first pixel offset to be checked.
pe - The last pixel offset to be checked.
dp - The spacing between pixels (either 1 or the number of pixels in a row).
valid - Should we consider this image?
newValid - If we recurse should be consider this image?
Returns:
true if there is a discrepant pixel, or false if all values are the same as std.

cornerMatch

protected int cornerMatch(int[] corners,
                          boolean[] valid,
                          boolean[] newValid)
Check the corners of a rectangle.

Parameters:
corners - The corners of the rectangle. It is assumed that there are four elements in corners, and they are in the order p00, p01, p10, p11
valid - The images to be checked at the current level of recursion.
newValid - The images to be checked at the next level of recursion. This routine will look at the corners of the image in relation to the bounds of the valid images to decide which images to search at a future level of recursion.

getCelest

protected double[] getCelest(int pix)
Get the celestial coordinates corresponding to a given pixel.

Parameters:
pix - The pixel index.
Returns:
The celestial coordinates as a unit vector. This is returned as a pointer to the field t3.

minDist

protected double minDist(double x,
                         double y,
                         double a,
                         double b)
Given a point at x,y in an image of size a,b in the rectangle 0,a 0,b find the minimum distance to the edge. We assume that x,y is contained in the rectangle. If x,y is outside the rectangle, then this should return a negative number.


getImage

protected double[] getImage(Image img,
                            double[] inp)
Convert an input unit vector to a position in an image.

Parameters:
img - The image we are transforming into the plane of.
inp - The input unit celestial coordinate unit vector.
Returns:
The coordinate plane tuple. This is returned as a pointer to the field t2.

bestFit

protected int bestFit(int pix,
                      boolean[] valid,
                      boolean secondTry)
Find the best image to use for a given unit vector.

Parameters:
pix - The output pixel we are testing (pix = x + width*y)
valid - Should we test this image
Returns:
The best image, or special values.

criterion

protected double criterion(double mn,
                           int i)