public final class Tensors extends Object
Tensor
objects. In
particular, this class provides methods for converting between ImgLib2 data
structures and TensorFlow Tensor
s.Modifier and Type | Method and Description |
---|---|
static Img<ByteType> |
imgByte(org.tensorflow.Tensor<org.tensorflow.types.UInt8> image)
Creates an image of type
ByteType containing the data of a
TensorFlow Tensor with the data type DataType.UINT8 . |
static Img<ByteType> |
imgByte(org.tensorflow.Tensor<org.tensorflow.types.UInt8> image,
int[] dimOrder)
Creates an image of type
ByteType containing the data of a
TensorFlow Tensor with the data type DataType.UINT8 . |
static Img<ByteType> |
imgByteDirect(org.tensorflow.Tensor<org.tensorflow.types.UInt8> image)
Creates an image of type
ByteType containing the data of a
TensorFlow Tensor with the data type DataType.UINT8 . |
static Img<DoubleType> |
imgDouble(org.tensorflow.Tensor<Double> image)
Creates an image of type
DoubleType containing the data of a
TensorFlow Tensor with the data type DataType.DOUBLE . |
static Img<DoubleType> |
imgDouble(org.tensorflow.Tensor<Double> image,
int[] dimOrder)
Creates an image of type
DoubleType containing the data of a
TensorFlow Tensor with the data type DataType.DOUBLE . |
static Img<DoubleType> |
imgDoubleDirect(org.tensorflow.Tensor<Double> image)
Creates an image of type
DoubleType containing the data of a
TensorFlow Tensor with the data type DataType.DOUBLE . |
static Img<FloatType> |
imgFloat(org.tensorflow.Tensor<Float> image)
Creates an image of type
FloatType containing the data of a
TensorFlow Tensor with the data type DataType.FLOAT . |
static Img<FloatType> |
imgFloat(org.tensorflow.Tensor<Float> image,
int[] dimOrder)
Creates an image of type
FloatType containing the data of a
TensorFlow Tensor with the data type DataType.FLOAT . |
static Img<FloatType> |
imgFloatDirect(org.tensorflow.Tensor<Float> image)
Creates an image of type
FloatType containing the data of a
TensorFlow Tensor with the data type DataType.FLOAT . |
static Img<IntType> |
imgInt(org.tensorflow.Tensor<Integer> image)
Creates an image of type
IntType containing the data of a
TensorFlow Tensor with the data type DataType.INT32 . |
static Img<IntType> |
imgInt(org.tensorflow.Tensor<Integer> image,
int[] dimOrder)
Creates an image of type
IntType containing the data of a
TensorFlow Tensor with the data type DataType.INT32 . |
static Img<IntType> |
imgIntDirect(org.tensorflow.Tensor<Integer> image)
Creates an image of type
IntType containing the data of a
TensorFlow Tensor with the data type DataType.INT32 . |
static Img<LongType> |
imgLong(org.tensorflow.Tensor<Long> image)
Creates an image of type
LongType containing the data of a
TensorFlow Tensor with the data type DataType.INT64 . |
static Img<LongType> |
imgLong(org.tensorflow.Tensor<Long> image,
int[] dimOrder)
Creates an image of type
LongType containing the data of a
TensorFlow Tensor with the data type DataType.INT64 . |
static Img<LongType> |
imgLongDirect(org.tensorflow.Tensor<Long> image)
Creates an image of type
LongType containing the data of a
TensorFlow Tensor with the data type DataType.INT64 . |
static <T extends RealType<T>> |
reverse(Img<T> image)
Flips all dimensions
d0,d1,...,dn -> dn,...,d1,d0 . |
static <T extends RealType<T>> |
reverse(RandomAccessibleInterval<T> image)
Flips all dimensions
d0,d1,...,dn -> dn,...,d1,d0 . |
static <T extends RealType<T>> |
tensor(RandomAccessibleInterval<T> image)
Creates a TensorFlow Tensor containing data from the given image.
|
static <T extends RealType<T>> |
tensor(RandomAccessibleInterval<T> image,
int[] dimOrder)
Creates a TensorFlow Tensor containing data from the given image.
|
static org.tensorflow.Tensor<org.tensorflow.types.UInt8> |
tensorByte(RandomAccessibleInterval<ByteType> image)
Creates a TensorFlow Tensor containing data from the given byte image.
|
static org.tensorflow.Tensor<org.tensorflow.types.UInt8> |
tensorByte(RandomAccessibleInterval<ByteType> image,
int[] dimOrder)
Creates a TensorFlow Tensor containing data from the given byte image.
|
static org.tensorflow.Tensor<org.tensorflow.types.UInt8> |
tensorByteDirect(RandomAccessibleInterval<ByteType> image)
Creates a TensorFlow Tensor containing data from the given byte image.
|
static <T extends RealType<T>> |
tensorDirect(RandomAccessibleInterval<T> image)
Creates a TensorFlow Tensor containing data from the given image.
|
static org.tensorflow.Tensor<Double> |
tensorDouble(RandomAccessibleInterval<DoubleType> image)
Creates a TensorFlow Tensor containing data from the given double image.
|
static org.tensorflow.Tensor<Double> |
tensorDouble(RandomAccessibleInterval<DoubleType> image,
int[] dimOrder)
Creates a TensorFlow Tensor containing data from the given double image.
|
static org.tensorflow.Tensor<Double> |
tensorDoubleDirect(RandomAccessibleInterval<DoubleType> image)
Creates a TensorFlow Tensor containing data from the given double image.
|
static org.tensorflow.Tensor<Float> |
tensorFloat(RandomAccessibleInterval<FloatType> image)
Creates a TensorFlow Tensor containing data from the given float image.
|
static org.tensorflow.Tensor<Float> |
tensorFloat(RandomAccessibleInterval<FloatType> image,
int[] dimOrder)
Creates a TensorFlow Tensor containing data from the given float image.
|
static org.tensorflow.Tensor<Float> |
tensorFloatDirect(RandomAccessibleInterval<FloatType> image)
Creates a TensorFlow Tensor containing data from the given float image.
|
static org.tensorflow.Tensor<Integer> |
tensorInt(RandomAccessibleInterval<IntType> image)
Creates a TensorFlow Tensor containing data from the given int image.
|
static org.tensorflow.Tensor<Integer> |
tensorInt(RandomAccessibleInterval<IntType> image,
int[] dimOrder)
Creates a TensorFlow Tensor containing data from the given int image.
|
static org.tensorflow.Tensor<Integer> |
tensorIntDirect(RandomAccessibleInterval<IntType> image)
Creates a TensorFlow Tensor containing data from the given int image.
|
static org.tensorflow.Tensor<Long> |
tensorLong(RandomAccessibleInterval<LongType> image)
Creates a TensorFlow Tensor containing data from the given long image.
|
static org.tensorflow.Tensor<Long> |
tensorLong(RandomAccessibleInterval<LongType> image,
int[] dimOrder)
Creates a TensorFlow Tensor containing data from the given long image.
|
static org.tensorflow.Tensor<Long> |
tensorLongDirect(RandomAccessibleInterval<LongType> image)
Creates a TensorFlow Tensor containing data from the given long image.
|
public static Img<ByteType> imgByte(org.tensorflow.Tensor<org.tensorflow.types.UInt8> image)
ByteType
containing the data of a
TensorFlow Tensor with the data type DataType.UINT8
.
Note that this does _not_ adjust any dimensions. This means that
the resulting image will have dimensions corresponding to the reversed
shape of the Tensor. See imgByteDirect(Tensor)
and
imgByte(Tensor, int[])
if you want to handle dimensions
differently.
Note also that no exception is thrown if the data type is not
DataType.UINT8
but it will give unexpected results.
image
- The TensorFlow Tensor.public static Img<DoubleType> imgDouble(org.tensorflow.Tensor<Double> image)
DoubleType
containing the data of a
TensorFlow Tensor with the data type DataType.DOUBLE
.
Note that this does _not_ adjust any dimensions. This means that
the resulting image will have dimensions corresponding to the reversed
shape of the Tensor. See imgByteDirect(Tensor)
and
imgByte(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not double.public static Img<FloatType> imgFloat(org.tensorflow.Tensor<Float> image)
FloatType
containing the data of a
TensorFlow Tensor with the data type DataType.FLOAT
.
Note that this does _not_ adjust any dimensions. This means that
the resulting image will have dimensions corresponding to the reversed
shape of the Tensor. See imgByteDirect(Tensor)
and
imgByte(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not float.public static Img<IntType> imgInt(org.tensorflow.Tensor<Integer> image)
IntType
containing the data of a
TensorFlow Tensor with the data type DataType.INT32
.
Note that this does _not_ adjust any dimensions. This means that
the resulting image will have dimensions corresponding to the reversed
shape of the Tensor. See imgByteDirect(Tensor)
and
imgByte(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not int.public static Img<LongType> imgLong(org.tensorflow.Tensor<Long> image)
LongType
containing the data of a
TensorFlow Tensor with the data type DataType.INT64
.
Note that this does _not_ adjust any dimensions. This means that
the resulting image will have dimensions corresponding to the reversed
shape of the Tensor. See imgByteDirect(Tensor)
and
imgByte(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not long.public static Img<ByteType> imgByte(org.tensorflow.Tensor<org.tensorflow.types.UInt8> image, int[] dimOrder)
ByteType
containing the data of a
TensorFlow Tensor with the data type DataType.UINT8
.
Note that no exception is thrown if the data type is not DataType.UINT8
but it will give unexpected results.
image
- The TensorFlow Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor. TODO Example?public static Img<DoubleType> imgDouble(org.tensorflow.Tensor<Double> image, int[] dimOrder)
DoubleType
containing the data of a
TensorFlow Tensor with the data type DataType.DOUBLE
.image
- The TensorFlow Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor.IllegalArgumentException
- if Tensor data type is not double.public static Img<FloatType> imgFloat(org.tensorflow.Tensor<Float> image, int[] dimOrder)
FloatType
containing the data of a
TensorFlow Tensor with the data type DataType.FLOAT
.image
- The TensorFlow Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor.IllegalArgumentException
- if Tensor data type is not float.public static Img<IntType> imgInt(org.tensorflow.Tensor<Integer> image, int[] dimOrder)
IntType
containing the data of a
TensorFlow Tensor with the data type DataType.INT32
.image
- The TensorFlow Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor.IllegalArgumentException
- if Tensor data type is not int.public static Img<LongType> imgLong(org.tensorflow.Tensor<Long> image, int[] dimOrder)
LongType
containing the data of a
TensorFlow Tensor with the data type DataType.INT64
.image
- The TensorFlow Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor.IllegalArgumentException
- if Tensor data type is not long.public static Img<ByteType> imgByteDirect(org.tensorflow.Tensor<org.tensorflow.types.UInt8> image)
ByteType
containing the data of a
TensorFlow Tensor with the data type DataType.UINT8
.
Note that this _does_ adjust the dimensions. This means that
the resulting image will have dimensions directly corresponding to the
shape of the Tensor. See imgByte(Tensor)
and
imgByte(Tensor, int[])
if you want to handle dimensions
differently.
Note also that no exception is thrown if the data type is not
DataType.UINT8
but it will give unexpected results.
image
- The TensorFlow Tensor.public static Img<DoubleType> imgDoubleDirect(org.tensorflow.Tensor<Double> image)
DoubleType
containing the data of a
TensorFlow Tensor with the data type DataType.DOUBLE
.
Note that this _does_ adjust the dimensions. This means that
the resulting image will have dimensions directly corresponding to the
shape of the Tensor. See imgDouble(Tensor)
and
imgDouble(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not double.public static Img<FloatType> imgFloatDirect(org.tensorflow.Tensor<Float> image)
FloatType
containing the data of a
TensorFlow Tensor with the data type DataType.FLOAT
.
Note that this _does_ adjust the dimensions. This means that
the resulting image will have dimensions directly corresponding to the
shape of the Tensor. See imgFloat(Tensor)
and
imgFloat(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not float.public static Img<IntType> imgIntDirect(org.tensorflow.Tensor<Integer> image)
IntType
containing the data of a
TensorFlow Tensor with the data type DataType.INT32
.
Note that this _does_ adjust the dimensions. This means that
the resulting image will have dimensions directly corresponding to the
shape of the Tensor. See imgInt(Tensor)
and
imgInt(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not int.public static Img<LongType> imgLongDirect(org.tensorflow.Tensor<Long> image)
LongType
containing the data of a
TensorFlow Tensor with the data type DataType.INT64
.
Note that this _does_ adjust the dimensions. This means that
the resulting image will have dimensions directly corresponding to the
shape of the Tensor. See imgLong(Tensor)
and
imgLong(Tensor, int[])
if you want to handle dimensions
differently.
image
- The TensorFlow Tensor.IllegalArgumentException
- if Tensor data type is not long.public static <T extends RealType<T>> org.tensorflow.Tensor<?> tensor(RandomAccessibleInterval<T> image)
Note that this does _not_ adjust any dimensions. This means that
the resulting Tensor will have a shape corresponding to the reversed
dimensions of the image. This is probably what you want because
TensorFlow uses the dimension order CYX while ImageJ uses XYC. See
tensorDirect(RandomAccessibleInterval)
and
tensor(RandomAccessibleInterval, int[])
if you want to handle
dimensions differently.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.IllegalArgumentException
- if the type of the image is not supported.
Supported types are ByteType
, DoubleType
,
FloatType
, IntType
and LongType
.public static <T extends RealType<T>> org.tensorflow.Tensor<?> tensor(RandomAccessibleInterval<T> image, int[] dimOrder)
Note that this will use the backing RAI's primitive array when one is available and no dimensions where swapped. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor. TODO Example?IllegalArgumentException
- if the type of the image is not supported.
Supported types are ByteType
, DoubleType
,
FloatType
, IntType
and LongType
.public static <T extends RealType<T>> org.tensorflow.Tensor<?> tensorDirect(RandomAccessibleInterval<T> image)
Note that this _does_ adjust the dimensions. This means that
the resulting Tensor will have a shape directly corresponding to the
dimensions of the image. Make sure the dimensions are as you want
them in TensorFlow. See tensor(RandomAccessibleInterval)
and
tensor(RandomAccessibleInterval, int[])
if you want to handle
dimensions differently.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.IllegalArgumentException
- if the type of the image is not supported.
Supported types are ByteType
, DoubleType
,
FloatType
, IntType
and LongType
.public static org.tensorflow.Tensor<org.tensorflow.types.UInt8> tensorByte(RandomAccessibleInterval<ByteType> image)
Note that this does _not_ adjust any dimensions. This means that the resulting Tensor will have a shape corresponding to the reversed dimensions of the image.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Double> tensorDouble(RandomAccessibleInterval<DoubleType> image)
Note that this does _not_ adjust any dimensions. This means that the resulting Tensor will have a shape corresponding to the reversed dimensions of the image.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Float> tensorFloat(RandomAccessibleInterval<FloatType> image)
Note that this does _not_ adjust any dimensions. This means that the resulting Tensor will have a shape corresponding to the reversed dimensions of the image.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Integer> tensorInt(RandomAccessibleInterval<IntType> image)
Note that this does _not_ adjust any dimensions. This means that the resulting Tensor will have a shape corresponding to the reversed dimensions of the image.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Long> tensorLong(RandomAccessibleInterval<LongType> image)
Note that this does _not_ adjust any dimensions. This means that the resulting Tensor will have a shape corresponding to the reversed dimensions of the image.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<org.tensorflow.types.UInt8> tensorByte(RandomAccessibleInterval<ByteType> image, int[] dimOrder)
Note that this will use the backing RAI's primitive array when one is available and no dimensions where swapped. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor. TODO Example?public static org.tensorflow.Tensor<Double> tensorDouble(RandomAccessibleInterval<DoubleType> image, int[] dimOrder)
Note that this will use the backing RAI's primitive array when one is available and no dimensions where swapped. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor. TODO Example?public static org.tensorflow.Tensor<Float> tensorFloat(RandomAccessibleInterval<FloatType> image, int[] dimOrder)
Note that this will use the backing RAI's primitive array when one is available and no dimensions where swapped. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor. TODO Example?public static org.tensorflow.Tensor<Integer> tensorInt(RandomAccessibleInterval<IntType> image, int[] dimOrder)
Note that this will use the backing RAI's primitive array when one is available and no dimensions where swapped. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor. TODO Example?public static org.tensorflow.Tensor<Long> tensorLong(RandomAccessibleInterval<LongType> image, int[] dimOrder)
Note that this will use the backing RAI's primitive array when one is available and no dimensions where swapped. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.dimOrder
- Defines the mapping of the dimensions between the image
and the Tensor where the index corresponds to the dimension
in the image and the value corresponds to the dimension in the
Tensor. TODO Example?public static org.tensorflow.Tensor<org.tensorflow.types.UInt8> tensorByteDirect(RandomAccessibleInterval<ByteType> image)
Note that this _does_ adjust the dimensions. This means that
the resulting Tensor will have a shape directly corresponding to the
dimensions of the image. Make sure the dimensions are as you want
them in TensorFlow. See tensorByte(RandomAccessibleInterval)
and
tensorByte(RandomAccessibleInterval, int[])
if you want to handle
dimensions differently.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Double> tensorDoubleDirect(RandomAccessibleInterval<DoubleType> image)
Note that this _does_ adjust the dimensions. This means that
the resulting Tensor will have a shape directly corresponding to the
dimensions of the image. Make sure the dimensions are as you want
them in TensorFlow. See tensorDouble(RandomAccessibleInterval)
and
tensorDouble(RandomAccessibleInterval, int[])
if you want to handle
dimensions differently.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Float> tensorFloatDirect(RandomAccessibleInterval<FloatType> image)
Note that this _does_ adjust the dimensions. This means that
the resulting Tensor will have a shape directly corresponding to the
dimensions of the image. Make sure the dimensions are as you want
them in TensorFlow. See tensorFloat(RandomAccessibleInterval)
and
tensorFloat(RandomAccessibleInterval, int[])
if you want to handle
dimensions differently.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Integer> tensorIntDirect(RandomAccessibleInterval<IntType> image)
Note that this _does_ adjust the dimensions. This means that
the resulting Tensor will have a shape directly corresponding to the
dimensions of the image. Make sure the dimensions are as you want
them in TensorFlow. See tensorInt(RandomAccessibleInterval)
and
tensorInt(RandomAccessibleInterval, int[])
if you want to handle
dimensions differently.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static org.tensorflow.Tensor<Long> tensorLongDirect(RandomAccessibleInterval<LongType> image)
Note that this _does_ adjust the dimensions. This means that
the resulting Tensor will have a shape directly corresponding to the
dimensions of the image. Make sure the dimensions are as you want
them in TensorFlow. See tensorLong(RandomAccessibleInterval)
and
tensorLong(RandomAccessibleInterval, int[])
if you want to handle
dimensions differently.
Also note that this will use the backing RAI's primitive array when one is available. Otherwise a copy will be made.
image
- The image which should be put into the Tensor.public static <T extends RealType<T>> Img<T> reverse(Img<T> image)
d0,d1,...,dn -> dn,...,d1,d0
.public static <T extends RealType<T>> RandomAccessibleInterval<T> reverse(RandomAccessibleInterval<T> image)
d0,d1,...,dn -> dn,...,d1,d0
.Copyright © 2014–2022 ImageJ. All rights reserved.