Object
ImageCombiner
- All Implemented Interfaces:
Consumer<RenderedImage>
Combines an arbitrary number of images into a single one.
The combined images may use different coordinate systems if a resampling operation is specified.
The workflow is as below:
- Creates an
ImageCombinerwith the destination image where to write. - Configure with methods such as
setInterpolation(…). - Invoke
accept(…)orresample(…)methods for each image to combine. - Get the combined image with
result().
ImageCombiner does not yet handle alpha values).
Limitations
Current implementation does not try to map source bands to target bands for the same colors. For example, it does not verify if band order needs to be reversed because an image is RGB and the other image is BVR. It is caller responsibility to ensure that bands are in the same order.Current implementation does not expand the destination image for accommodating any area of a given image that appear outside the destination image bounds. Only the intersection of both images is used.
- Since:
- 1.1
-
Constructor Summary
ConstructorsConstructorDescriptionImageCombiner(WritableRenderedImage destination) Creates an image combiner which will write in the given image.ImageCombiner(WritableRenderedImage destination, ImageProcessor processor) Creates an image combiner which will use the given processor for resampling operations. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(RenderedImage source) Writes the given image on top of destination image.Returns the type of number used for representing the values of each band.Returns the interpolation method to use during resample operations.Quantity<?>[]Returns hints about the desired positional accuracy, in "real world" units or in pixel units.voidresample(RenderedImage source, Rectangle bounds, MathTransform toSource) Combines the result of resampling the given image.result()Returns the combination of destination image with all images specified toImageCombinermethods.voidsetInterpolation(Interpolation method) Sets the interpolation method to use during resample operations.voidsetPositionalAccuracyHints(Quantity<?>... hints) Sets hints about desired positional accuracy, in "real world" units or in pixel units.
-
Constructor Details
-
ImageCombiner
Creates an image combiner which will write in the given image. That image is not cleared; pixels that are not overwritten by calls to theaccept(…)orresample(…)methods will be left unchanged.- Parameters:
destination- the image where to combine images.
-
ImageCombiner
Creates an image combiner which will use the given processor for resampling operations. The given destination image is not cleared; pixels that are not overwritten by calls to theaccept(…)orresample(…)methods will be left unchanged.- Parameters:
destination- the image where to combine images.processor- the processor to use for resampling operations.- Since:
- 1.2
-
-
Method Details
-
getInterpolation
Returns the interpolation method to use during resample operations.- Returns:
- interpolation method to use during resample operations.
- See Also:
-
setInterpolation
Sets the interpolation method to use during resample operations.- Parameters:
method- interpolation method to use during resample operations.- See Also:
-
getPositionalAccuracyHints
Returns hints about the desired positional accuracy, in "real world" units or in pixel units. If the returned array is non-empty and contains accuracies large enough,ImageCombinermay use some slightly faster algorithms at the expense of accuracy.- Returns:
- desired accuracy in no particular order, or an empty array if none.
- See Also:
-
setPositionalAccuracyHints
Sets hints about desired positional accuracy, in "real world" units or in pixel units. Accuracy can be specified in real world units such as metres or in pixel units, which are converted to real world units depending on image resolution. If more than one value is applicable to a dimension (after unit conversion if needed), the smallest value is taken.- Parameters:
hints- desired accuracy in no particular order, or anullarray if none. Null elements in the array are ignored.- See Also:
-
getBandType
Returns the type of number used for representing the values of each band.- Returns:
- the type of number capable to hold sample values of each band.
- Since:
- 1.4
-
accept
Writes the given image on top of destination image. The given source image shall use the same pixel coordinate system than the destination image (but not necessarily the same tile indices). For every (x,y) pixel coordinates in the destination image:- If (x,y) are valid
sourcepixel coordinates, then the source pixel values overwrite the destination pixel values. - Otherwise the destination pixel is left unchanged.
ImageCombinerdoes not yet handle alpha values).- Specified by:
acceptin interfaceConsumer<RenderedImage>- Parameters:
source- the image to write on top of destination image.
- If (x,y) are valid
-
resample
Combines the result of resampling the given image. The resampling operation is defined by a potentially non-linear transform from the destination image to the specified source image. That transform should map pixel centers.Properties used
This operation uses the following properties in addition to method parameters:- Interpolation method (nearest neighbor, bilinear, etc).
- Positional accuracy hints for enabling faster resampling at the cost of lower precision.
ImageProcessor, this method does not use fill values. Destination pixels that cannot be mapped to source pixels are left unchanged.- Parameters:
source- the image to be resampled.bounds- domain of pixel coordinates in the destination image, ornullfor the whole image.toSource- conversion of pixel coordinates from destination image tosourceimage.- See Also:
-
result
Returns the combination of destination image with all images specified toImageCombinermethods. This may be the destination image specified at construction time, but may also be a larger image if the destination has been dynamically expanded for accommodating larger sources.Note: dynamic expansion is not yet implemented in current version. If a future version implements it, we shall guarantee that the coordinate of each pixel is unchanged (i.e. the image
minXandminYmay become negative, but the pixel identified by coordinates (0,0) for instance will stay the same pixel.)- Returns:
- the combination of destination image with all source images.
-