Class RecoloredImage
- All Implemented Interfaces:
RenderedImage
getColorModel()
, which returns the model
specified at construction time. All other non-trivial methods are static helper methods
for ImageProcessor
, defined here for reducing ImageProcessor
size.- Since:
- 1.1
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ColorModel
The color model to associate with this recolored image.(package private) final double
The minimum and maximum values used for computing the color model.(package private) final double
The minimum and maximum values used for computing the color model.Fields inherited from class org.apache.sis.image.ImageAdapter
source
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
RecoloredImage
(RenderedImage source, ColorModel colors, double minimum, double maximum) Creates a new recolored image with the given colors. -
Method Summary
Modifier and TypeMethodDescription(package private) final Class
<RecoloredImage> appendStringContent
(StringBuilder buffer) Appends a content to show in theImageAdapter.toString()
representation, after the class name and before the string representation of the wrapped image.(package private) static RenderedImage
applySameColors
(RenderedImage source, RenderedImage colored) Returns a recolored image with the same colors than the given image.boolean
Compares the given object with this image for equality.Returns the color model of this image.int
hashCode()
Returns a hash code value for this image.private static IllegalArgumentException
illegalPropertyType
(Map<String, ?> properties, String key, Object value) Returns the exception to be thrown when a property is of illegal type.(package private) static RenderedImage
stretchColorRamp
(ImageProcessor processor, RenderedImage source, Map<String, ?> modifiers) Returns an image with the same sample values than the given image, but with its color ramp stretched between specified or inferred bounds.Methods inherited from class org.apache.sis.image.ImageAdapter
copyData, getData, getData, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getPropertyNames, getSampleModel, getSources, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, prefetch, toString
Methods inherited from class org.apache.sis.image.PlanarImage
getBounds, verify
-
Field Details
-
colors
The color model to associate with this recolored image.- See Also:
-
minimum
final double minimumThe minimum and maximum values used for computing the color model. This is used for preserving color ramp stretching when a new color ramp is applied.Current implementation can only describes a uniform stretching between a minimum and maximum value. Future version may allow more sophisticated ways to redistribute the colors. The possibilities are determined by
stretchColorRamp(ImageProcessor, RenderedImage, Map)
implementation. -
maximum
final double maximumThe minimum and maximum values used for computing the color model. This is used for preserving color ramp stretching when a new color ramp is applied.Current implementation can only describes a uniform stretching between a minimum and maximum value. Future version may allow more sophisticated ways to redistribute the colors. The possibilities are determined by
stretchColorRamp(ImageProcessor, RenderedImage, Map)
implementation.
-
-
Constructor Details
-
RecoloredImage
Creates a new recolored image with the given colors.- Parameters:
source
- the image to wrap.colors
- the new color model.minimum
- the minimal sample value used for computing the color model.maximum
- the maximal sample value used for computing the color model.
-
-
Method Details
-
applySameColors
Returns a recolored image with the same colors than the given image. This method may return an existing ancestor if one is found with the desired color model.- Parameters:
source
- the image to wrap.colored
- the image from which to preserve the color model.
-
stretchColorRamp
static RenderedImage stretchColorRamp(ImageProcessor processor, RenderedImage source, Map<String, ?> modifiers) Returns an image with the same sample values than the given image, but with its color ramp stretched between specified or inferred bounds. The mapping applied by this method is conceptually a linear transform applied on sample values before they are mapped to their colors.Current implementation can stretch gray scale and index color models). If this method cannot stretch the color ramp, for example because the given image is an RGB image, then the image is returned unchanged.
- Parameters:
processor
- the processor to use for computing statistics if needed.source
- the image to recolor (can benull
).modifiers
- modifiers for narrowing the range of values, ornull
if none.- Returns:
- the image with color ramp stretched between the automatic bounds,
or
image
unchanged if the operation cannot be applied on the given image. - See Also:
-
illegalPropertyType
private static IllegalArgumentException illegalPropertyType(Map<String, ?> properties, String key, Object value) Returns the exception to be thrown when a property is of illegal type. -
getColorModel
Returns the color model of this image.- Specified by:
getColorModel
in interfaceRenderedImage
- Overrides:
getColorModel
in classImageAdapter
-
equals
Compares the given object with this image for equality.- Overrides:
equals
in classImageAdapter
- Parameters:
object
- the object to compare with this image.- Returns:
true
if the given object is an image performing the same calculation than this image.
-
hashCode
public int hashCode()Returns a hash code value for this image.- Overrides:
hashCode
in classImageAdapter
- Returns:
- a hash code value based on a description of the operation performed by this image.
-
appendStringContent
Appends a content to show in theImageAdapter.toString()
representation, after the class name and before the string representation of the wrapped image.- Specified by:
appendStringContent
in classImageAdapter
- Parameters:
buffer
- where to start writing content ofImageAdapter.toString()
representation.- Returns:
- name of the class to show in the
ImageAdapter.toString()
representation.
-