Image to tensorπŸ”—

Takes in an image and outputs a dense tensor in a predefined format.


  • image: Any image.

  • layout: Layout of output tensor.

  • outputType: The data type of output tensor elements.

  • normalizeIntensity: A Boolean flag that enables or disables intensity range normalization. If enabled, the intensity levels of the input image are scaled by equation β€œout = ((in / channel_max) * max - offset) / divisor” before they are copied to the output tensor. This is done separately for each color channel. See normalizationFactors.

  • normalizationFactors: A 3-by-3 matrix that contains the max, offset and divisor values for each color channel. Only the first row is used with grayscale images.


  • tensor: A tensor in the defined format. If the input is an RGB image, the output tensor will have three elements in the β€œc” dimension. Gray images produce just one. Use color converting to convert gray levels to RGB if needed. The β€œw” and β€œh” dimensions will match the size of the input image. Use image scaling or cropping as a preprocessing tool to fix the tensor size if required by the application. In NCHW and NHWC layouts, the batch size (β€œn”) will be one.

enum LayoutπŸ”—

Supported data layouts.


enumerator ChwLayoutπŸ”—

Channels, height, width.

enumerator HwcLayoutπŸ”—

Height, width, channels.

enumerator NchwLayoutπŸ”—

Batch, channels, height, width.

enumerator NhwcLayoutπŸ”—

Batch, height, width, channels.

enum OutputTypeπŸ”—

Supported tensor data types.


enumerator FloatπŸ”—
enumerator Float16πŸ”—
enumerator DoubleπŸ”—
enumerator Uint8πŸ”—
enumerator Int8πŸ”—
enumerator Uint16πŸ”—
enumerator Int16πŸ”—
enumerator Uint32πŸ”—
enumerator Int32πŸ”—
enumerator Uint64πŸ”—
enumerator Int64πŸ”—
enumerator BooleanπŸ”—
enumerator FloatComplexπŸ”—
enumerator DoubleComplexπŸ”—