Class RealTypeConverters

java.lang.Object
net.imglib2.converter.RealTypeConverters

public final class RealTypeConverters extends Object
  • Constructor Details

    • RealTypeConverters

      private RealTypeConverters()
  • Method Details

    • 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 example UnsignedByteType, IntType, FloatType and 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 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.
      Parameters:
      image - image to convert
      pixelType - 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 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.