Package skyview.process.imagefinder
Class RectRecurse
java.lang.Object
skyview.process.ImageFinder
skyview.process.imagefinder.RectRecurse
- Direct Known Subclasses:
Border
,MaxExposure
,ScaledBorder
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.
Settings are used by this class:
Settings are used by this class:
- MinEdge
- Only images where we are at least this number of pixels from the edge will be considered. The default is 0.
- MaxRadius
- Only images where the offset of the pixel from the center of the image is less than this radius (calculations in pixels) will be considered. The default is infinity.
- 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
- Only images where we are at least this number of pixels from the edge will be considered. The default is 0.
- 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.
- The output image is sampled in a rectangular grid with the samples spaced no more than half the image size of the input images.
- For each rectangle, the corners of the image are projected into the frame of each currently valid image in turn.
- If all four pixels project below, above, to the right or to the left of the image bounds, then this image is marked as invalid for future consideration in this rectangle or subrectangles. E.g., suppose that a given corner is simultaneously below and to the left of the image (i.e., the corner projects to pixel coordinates with x and y both less than 0). If the other three corners are also below the image, even if some are to the right of the image or some have X-values that would be within the image, then the image can be eliminated from future consideration. However, if even one of the other pixels is not below the image, then we can not use this criterion to eliminate the image, even if that corner is also outside the image. Similarly if the other three corners all project to the left of the image, then the image can be eliminated.
- The best pixel is found for each corner. The algorithm for the best pixel is defined by subclasses. If the pixel does not fall within any image it is marked as NO_COVERAGE.
- A pixel may not correspond to any position on the sky (e.g., a pixel outside the elliptical bounds the Aitoff projection). These pixels are marked as NON-PHYSICAL
- If the best images are the same for all four corners, then the edges of the rectangle is also checked. If the entire border comes from the same candidate then the rectangle is filled in as coming from that sample.
- Otherwise the algorithm checks to see if the the values along the horizontal or veritical edges are the same. If so, we split the rectangle in half, so that the corners that match are kept together. If not we do a recusion splitting the rectangle into quarters.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
protected Transformer
The transformation from the output pixels to the celestial spherestatic final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
cornerMatch
(int[] corners, boolean[] valid, boolean[] newValid) Check the corners of a rectangle.protected abstract double
criterion
(int image, int nx, int ny, double tx, double ty) The criterion function should return a larger value for more desirable inputs.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 Image
getCandidate
(int i) Return a particular candidate.protected double[]
Convert an input unit vector to a position in an image.protected int[]
getInputLimits
(Image in) 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
printOut
(int[] arr, int mx) Debugging outputprotected double
radiusSquared
(double tx, double ty, double nx, double ny, int index, Image input) The default for this is to use the radius from the center of the image.void
setStrict
(boolean flag) Set a strict geometry.Methods inherited from class skyview.process.ImageFinder
factory
-
Field Details
-
fromOut
The transformation from the output pixels to the celestial sphere -
UNCHECKED
public static final int UNCHECKED- See Also:
-
NO_COVERAGE
public static final int NO_COVERAGE- See Also:
-
NON_PHYSICAL
public static final int NON_PHYSICAL- See Also:
-
CONSUMED
public static final int CONSUMED- See Also:
-
SPLIT_X
public static final int SPLIT_X- See Also:
-
SPLIT_Y
public static final int SPLIT_Y- See Also:
-
SPLIT_XY
public static final int SPLIT_XY- See Also:
-
-
Constructor Details
-
RectRecurse
public RectRecurse()
-
-
Method Details
-
findImages
Find the best image for each output pixel.- Specified by:
findImages
in classImageFinder
- Parameters:
input
- An array of images that may be sampled to get the output image.output
- The output image. In this routine we are interested in its geometry, not its data.- 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.
-
getCandidate
Return a particular candidate.- Parameters:
i
- The index of the requested candidate- Returns:
- The input image.
-
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 classImageFinder
- Parameters:
flag
- Should strict checking be enabled?
-
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:
match
- 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?valid
- 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, p11valid
- 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.- Returns:
- A zero of positive value indicates that all corners match that image. Negative values code where variations were shown.
-
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.- Parameters:
x
- The x value of the point.y
- The y value of the pointa
- The width of the image.b
- the height of the image- Returns:
- The distance between the point and the nearest edge.
-
getImage
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.
-
getInputLimits
-
radiusSquared
The default for this is to use the radius from the center of the image. The last two arguments may be used in extending classes. when the center of the image is not the center of the field of view.- Parameters:
tx
- The x value of the first point.ty
- The y value of the first point.nx
- The width of the image.ny
- the height of the image.- Returns:
- the distance squared from the center of the image.
-
criterion
protected abstract double criterion(int image, int nx, int ny, double tx, double ty) The criterion function should return a larger value for more desirable inputs.- Parameters:
image
- The index of the image being considerednx
- The width of the candidate imageny
- The height of the caandiate imagetx
- The x-value of the requested point.ty
- The y-value of the requested point.- Returns:
- A measure of the desirability of using this image to same this point. Larger is better.
-
printOut
public void printOut(int[] arr, int mx) Debugging output- Parameters:
arr
- An input array.mx
- The number of values to put on a line
-