Package nom.tam.image
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
ConstructorDescriptionStreamingTileImageData
(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.void
Writes 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 nom.tam.fits.ImageData
convertTo, from, getDimensions, getQuantizer, getTiler, getType, isComplexValued, overrideHeaderAxes, read, setBuffer, setQuantizer, toHDU
Methods inherited from class nom.tam.fits.Data
calcChecksum, detach, getData, getFileOffset, getKernel, getSize, isDeferred, isEmpty, reset, rewrite, rewriteable
-
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:FitsElement
Writes 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:
write
in interfaceFitsElement
- Overrides:
write
in classImageData
- Parameters:
o
- The data sink.- Throws:
FitsException
- if the write was unsuccessful.
-