Q: Best lossless format for bitonal images?

Ask for help and post your question on how to use XnView Classic.

Moderators: helmut, XnTriq, xnview

Post Reply
Hacker
Posts: 242
Joined: Tue May 17, 2005 9:24 pm
Location: Bratislava, Slovakia
Contact:

Q: Best lossless format for bitonal images?

Post by Hacker »

Hi *.*,
In your opinion (or are there any comparative tests?), what is the best - compresses the most - format for bitonal (containing only two colors - black and white) images?

PNG greyscale seems to be nice, I am also about to give a chance to BMF 1.1 and 2.0 beta, but is there not some format specialized in such images?

TIA
Roman
User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken »

Are you talking about a true bitonal image, or a scanned black & white paper? There's a big difference. While scanned papers appear to only have 2 colors, they actually have many, and can look quite bad when forced down to just black & white. If it's a true black & white image, try JBIG. The JBIG format was specifically designed for b/w images. If it's a scanned paper, JPEG2000 is probably your best bet (although I've never tried BMF, so that might or might not be better). (Make sure to use the one that says "lurawave jpeg 2000", the other one only works on truecolor images. (If you get a "contact your dealer" error when saving, you're using the wrong one.))
Danny
Posts: 578
Joined: Sat Sep 04, 2004 5:09 pm

Post by Danny »

Try TIFF with CCITT compression.
User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken »

I just ran some tests using a true 2-tone image, and a greyscale image that looks like 2-tone. I didn't try BMF, but out of the formats Xnview can save in, JBIG was the best in both cases. PNG was a close second (PNG recompressed with PNGout was #1 for the true 2-tone image). TIFF with ZIP compression was surprisingly good on the 2-tone image (3rd place), TIFF with CCITT compression was 4th (tied with TIFF with LZW compression). TIFF was terrible on the greyscale image, more than 8x the size of the PNG and JBIG file, and about 4x the size of the JP2 and LDF files.
2-tone
======
PNGout-5,554 bytes
JBIG-6,117 bytes
PNG-6,131 bytes
TIFF-8,313 bytes
LDF- 119,728 bytes
JP2k-125,183 bytes

greyscale (16)
=========
JBIG-49,993 bytes
PNGout-45,183 bytes
PNG-52,684 bytes
LDF-112,876 bytes
JP2k-159,493 bytes
TIFF-450,175 bytes (NO SAMPLE, I'm not uploading a 440k image)



This is what happens when you take a greyscale image and force it to be bitonal.
Hacker
Posts: 242
Joined: Tue May 17, 2005 9:24 pm
Location: Bratislava, Slovakia
Contact:

Post by Hacker »

Drahken,
Are you talking about a true bitonal image, or a scanned black & white paper?
Can a scanned black & white paper not be a bitonal image? ;)
I am talking about bitonal which I got from grayscale scanned in paper after using the Threshold function.

Thanks for the tests and recommendations. However, there doesn't seem to be a JBIG format in XnView. How do I get it or what do I do wrong? I am using 1.80 RC5.

TIA
Roman
User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken »

Can a scanned black & white paper not be a bitonal image?
No, it can't. As I said in that first post, "While scanned papers appear to only have 2 colors, they actually have many, and can look quite bad when forced down to just black & white." While they appear to be just black & white, they actually contain several shades of grey. If you try to force it to be bitonal, the lines and letters will look all rough and jagged, like THIS In fact, even trying to reduce it to too few shades of grey can result in an ugly image. The greyscale images I posted for example, have 16 shades. I had tried only 8 shades, and they looked bad.

However, there doesn't seem to be a JBIG format in XnView.
Considering that I made all those images with xnview (including the jbig), and that no program on my comp other than xnview can even read a JBIG file.....
I'm using 1.74 + plugins. I don't know if A) 1.8x still contains JBIG, B) you need a plugin for JBIG, or C) you're just not seeing it. When you save the image, look in the dropdown for the file formats. They're in order, so JBIG (possibly as just JBG) should be just above JPG and JP2.
Hacker
Posts: 242
Joined: Tue May 17, 2005 9:24 pm
Location: Bratislava, Slovakia
Contact:

Post by Hacker »

Drahken,
No, it can't.
;) Oh come on, yes it can. Sure it won't look great, but it's readable (and possible).
I'm using 1.74 + plugins.
Hmm, well, I certainly don't have it there. Ctrl-U, Format shows IMG, JIF, JP2, JP2, JPC, JPC, JPG, JPM, LDF.

Roman
User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken »

Yes, technically it's possible. However, doing so would produce a much lower quality image than if you used a lossy format, so in the context of your original question it isn't possible. Looking for a lossless format to save it in and then doing something that degrades the quality as much as forcing it to be bitonal does is like shooting yourself in the foot.


Hmm... it's odd that you have the JP2 family of formats and LDF, but no JBG. 1.74 can't save as JBG without plugins, but without plugins it can't save as JP2 or LDF either. I would suggest downloading and installing the plugins if you haven't already. If you have, then you should make a post in the 1.8 subforum and ask why it doesn't have JBIG support.
Alternatively, just grab 1.74 and the plugins.

...or just go for PNG (make sure to reduce colors before saving), since it's only slightly larger.
Post Reply