Skip to content

Processing Blocks

Image block

Make every picture the same size and scale its pixels, so the model always gets the same kind of input.

Try it in Studio
On this page

What is this block?

Image is the processing block for Image projects. It takes each photo, resizes it to one fixed size, and turns its pixels into numbers between 0 and 1. It is the only processing block in Image projects.

Why do we use it?

Your photos come in many sizes, but a neural network needs every input to have exactly the same shape. Smaller inputs also make the model faster and smaller on your device. The block also moves your bounding boxes so they still fit the objects after resizing.

How does it work?

  1. Reads the photo.
  2. Resizes it to Image width × Image height using the Resize mode.
  3. Optionally turns it into grayscale (Color channels).
  4. Divides every pixel value by 255, so values go from 0 to 1.
  5. Applies the same resize to every bounding box.
Resize modeWhat happens
Fit shortest axis (default)Resizes so the shortest side fits, then crops the centre. Fills the frame, but cuts off the edges.
Fit longest axisResizes so the longest side fits, then adds padding. Keeps the whole photo.
SquashStretches the photo to fit and ignores the aspect ratio.

What input does it receive?

JPG or PNG images of any size, with their bounding boxes.

What output does it produce?

An image of width × height × 3 numbers for RGB, or width × height × 1 for grayscale.

Example: the default 96 × 96 RGB image is 96 × 96 × 3 = 27,648 numbers.

What do its settings mean?

Width, height and resize mode are first set on Create impulse. You can change them on the block's parameters tab, then select Save parameters.

SettingDefaultWhat changing it does
Image width96Wider images keep more detail but make the model slower and bigger.
Image height96Same as width. Square sizes are the most common.
Color channelsRGBGrayscale uses one channel instead of three: three times fewer numbers, but no colour information.
Resize modeFit shortest axisHow the photo is fitted into the new size (see the table above).

Each model has its own size rules:

ModelImage size
NanoVisionAt least 96 × 96
Vision ProRounded up to a multiple of 32 (at least 96)
EdgeDetect LiteExactly 320 × 320

After saving, open the generate features tab and select Generate Features. The Feature explorer then shows your training images as points. Images that look alike end up close together.

Simple example

A 640 × 480 photo with Fit shortest axis and a 96 × 96 size:

  1. The short side (480) is scaled to 96, so the photo becomes 128 × 96.
  2. The centre 96 × 96 is kept; 16 pixels are cut from the left and the right.
  3. A box that was near the left edge of the original photo may be partly or fully cut off.

With Fit longest axis, the same photo becomes 96 × 72 with black bands above and below, so nothing is cut off.

When should I use it?

  • Always: every Image project uses this block.
  • Pick Fit longest axis when objects are often near the edges of your photos.
  • Pick a larger size when your objects are small in the picture; small objects can disappear at 96 × 96.
  • Pick Grayscale only when colour does not matter for telling your objects apart.