Package org.apache.sis.image
Class BandedSampleConverter
java.lang.Object
org.apache.sis.image.PlanarImage
org.apache.sis.image.ComputedImage
org.apache.sis.image.BandedSampleConverter
- All Implemented Interfaces:
RenderedImage,Disposable
- Direct Known Subclasses:
BandedSampleConverter.Writable
An image where each sample value is computed independently of other sample values and independently
of neighbor points. Values are computed by a separated
MathTransform1D for each band
(by contrast, an InterleavedSampleConverter would handle all sample values as a coordinate tuple).
Current implementation makes the following simplifications:
- The image has exactly one source.
- Image layout (minimum coordinates, image size, tile grid) is the same than source image layout,
unless the source has too large tiles in which case
ImageLayoutautomatically subdivides the tile grid in smaller tiles. - Image is computed and stored on a band-by-band basis using a
BandedSampleModel. - Calculation is performed on
floatordoublenumbers.
BandedSampleConverter
returned by the create(…) method will implement WritableRenderedImage interface.
In such case, writing converted values will cause the corresponding source values to be updated too.- Since:
- 1.1
- Version:
- 1.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classABandedSampleConvertercapable to retro-propagate the changes to the source coverage. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]Properties potentially added by this image, no matter if present in source image or not.private final ColorModelThe color model for the expected range of values.private final org.opengis.referencing.operation.MathTransform1D[]The transfer functions to apply on each band of the source image.private final double[]The sample resolutions, ornullif unknown.Fields inherited from class org.apache.sis.image.ComputedImage
sampleModel, SOURCE_PADDING_KEYFields inherited from class org.apache.sis.image.PlanarImage
GRID_GEOMETRY_KEY, MASK_KEY, POSITIONAL_ACCURACY_KEY, SAMPLE_RESOLUTIONS_KEY, STATISTICS_KEY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateBandedSampleConverter(RenderedImage source, BandedSampleModel sampleModel, ColorModel colorModel, NumberRange<?>[] ranges, org.opengis.referencing.operation.MathTransform1D[] converters) Creates a new image which will compute values using the given converters. -
Method Summary
Modifier and TypeMethodDescriptionprotected RastercomputeTile(int tileX, int tileY, WritableRaster target) Computes the tile at specified indices.(package private) static BandedSampleConvertercreate(RenderedImage source, ImageLayout layout, NumberRange<?>[] sourceRanges, org.opengis.referencing.operation.MathTransform1D[] converters, int targetType, ColorModel colorModel) Creates a new image of the given data type which will compute values using the given converters.booleanCompares the given object with this image for equality.Returns the color model associated with all rasters of this image.intReturns the height (in pixels) of this image.intReturns the minimum tile index in the x direction.intReturns the minimum tile index in the y direction.intgetMinX()Returns the minimum x coordinate (inclusive) of this image.intgetMinY()Returns the minimum y coordinate (inclusive) of this image.getProperty(String key) Gets a property from this image.String[]Returns the names of all recognized properties, ornullif this image has no properties.intgetWidth()Returns the width (in pixels) of this image.inthashCode()Returns a hash code value for this image.protected DisposableNotifies the source image that tiles will be computed soon in the given region.Methods inherited from class org.apache.sis.image.ComputedImage
clearErrorFlags, createTile, dispose, equalsBase, getDestination, getSampleModel, getSource, getSource, getSources, getTile, getTileHeight, getTileWidth, getWritableTileIndices, hashCodeBase, hasTileWriters, isTileWritable, markDirtyTiles, markTileWritable, reference, setDestination, sourceTileChangedMethods inherited from class org.apache.sis.image.PlanarImage
copyData, getBounds, getData, getData, getNumXTiles, getNumYTiles, getTileGridXOffset, getTileGridYOffset, toString, verify
-
Field Details
-
ADDED_PROPERTIES
Properties potentially added by this image, no matter if present in source image or not. Must be consistent with the switch case statement doing its own calculation ingetProperty(String).- See Also:
-
converters
private final org.opengis.referencing.operation.MathTransform1D[] convertersThe transfer functions to apply on each band of the source image. -
colorModel
The color model for the expected range of values. May benull. -
sampleResolutions
private final double[] sampleResolutionsThe sample resolutions, ornullif unknown.
-
-
Constructor Details
-
BandedSampleConverter
private BandedSampleConverter(RenderedImage source, BandedSampleModel sampleModel, ColorModel colorModel, NumberRange<?>[] ranges, org.opengis.referencing.operation.MathTransform1D[] converters) Creates a new image which will compute values using the given converters.- Parameters:
source- the image for which to convert sample values.sampleModel- the sample model shared by all tiles in this image.colorModel- the color model for the expected range of values, ornull.ranges- the expected range of values for each band, ornullif unknown.converters- the transfer functions to apply on each band of the source image. If this array was a user-provided parameter, should be cloned by caller.
-
-
Method Details
-
create
static BandedSampleConverter create(RenderedImage source, ImageLayout layout, NumberRange<?>[] sourceRanges, org.opengis.referencing.operation.MathTransform1D[] converters, int targetType, ColorModel colorModel) Creates a new image of the given data type which will compute values using the given converters. The number of bands is the length of theconvertersarray, which must be greater than 0 and not greater than the number of bands in the source image.- Parameters:
source- the image for which to convert sample values.layout- object to use for computing tile size.sourceRanges- the expected range of values for each band in source image, ornullif unknown.converters- the transfer functions to apply on each band of the source image.targetType- the type of this image resulting from conversion of given image. Shall be one ofDataBufferconstants.colorModel- the color model for the expected range of values, ornull.- Returns:
- the image which compute converted values from the given source.
- See Also:
-
getProperty
Gets a property from this image. Current implementation recognizes: "org.apache.sis.SampleResolution".- Specified by:
getPropertyin interfaceRenderedImage- Overrides:
getPropertyin classPlanarImage- Parameters:
key- the name of the property to get.- Returns:
- the property value, or
Image.UndefinedPropertyif none.
-
getPropertyNames
Returns the names of all recognized properties, ornullif this image has no properties.- Specified by:
getPropertyNamesin interfaceRenderedImage- Overrides:
getPropertyNamesin classPlanarImage- Returns:
- names of all recognized properties, or
nullif none.
-
getColorModel
Returns the color model associated with all rasters of this image. If the sample values of this image are floating point numbers, then a gray scale color model is computed from the expected range of values.- Returns:
- the color model of this image, or
nullif none.
-
getWidth
public int getWidth()Returns the width (in pixels) of this image. This is the the same value than the source image (not necessarily zero).- Returns:
- the width (number of columns) of this image.
-
getHeight
public int getHeight()Returns the height (in pixels) of this image. This is the the same value than the source image (not necessarily zero).- Returns:
- the height (number of rows) of this image.
-
getMinX
public int getMinX()Returns the minimum x coordinate (inclusive) of this image. This is the the same value than the source image (not necessarily zero).- Specified by:
getMinXin interfaceRenderedImage- Overrides:
getMinXin classPlanarImage- Returns:
- the minimum x coordinate (column) of this image.
-
getMinY
public int getMinY()Returns the minimum y coordinate (inclusive) of this image. This is the the same value than the source image (not necessarily zero).- Specified by:
getMinYin interfaceRenderedImage- Overrides:
getMinYin classPlanarImage- Returns:
- the minimum y coordinate (row) of this image.
-
getMinTileX
public int getMinTileX()Returns the minimum tile index in the x direction. This is the the same value than the source image (not necessarily zero).- Specified by:
getMinTileXin interfaceRenderedImage- Overrides:
getMinTileXin classPlanarImage- Returns:
- the minimum tile index in the x direction.
-
getMinTileY
public int getMinTileY()Returns the minimum tile index in the y direction. This is the the same value than the source image (not necessarily zero).- Specified by:
getMinTileYin interfaceRenderedImage- Overrides:
getMinTileYin classPlanarImage- Returns:
- the minimum tile index in the y direction.
-
computeTile
protected Raster computeTile(int tileX, int tileY, WritableRaster target) throws org.opengis.referencing.operation.TransformException Computes the tile at specified indices.- Specified by:
computeTilein classComputedImage- Parameters:
tileX- the column index of the tile to compute.tileY- the row index of the tile to compute.target- if the tile already exists but needs to be updated, the tile to update. Otherwisenull.- Returns:
- computed tile for the given indices (cannot be null).
- Throws:
org.opengis.referencing.operation.TransformException- if an error occurred while converting a sample value.
-
prefetch
Notifies the source image that tiles will be computed soon in the given region. If the source image is an instance ofPlanarImage, then this method forwards the notification to it. Otherwise default implementation does nothing.- Overrides:
prefetchin classComputedImage- Parameters:
tiles- indices of the tiles which will be prefetched.- Returns:
- handler on which to invoke
dispose()after the prefetch operation completed (successfully or not), ornullif none.
-
hashCode
public int hashCode()Returns a hash code value for this image. -
equals
Compares the given object with this image for equality.
-