Package nom.tam.image
Class StandardImageTiler
java.lang.Object
nom.tam.image.StandardImageTiler
- All Implemented Interfaces:
ImageTiler
- Direct Known Subclasses:
ImageData.ImageDataTiler
This class provides a subset of an N-dimensional image. Modified May 2, 2000
by T. McGlynn to permit tiles that go off the edge of the image.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?>
private final int[]
private final long
private final RandomAccess
-
Constructor Summary
ConstructorsConstructorDescriptionStandardImageTiler
(RandomAccess f, long fileOffset, int[] dims, Class<?> base) Create a tiler. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
fillFileData
(Object output, long delta, int outputOffset, int segment) File a tile segment from a file.protected void
fillMemData
(Object data, int[] posits, int length, Object output, int outputOffset, int dim) Fill a single segment from memory.protected void
Fill the subset.Read the entire image into a multidimensional array.protected abstract Object
See if we can get the image data from memory.static long
getOffset
(int[] dims, int[] pos) getTile
(int[] corners, int[] lengths) Get a subset of the image.void
Get a tile, filling in a prespecified array.protected static boolean
incrementPosition
(int[] start, int[] current, int[] lengths) Increment the offset within the position array.
-
Field Details
-
randomAccessFile
-
fileOffset
private final long fileOffset -
dims
private final int[] dims -
base
-
-
Constructor Details
-
StandardImageTiler
Create a tiler.- Parameters:
f
- The random access device from which image data may be read. This may be null if the tile information is available from memory.fileOffset
- The file offset within the RandomAccess device at which the data begins.dims
- The actual dimensions of the image.base
- The base class (should be a primitive type) of the image.
-
-
Method Details
-
getOffset
public static long getOffset(int[] dims, int[] pos) - Parameters:
dims
- The dimensions of the array.pos
- The index requested.- Returns:
- the offset of a given position.
-
incrementPosition
protected static boolean incrementPosition(int[] start, int[] current, int[] lengths) Increment the offset within the position array. Note that we never look at the last index since we copy data a block at a time and not byte by byte.- Parameters:
start
- The starting corner values.current
- The current offsets.lengths
- The desired dimensions of the subset.- Returns:
true
if the current array was changed
-
fillFileData
protected void fillFileData(Object output, long delta, int outputOffset, int segment) throws IOException File a tile segment from a file.- Parameters:
output
- The output tile.delta
- The offset from the beginning of the image in bytes.outputOffset
- The index into the output array.segment
- The number of elements to be read for this segment.- Throws:
IOException
- if the underlying stream failed
-
fillMemData
protected void fillMemData(Object data, int[] posits, int length, Object output, int outputOffset, int dim) Fill a single segment from memory. This routine is called recursively to handle multi-dimensional arrays. E.g., if data is three-dimensional, this will recurse two levels until we get a call with a single dimensional datum. At that point the appropriate data will be copied into the output.- Parameters:
data
- The in-memory image data.posits
- The current position for which data is requested.length
- The size of the segments.output
- The output tile.outputOffset
- The current offset into the output tile.dim
- The current dimension being
-
fillTile
protected void fillTile(Object data, Object o, int[] newDims, int[] corners, int[] lengths) throws IOException Fill the subset.- Parameters:
data
- The memory-resident data image. This may be null if the image is to be read from a file. This should be a multi-dimensional primitive array.o
- The tile to be filled. This is a simple primitive array.newDims
- The dimensions of the full image.corners
- The indices of the corner of the image.lengths
- The dimensions of the subset.- Throws:
IOException
- if the underlying stream failed
-
getCompleteImage
Read the entire image into a multidimensional array.- Specified by:
getCompleteImage
in interfaceImageTiler
- Throws:
IOException
- if the underlying stream failed
-
getMemoryImage
See if we can get the image data from memory. This may be overridden by other classes, notably in nom.tam.fits.ImageData.- Returns:
- the image data
-
getTile
Get a subset of the image. An image tile is returned as a one-dimensional array although the image will normally be multi-dimensional.- Specified by:
getTile
in interfaceImageTiler
- Parameters:
corners
- The starting corner (using 0 as the start) for the image.lengths
- The length requested in each dimension.- Throws:
IOException
- if the underlying stream failed
-
getTile
Get a tile, filling in a prespecified array. This version does not check that the user hase entered a valid set of corner and length arrays. ensure that out matches the length implied by the lengths array.- Specified by:
getTile
in interfaceImageTiler
- Parameters:
outArray
- The output tile array. A one-dimensional array. Data not within the valid limits of the image will be left unchanged. The length of this array should be the product of lengths.corners
- The corners of the tile.lengths
- The dimensions of the tile.- Throws:
IOException
- if the underlying stream failed
-