Search code examples
pythonimagemachine-learningnormalizationscikit-image

scikit-image (io.imread) returns floating point array, is this already normalized?


I'm importing grayscale images that are RGBA (4-channels) formatted using scikit-image.

from skimage import io

example = io.imread("example.png", as_gray=True)
print(example.shape)
print(example)
plt.imshow(example)

I was expecting to get an array with values in the range 0-255. However, I found in the docs, that the above method returns an array of (64-bit) floating points.

Does this mean the values are already normalized (X / 255)? Or do I need to be aware of something else? Thanks in advance.


Solution

  • Min-Max Feature Scaling aka Min-Max Normalization / Unity-based Normalization is a technique that brings all values in a set into the range [0, 1] (or an arbitrary range [a, b]).

    The mathematical definition of min-max normalization is as follows:

    enter image description here

    Notice that calling np.max(example) will result in a value less than or equal to 1.0.

    Notice that calling np.min(example) will return a value greater than or equal to 0.0.

    Yes, the features have been normalized such that a=0 and b=255 in the equation above.