Class RealTypeConverters
- java.lang.Object
-
- net.imglib2.converter.RealTypeConverters
-
public final class RealTypeConverters extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description privateRealTypeConverters()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends RealType<T>>
RandomAccessibleInterval<T>convert(RandomAccessibleInterval<? extends RealType<?>> image, T pixelType)Convert the pixel type of the given image to a given output pixel type.static voidcopyFromTo(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<?>>
Converter<S,T>getConverter(S inputType, T outputType)Returns a converter that converts from input to output type.
-
-
-
Method Detail
-
copyFromTo
public static void copyFromTo(RandomAccessible<? extends RealType<?>> source, RandomAccessibleInterval<? extends RealType<?>> destination)
Copy the image content from a source image to a destination image. The area to be copied is defined by the destination.Both images need to be of type
RealType. So for exampleUnsignedByteType,IntType,FloatTypeand many more types are supported. A type conversion is done if needed.- Parameters:
source- Image that is source of the copy operation.destination- Image that is destination of the copy operation.
-
convert
public static <T extends RealType<T>> RandomAccessibleInterval<T> convert(RandomAccessibleInterval<? extends RealType<?>> image, T pixelType)
Convert the pixel type of the given image to a given output pixel type.Example, convert and image from
UnsignedByteTypetoIntType:
The conversion is done on-the-fly when a pixel value is red.RandomAccessibleInterval<UnsignedByteType> image = ...; RandomAccessibleInterval<IntType> intImage = RealTypeConverters.convert( image, new IntType() );- Parameters:
image- image to convertpixelType- pixel type of the result image
-
getConverter
public static <S extends RealType<?>,T extends RealType<?>> Converter<S,T> getConverter(S inputType, T outputType)
Returns a converter that converts from input to output type.To get a converter from
UnsignedByteTypetoLongTypeuse: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 thanRealDoubleConverter. This is because it's optimal for the given pair of types. A converter fromUnsignedByteTypetoByteTypewill for example copy the byte directly and never convert to double.
-
-