Kumita← Open visual lesson

Pixel Value Normalization

The code behind the picture

Follow the lesson’s implementation, one code cell at a time.

Choose a language and read the cells in order. These are small teaching examples; the visual lesson runs separately.

Follow the calculation

Same inputs · Same operation · Same result

3 teaching cells · Python standard library · Read-only

  1. 1. Prepare the inputs

    Use these small, explicit inputs to follow the calculation.

    import json
    
    values = [0, 128, 255]
  2. 2. Change the numerical ruler

    Divide each byte value by 255. Retain full precision; rounding is only for display.

    result = [value / 255 for value in values]
  3. 3. Inspect the result

    Print the result as JSON so both languages use the same output format.

    print(json.dumps(result))

Expected result

Running the three cells in order produces this result in either language.

[
  0,
  0.5019607843137255,
  1
]