Class StreamingTileImageData
java.lang.Object
nom.tam.fits.Data
nom.tam.fits.ImageData
nom.tam.image.StreamingTileImageData
- All Implemented Interfaces:
FitsElement
Simple streaming image tile implementation. Useful for web applications that provide a cutout service. The idea is that the ImageData object will be extracted from an overlapping HDU (without first reading so as not to fill up the memory), and one of these objects are created for the output.
Fits source = new Fits(myFile);
ImageHDU imageHDU = source.getHDU(1);
// We must manually adjust the header for the cutout image as necessary
Header tileHeader = ...
// Define the cutout region
int[] tileStarts = new int[]{10, 10};
int[] tileLengths = new int[]{45, 60};
int[] tileSteps = new int[]{1, 1};
// Create the cutout
StreamingTileImageData streamingTileImageData = new StreamingTileImageData(tileHeader, imageHDU.getTiler(),
tileStarts, tileLengths, tileSteps);
// Write the cutout to the output
Fits output = new Fits();
output.addHDU(FitsFactory.hduFactory(tileHeader, streamingTileImageData));
// The cutout happens at write time!
output.write(outputStream);
- Since:
- 1.18
-
Constructor Summary
ConstructorsConstructorDescriptionStreamingTileImageData(Header header, ImageTiler tiler, int[] corners, int[] lengths, int[] steps) Constructor for a tile image data object. -
Method Summary
Modifier and TypeMethodDescriptionint[]getSteps()Returns the striding step sizes along the various image dimensions.voidWrites the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.Methods inherited from class ImageData
convertTo, from, getDimensions, getQuantizer, getTiler, getType, isComplexValued, overrideHeaderAxes, read, setBuffer, setQuantizer, toHDUModifier and TypeMethodDescriptionConverts this image HDU to another image HDU of a different type, possibly using a qunatizer for the integer-decimal conversion of the data elements.static ImageDataCreates a new FITS image using the specified primitive numerical Java array containing data.final int[]Returns the dimensions of this image.final QuantizerReturns the conversion between decimal and integer data representations.getTiler()Returns the an image tiler instance that can be used to divide this image into tiles that may be processed separately (and in parallel).final Class<?> getType()Returns the element type of this image in its current representation.final booleanChecks if the image data is explicitly designated as a complex-valued image.static voidoverrideHeaderAxes(Header header, int... sizes) (for expert users) Overrides the image size description in the header to the specified Java array dimensions.voidread(ArrayDataInput in) Reads the data or skips over it for reading later, depending on whether reading from a stream or a random acessible input, respectively.voidSets the buffer that may hold a serialized version of the data for this image.voidsetQuantizer(Quantizer quant) Sets the conversion between decimal and integer data representations.toHDU()Returns an approprotae HDU object that encapsulates this FITS data, and contains the minimal mandatory header description for that data.Methods inherited from class Data
calcChecksum, detach, getData, getFileOffset, getKernel, getSize, isDeferred, isEmpty, reset, rewrite, rewriteableModifier and TypeMethodDescriptionlongComputes and returns the FITS checksum for this data, for example to compare against the storedDATASUMin the FITS header (e.g. viaBasicHDU.getStoredDatasum()).voiddetach()Detaches this data object from the input (if any), such as a file or stream, but not before loading data from the previously assigned input into memory.getData()Returns the underlying Java representation of the data contained in this HDU's data segment.longReturns the byte offset at which this element starts ina file.final ObjectSame asData.getData().longgetSize()Returns the size of this elements in the FITS representation.booleanChecks if the data should be assumed to be in deferred read mode.booleanisEmpty()Checks if the data content is currently empty, i.e. no actual data is currently stored in memory.booleanreset()Reset the input stream to point to the beginning of this elementvoidrewrite()Rewrite the contents of the element in place.booleanChecks if we can write this element back to its source.
-
Constructor Details
-
StreamingTileImageData
public StreamingTileImageData(Header header, ImageTiler tiler, int[] corners, int[] lengths, int[] steps) throws FitsException Constructor for a tile image data object.- Parameters:
header- The header representing the desired cutout. It is the responsibility of the caller to adjust the header appropriately.tiler- The tiler to slice pixels out with.corners- The corners to start tiling.lengths- The count of values to extract.steps- The number of jumps to make to the next read. Optional, defaults to 1 for each axis.- Throws:
FitsException- If the provided Header is unreadable
-
-
Method Details
-
getSteps
public int[] getSteps()Returns the striding step sizes along the various image dimensions.- Returns:
- an array containing the steps sizes along the dimensions
-
write
Description copied from interface:FitsElementWrites the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.- Specified by:
writein interfaceFitsElement- Overrides:
writein classImageData- Parameters:
o- The data sink.- Throws:
FitsException- if the write was unsuccessful.
-