Class ImageToNDArrayConfig


  • public class ImageToNDArrayConfig
    extends java.lang.Object
    Configuration for converting Images to NDArrays.

    The following can be configured:

    • height: Output NDArray image height: leave null to convert to the same size as the input. Default: null
    • width: Output NDArray image width: leave null to convert to the same size as the input. Default: null
    • datatype: NDArrayType (data type) of the output array
    • includeMinibatchDim: If true: the output array will be rank 4 with shape [1, c, h, w] or [1, h, w, c]. If false: return rank 3 array with shape [c, h, w] or [h, w, c]. Default: true
    • aspectRatioHandling: How should input images with different aspect ratio to the output height/width be handled? Default: CENTER_CROP
      • CENTER_CROP: Crop the larger dimension down to the correct aspect ratio (and then resize if necessary).
      • PAD: Zero pad the smaller dimension to make the aspect ratio match the output (and then resize if necessary)
      • STRETCH: Simply resize the image to the required aspect ratio, distorting the image if necessary
    • format: CHANNELS_FIRST (output shape: [1, c, h, w] or [c, h, w]) or CHANNELS_LAST (output shape: [1, h, w, c] or [h, w, c])
    • channels: The layout for the returned array. Note input images will be converted if necessary. Default: RGB
      • RGB: 3 channels, ordered according to: red, green, blue - most common for TensorFlow, Keras, and some other libraries
      • BGR: 3 channels, ordered according to: blue, green, red - the default for OpenCV, JavaCV, DL4J
      • RGBA: 4 channels, ordered according to: red, green, blue, alpha
      • BGRA: 4 channels, ordered according to: blue, green, red, alpha
      • GRAYSCALE: 1 channel - grayscale
    • normalization: How the image should be normalized. See ImageNormalization - support scaling ([0,1] range), subtracting mean (out = (in-mean)), standardization (out = (in-mean)/stdev), inception ([-1, 1] range) and VGG mean subtraction (fixed out = in - meanRgb, where meanRgb is hardcoded to [123.68, 116.779, 103.939]. Default: simple scale normalization ([0, 1] range). Note: If image normalization in null, or ImageNormalization.type == Type.NONE, no normalization is applied.
    • listHandling: Only applies in situations such as ImageToNDArrayStep, and only when List<Image> is passed in instead of Image. This setting determines what the output should be. NONE: Error for List<Image> input (only single Images are allowed). BATCH: a single output NDArray is returned, with the images batched along dimension 0. LIST_OUT: A List<NDArray> is returned instead of a single NDArray - one entry for each entry in the input List<Image>. FIRST: the first bounding box only is returned as as single NDArray - the remainder are discarded/ignored.
    Author:
    Alex Black