public final class RealTypeConverters extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T extends RealType<T>> |
convert(RandomAccessibleInterval<? extends RealType<?>> image,
T pixelType)
Convert the pixel type of the given image to a given output pixel type.
|
static void |
copyFromTo(RandomAccessible<? extends RealType<?>> source,
RandomAccessibleInterval<? extends RealType<?>> destination)
Copy the image content from a source image to a destination image.
|
static <S extends RealType<?>,T extends RealType<?>> |
getConverter(S inputType,
T outputType)
Returns a converter that converts from input to output type.
|
public static void copyFromTo(RandomAccessible<? extends RealType<?>> source, RandomAccessibleInterval<? extends RealType<?>> destination)
Both images need to be of type RealType. So for example
UnsignedByteType, IntType, FloatType
and many more types are supported. A type conversion is done
if needed.
source - Image that is source of the copy operation.destination - Image that is destination of the copy operation.public static <T extends RealType<T>> RandomAccessibleInterval<T> convert(RandomAccessibleInterval<? extends RealType<?>> image, T pixelType)
Example, convert and image from UnsignedByteType to IntType:
RandomAccessibleInterval<UnsignedByteType> image = ...;
RandomAccessibleInterval<IntType> intImage =
RealTypeConverters.convert( image, new IntType() );
The conversion is done on-the-fly when a pixel value is red.image - image to convertpixelType - pixel type of the result imagepublic static <S extends RealType<?>,T extends RealType<?>> Converter<S,T> getConverter(S inputType, T outputType)
To get a converter from UnsignedByteType to LongType use:
Converter< UnsignedByteType, LongType > converter =
RealConverters.getConverter(new UnsignedByteType(), new LongType());
The functionality is equivalent to RealDoubleConverter.
But the returned converter is faster and has higher numerical precision
than RealDoubleConverter.
This is because it's optimal for the given pair of types.
A converter from UnsignedByteType to ByteType
will for example copy the byte directly and never convert to double.
Copyright © 2015–2022 ImgLib2. All rights reserved.