PIL Image with mode 1

Viewed 228

I have a segmentation dataset with PIL image mode '1'. What does it mean and how can I proceed? I have gone through documentation https://pillow.readthedocs.io/en/stable/handbook/concepts.html, and the explanation given is, 1 - (1-bit pixels, black and white, stored with one pixel per byte).

Is it a grayscale image? or a binary image? Any reference to know about it more? And if we try to convert this into RGB image, will it be correct?

1 Answers

It's a binary image. Each pixel can store one of two possible values, zero or one. Each pixel is represented by one byte. That means that although all the bits could theoretically be shifted to become adjacent and thereby store 8 pixels in one byte, they have NOT done that and they, somewhat wastefully, only store one (one-bit) pixel in one byte.

It is not a greyscale image because that is a single channel where each pixel is some value on a sliding scale between a lower and an upper limit, often 0..255 or 0..65535 or some other scale.

You could convert it to colour but it will still look black and white unless you take other steps - similar to tinting or toning or only putting the binary values in one channel, but even then it is going to look "two tone" and not exhibit any gradations of colour.

Related