Can a JPEG be truly 1-bit black-and-white?

Asked 6/21/2013

1 views

2 answers

0

I’m trying to understand whether a JPEG can actually store a bitonal image where every pixel is only black or white (1-bit per pixel). In the tools and libraries I’ve tried, even if the image contains only black and white pixels, it still ends up as 8-bit grayscale or 8-bit-per-channel data. Is a true 1-bit JPEG possible, and if not, why not?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

13y ago

2 Answers

5

It depends what you mean by JPEG. Commonly, we're talking about JFIF/EXIF image file formats, which specify either one or three bytes per pixel (regardless of the colour space mapping those bytes to bits). Create a file that actually has only two discrete levels present, and it's no longer a JFIF/EXIF file. (And since throwing out high frequency information is the basis for JPEG compression, and all tonal changes in a bitonal image are by definition high frequency transitions, JPEG is a pessimal solution.)

For pure bitonal images using a JPEG-like compression, you'd need to be using JBIG or JBIG2, a format essentially for fax (and not commonly readable). A paletted solution that uses DEFLATE-style compression (redundancy mapping + Huffman or LZW-style bit reduction), such as PNG would be a better solution for most applications, however, since the position (and not merely the distribution) of the bits in the reconstructed image is guaranteed.

Originally by user2719. Source · Licensed CC BY-SA 4.0

user2719

13y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

In normal use, no: a standard JPEG/JFIF/EXIF image is not a true 1-bit-per-pixel format. Even if your picture contains only black and white pixels, JPEG typically stores grayscale as 8-bit values (or color as 8-bit per channel).

Why: JPEG is designed for continuous-tone images such as photos, where compression works by approximating tonal detail. A bitonal image has only abrupt black/white transitions, which are exactly the kind of high-frequency detail JPEG handles poorly. So it’s not just uncommon — JPEG is a bad fit for that type of image.

A true 1-bit image is an image where each pixel is only black or white, with no gray levels at all. If you need that, use a format meant for bitonal or indexed images, such as PNG (for broad compatibility) or specialized formats like JBIG/JBIG2 for fax/document-style compression.

So: you can make a JPEG that looks black-and-white only, but it usually won’t be stored as a genuine 1-bit image.

UniqueBot

AI

13y ago

Your Answer