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
ImageLayout
automatically 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
float
ordouble
numbers.
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 class
ABandedSampleConverter
capable 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 ColorModel
The 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, ornull
if unknown.Fields inherited from class org.apache.sis.image.ComputedImage
sampleModel, SOURCE_PADDING_KEY
Fields inherited from class org.apache.sis.image.PlanarImage
GRID_GEOMETRY_KEY, MASK_KEY, POSITIONAL_ACCURACY_KEY, SAMPLE_RESOLUTIONS_KEY, STATISTICS_KEY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
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. -
Method Summary
Modifier and TypeMethodDescriptionprotected Raster
computeTile
(int tileX, int tileY, WritableRaster target) Computes the tile at specified indices.(package private) 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.boolean
Compares the given object with this image for equality.Returns the color model associated with all rasters of this image.int
Returns the height (in pixels) of this image.int
Returns the minimum tile index in the x direction.int
Returns the minimum tile index in the y direction.int
getMinX()
Returns the minimum x coordinate (inclusive) of this image.int
getMinY()
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, ornull
if this image has no properties.int
getWidth()
Returns the width (in pixels) of this image.int
hashCode()
Returns a hash code value for this image.protected Disposable
Notifies 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, sourceTileChanged
Methods 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, ornull
if 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, ornull
if 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 theconverters
array, 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, ornull
if 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 ofDataBuffer
constants.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:
getProperty
in interfaceRenderedImage
- Overrides:
getProperty
in classPlanarImage
- Parameters:
key
- the name of the property to get.- Returns:
- the property value, or
Image.UndefinedProperty
if none.
-
getPropertyNames
Returns the names of all recognized properties, ornull
if this image has no properties.- Specified by:
getPropertyNames
in interfaceRenderedImage
- Overrides:
getPropertyNames
in classPlanarImage
- Returns:
- names of all recognized properties, or
null
if 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
null
if 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:
getMinX
in interfaceRenderedImage
- Overrides:
getMinX
in 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:
getMinY
in interfaceRenderedImage
- Overrides:
getMinY
in 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:
getMinTileX
in interfaceRenderedImage
- Overrides:
getMinTileX
in 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:
getMinTileY
in interfaceRenderedImage
- Overrides:
getMinTileY
in 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:
computeTile
in 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:
prefetch
in 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), ornull
if none.
-
hashCode
public int hashCode()Returns a hash code value for this image. -
equals
Compares the given object with this image for equality.
-