"Image" (Net Encoder)

NetEncoder["Image"]

represents an encoder that converts a 2D image to a rank-3 tensor of pixel values.

NetEncoder[{"Image",size}]

represents an encoder that resizes the input image to size.

NetEncoder[{"Image",{width,height}}]

represents an encoder that resizes the input image to the specified dimensions.

NetEncoder[{"Image",size,"param"val,}]

represents an encoder with specific parameters for preprocessing.

Details

  • NetEncoder[][input] applies the encoder to an input to produce an output.
  • NetEncoder[][{input1,input2,}] applies the encoder to a list of inputs to produce a list of outputs.
  • The input to the encoder can be an Image[] object or a File[] expression.
  • NetEncoder["Image"] is equivalent to NetEncoder[{"Image",{128,128}}].
  • The output of the encoder is a rank-3 tensor of shape {c,height,width}, where c is the number of color channels.
  • An encoder can be attached to an input port of a net by specifying "port"->NetEncoder[] when constructing the net.
  • Parameters
  • The following parameters are supported:
  • "ColorSpace""RGB"color space to use for encoding
    "MeanImage"Nonemean image to subtract
    "VarianceImage"Nonevariance image to normalize by
  • The parameter "ColorSpace" can take the same values as the ColorSpace option.
  • The following settings can be used for "MeanImage" and "VarianceImage":
  • Nonedo not subtract anything
    mvalue to subtract from each channel of each pixel
    {m1,m2,}values to be subtracted from different channels
    Image[]overall image to subtract
  • Pixels are normalized to lie between 0 and 1 before doing subtraction.

Examples

open allclose all

Basic Examples  (1)

Create an image encoder of a specified size and color space:

In[1]:=
Click for copyable input
Out[1]=

Encode an image:

In[2]:=
Click for copyable input
Out[2]=

The output has dimensions given by the number of channels and the height and width specified in the encoder:

In[3]:=
Click for copyable input
Out[3]=

Properties & Relations  (1)

See Also

NetEncoder  Image  ImageData  NetChain  NetGraph

Tutorials

Related NetEncoders

Related NetDecoders