PDA

View Full Version : image compression


cypher_soundz
9th March 2004, 02:39
Hi,
As video compression and image compression are kind of the same (I know not totally but the basic concepts) I was wondering what the best compression for images are...png seem good. I found that smoothing a image does not help its compressibility.
So what compression do you recommend? are there any up and coming compressions? Like AAC for the image world?
Regards
Cyph

EDIT : i found this site (http://www.leadtools.com/SDK/Raster/Raster-Compression.htm) which tells you about different image compressions, jpeg2000 looks good. can't find a download for it though.

int 21h
9th March 2004, 03:41
http://www.leadtools.com/utilities/psplugin/PhotoShop_plug-in.htm

http://www.pegasusimaging.com/imagepressj2k.htm


Here are two implementations of it. Wavelet compression really delivers some great results in Jpeg2000.

Stux
9th March 2004, 03:56
QuickTime 6 includes JPEG2000

Interstingly (i think) Jpeg2000 uses the same base file format as MP4 ;)

Sirber
9th March 2004, 04:39
JPEG2000 might be good for still pictures, but as a video codec it sucks. I tryed it some months ago.

smok3
9th March 2004, 05:08
i run a fast lossless test j2k vs png:
2.082.985 dsc00610.j2k
2.297.984 dsc00610.png
1.711.447 jesen_listje_smarjeske.j2k
2.048.302 jesen_listje_smarjeske.png
249.879 glava_obrvi_wall.j2k
174.006 glava_obrvi_wall.png
707.295 smoke_joke_paint.j2k
458.264 smoke_joke_paint.png
1.422.131 zid.j2k
2.067.270 zid.png seems like photo-like images will win with j2k and images with less colors will win with png (all images were 24bit).

Neo Neko
9th March 2004, 06:27
Having the "best" compression for images is alot like having the best compression for video. There is no one best. It depends on the type of image to be compressed and the purpose of it's compression. For some purposes anything less than TIFF is to little. For long term archival of every day images found on the web etc PNG is rather hard to beat. If size is an issue Jpeg can deliver but sacrifices quality. Jpeg 2000 is only slightly better than jpeg. But Jpeg 2000 is rather a pain to view.

It just depends. But Tiff is the top of the quality scale. PNG covers most of the high and mid quality scale. And Jpeg covers the lower range of the quality scale. But they are al valid in the correct aplication.

ultimatebilly
9th March 2004, 11:25
I would say that png is best for text and line-art, whereas jpeg or jpeg2000 is best for natural images, like landscapes etc.
If you've ever seen a jpeg from a screenshot with text for example, you will probably have noticed the annoying artifacts around sharp contrasts, which are due to the way high frequencies are treated by jpeg compression with the standard quantization matrix.
I found this interactive jpeg very interesting: Interactive JPEG (http://www.cs.sfu.ca/undergrad/CourseMaterials/CMPT365/material/misc/interactive_jpeg/Ijpeg.html)
In the end it all depends on the image, and what purpose you do need it for.

cypher_soundz
9th March 2004, 11:31
Thanks for the replys, wow so png is still up there at top? i just read my posting (it was late :o ) Sorry for asking which is "best" :rolleyes: I wish png had some options, with jpg you can select quality, would be nice with png as it has a smaller file size with "the same quality" as a larger jpg.
Are there differnet builds of PNG like with say XviD?
are there any free versions of jpg2000 ?
Regards
cyph

duartix
9th March 2004, 13:00
PNG is very good for lossless images.
It's basically something like GIF with improoved (and royaltie free) compression, support for full colour (GIF is limited to 256 colours) but no support for animation. For screen captures it's most of the times better than GIF. Filesize savings of up to 20% are claimed.

JPEG is very good for lossy images.
For photorealistic images JPEG is much better than PNG because contrary to PNG which is lossless, JPEG is a selective lossy approach which can reduce filesize dramaticaly, with limited visible loss in quality. This is acomplished by the use of a DCT transformation.

JPEG2000 or J2K is also very good for lossy images. (Note that it supports lossless compression too, and better than PNG)
J2K instead of DCT is a wavelet based lossy format. For high bitrates, JPEG and J2K are roughly indistinguishable, but for lower ones there is no doubt J2K is vastly superior.
J2K can usually obtain better PSNR than a JPEG double the sise.

I still can't understand why it 's not a standard :(Are there differnet builds of PNG like with say XviD? PNG is a standard so I guess there is just one finished version.are there any free versions of jpg2000 ? No free software that I know of does J2K compression, even though I believe the format to be royaltie free...
Perhaps this explains why it hasn't become a standard.

ultimatebilly
9th March 2004, 14:48
Actually, there is an animated png specification, called MNG (http://graphicswiz.com/png/png-sitemap.html#animation), but unfortunately it isn't widely supported by applications, IIRC even IE lacks support for it...
Too bad, because the patent issues with .gif are still in place in many countries :(

smok3
9th March 2004, 16:13
best support for png making is in gimp:
http://www.gimp.org/ (32 bit as well)

good photoshop plugin is super png:
http://www.fnordware.com/superpng/ (no 32 bit irc, but has a decent 24 bit compression)

edit: example hacks for ie/mozzila (8 bit rgba wont work in ie though)
http://somestuff.org/png/png_test2.htm

smok3
9th March 2004, 16:29
Originally posted by cypher_soundz
I wish png had some options, with jpg you can select quality, would be nice with png as it has a smaller file size with "the same quality" as a larger jpg. png is always lossless, so there is no quality slider.... (that is, png can not replace jpg for its purpose, but can replace gif.)

Soulhunter
9th March 2004, 20:00
I like JPEG with 4:4:4 subsampling... ;)

Bye

Neo Neko
9th March 2004, 21:30
Originally posted by duartix

JPEG is very good for lossy images.
For photorealistic images JPEG is much better than PNG because contrary to PNG which is lossless, JPEG is a selective lossy approach which can reduce filesize dramaticaly, with limited visible loss in quality. This is acomplished by the use of a DCT transformation.

Just never say that in front of a professional photographer or graphic artist. They will likely wanna slap the snot outta you. ;) Using jpeg actually does loose quite alot of info whether you see it or not. And it for the most part destroys the editability of the picture. In those crowds say Tiff or PNG at the verry least.

Originally posted by duartix

JPEG2000 or J2K is also very good for lossy images. (Note that it supports lossless compression too, and better than PNG)
J2K instead of DCT is a wavelet based lossy format. For high bitrates, JPEG and J2K are roughly indistinguishable, but for lower ones there is no doubt J2K is vastly superior.
J2K can usually obtain better PSNR than a JPEG double the sise.

I still can't understand why it 's not a standard :( PNG is a standard so I guess there is just one finished version. No free software that I know of does J2K compression, even though I believe the format to be royaltie free...
Perhaps this explains why it hasn't become a standard.

It does. Jpeg 2000 is a standard. Just not a free standard like PNG. Whereas anyone is free to implement PNG. There are royalties due for Jpeg 2000. This is understandable as those who developed Jpeg 2000 would like to earn something from their work. But largely ignored the market for such a product. Jpeg 2000 lossless? Why? Tiff is still better. Plus Tiff and PNG are still free. Jpeg 2000 lossy? Why? It's not that much better than Jpeg plus Jpeg is free. The biggest market for JPEG/2000 is over the internet. But the Mozilla group earn no money from their browser to pay for licensing. and Microsoft's Internet Explorer has yet to propperly implement free image formats from back in 1997/98 let alone royalty encumbered ones from 2000. That and Microsoft is deathly afraid of innovation. That leaves it up to plugin writers to support it. But that raises a whole new can of worms. As a plugin chances of the format really catching on in browsers is highly limited to begin with. There are a few exceptions like flash. But Jpeg 2000 not being that great or unique stands almost no chance. Add to that "Micro-think"(TM) where by the misconception that the user should never have to download something to support your media or pages is popularised. So that even if there were a plugin it would stand even less chance of sucess unless Microsoft decided to bundle their own Jpeg 2000 implementation with IE 7 if it is ever released. This means no matter how good Jpeg 2000 may be it is largely useless. As there is no use for it there will be few people using it. And therefore little demand to implement it in viewer or editor software. Meaning that Jpeg 2000 will have it's niche. But never see main stream.

smok3
9th March 2004, 21:47
ok, i just tested 2 images, tiff lossless compression vs png: 1.980.774 bigpng.png
2.285.388 bigtiflzw.tif
2.060.436 bigtifzip.tif

19.027 png.png
69.200 tiflzw.tif
35.420 tifzip.tif Neo Neko: how is tiff better?

smok3
9th March 2004, 21:57
Originally posted by duartix
For high bitrates, JPEG and J2K are roughly indistinguishable, but for lower ones there is no doubt J2K is vastly superior.
my limited lossy test mostly confirm your claim (i do like jpg better, but i didnt run enough tests really...). (shortly: there is no blocks with lower bitrates in j2k, but there is well known smearing of the borders.)

virus
9th March 2004, 22:11
Originally posted by duartix
I still can't understand why it 's not a standard :(
Actually, JPEG 2000 is a standard since, well, 2000 :)
(ISO/IEC 15444 - Information technology - JPEG 2000 image coding system)
But they say a new format can't really be considered a "standard" until M$ has written a totally incompatible implementation of it... ;)

PNG is a standard so I guess there is just one finished version. No free software that I know of does J2K compression, even though I believe the format to be royaltie free...
Perhaps this explains why it hasn't become a standard.
there are a few free implementations (btw JPEG 2000 Part 1 is completely royalty-free).
There's a plugin (from LuraTech) provided with IrfanView (IIRC it can save images up to 640x480, if larger you need to register) and there's the excellent and fast Kakadu library from the University of New South Wales, Australia, which is totally free.
The JasPer Project provides source code, too. Try a Google search for the URLs (and enjoy the must powerful, complete and flexible standard for image compression ever created)

@cypher_soundz

if you need lossless compression only, there's JPEG-LS which is both faster and more efficient than JPEG 2000, and w/ better compression than PNG.
Hewlett Packard still gives away a free implementation IIRC (JPEG-LS was derived from a scheme developed at HP Labs and dubbed LOCO)

link: http://www.hpl.hp.com/loco/

@Neo Neko

personally, I don't share your forecasts on JPEG 2000. Baseline is free but the complexity is quite high... that was the same with JPEG in the early 90s.
It will mature. It is much better than JPEG under every point, not only for better lossy compression. I think in the long term it will win. Or, at least, let's hope so. JPEG 2000 confined in a niche would be a defeat for us all.

cheers
virus

Tommy Carrot
9th March 2004, 22:25
Originally posted by cypher_soundz

are there any free versions of jpg2000 ?


Here (http://www.kakadusoftware.com) is a command line encoder, not easy to use but free.

BTW, i cannot see any evidence for the so called superiority of jpeg2000. At lower rates it's better than the good old jpeg, but not convincingly, it just trades the blocks for blurriness. But for high quality purposes it's definitely inferior, it's blurrier and less detailed.

I wonder if this is just my observation or it's really the case. If the latter then it can be the reason behind it's lack of success.

For lossless image encoding i wonder what the algorithm of ffv1 could do, because it beats badly every other lossless video codecs, even though some of them are based on PNG and JPEG-LS.

lakedude
9th March 2004, 22:57
plus Jpeg is free Last time I checked some company was trying to get a group of "meaningful" patents together to challenge their ownership of the JPEG standard. It has been a while and I can't remember the name of the the company. It would be interesting to know how this turned out....

Ohh I just remembered that they sued a couple big companies like Sony and either won or settled.

Must do more research....I'll get back to y'all.

lakedude
9th March 2004, 23:03
Research is done, see:

http://abcnews.go.com/sections/business/DailyNews/jpeg020829.html

and

http://www.forgent.com/company/press_room/dallas_082802.shtml

Joe Fenton
9th March 2004, 23:55
Yet another company that turns to lawsuits to make money when their business fails. There is a rash of those lately. Too many lawyers in a bad economy.

Just another example of why software patents should be made illegal.

cypher_soundz
10th March 2004, 04:26
@all
thanks for the links and info, i'm a little busy for a fews days so i wont have time to try them out , that jpg-ls looks good and if it does like you say then i can't wait to try it out! the jpg2000 cmd line tool seems ok, i will have to write a gui for it if i take to it (i will be sure to post)
just a thought , but could some of the code for Xvid be modified to produce a picture output? with compresion? please corect me if im WAY off :p
Regards
cyph

Neo Neko
10th March 2004, 04:30
Originally posted by smok3
ok, i just tested 2 images, tiff lossless compression vs png: 1.980.774 bigpng.png
2.285.388 bigtiflzw.tif
2.060.436 bigtifzip.tif

19.027 png.png
69.200 tiflzw.tif
35.420 tifzip.tif Neo Neko: how is tiff better?

1. TIFF can store greater color depth. All they way up to 64bit. PNG is only up to 32bit.

2. TIFF can use more color spaces like YCbCr, CMYK, and CIELab as well as RGB, and Greyscale modes. PNG as great as it is; is only RGB.

3. TIFF includes a few more compression types that are some times less computationally taxing. Also JPEG if you really need it.

4. TIFF also supports multipage images or multiple images in one file.

It's not always required. But you can't find better quality than TIFF. If your image is 32bpp or less RGB then you would basically always be better off using PNG.

So in terms of absolute picture quality from best to worst the scale goes TIFF->PNG->JPG. What makes judgement dificult is when you throw in other factors like file size restriction. And that is why it depends on the aplication as to which one is best.

int 21h
10th March 2004, 07:37
Fact 1: As stated earlier, the baseline JPEG2000 is royalty-free and license-fee free. Quoting from the Jpeg-2000 Wiki:

JPEG2000 is not widely supported in present software due to the perceived danger of software patents on the mathematics of the compression method, this area of mathematics being heavily patented in general.

The JPEG committee has stated:

It has always been a strong goal of the JPEG committee that its standards should be implementable in their baseline form without payment of royalty and license fees ... The up and coming JPEG 2000 standard has been prepared along these lines, and agreement reached with over 20 large organisations holding many patents in this area to allow use of their intellectual property in connection with the standard without payment of license fees or royalties.

However, the JPEG committee has also noted that undeclared and obscure submarine patents may still present a hazard:

It is of course still possible that other organisations or individuals may claim intellectual property rights that affect implementation of the standard, and any implementors are urged to carry out their own searches and investigations in this area.



Fact 2: TIFF (because of its LZW compression) has not always been free and unencumbered. In fact, up until June 2003 (in the United States, June 2004 internationally), Unisys actively enforced their patent and caused quite a disturbance back in the day. PNG was developed actively as an unencumbered alternative. (http://news.bbc.co.uk/1/hi/technology/3007862.stm)

Fact 3: Anyone working in the digital camera field will tell you, capture in RAW! Most camera CCDs capture 12 or 16 bits per pixel, and RAW simply takes the captured CCD data and stores it (sometimes huffman encodes it, or similar) Usually TIFF is interpolated up to 24 bits per pixel (minimum)... this results in a smaller RAW filesize vs. TIFF filesize for most camera applications. (Not too mention the infinite benefits of having RAW formatted pictures, i.e. true white balance control, etc.)

Its already been said, the choice depends greatly on your application. If you're using a digital camera and have the choice between JPG, TIFF, and RAW, choose RAW. If you're just editing clipart on your workstation, its likely you don't have the same choices available to you.

And I forgot:

Fact 4: PNG supports 16-bits per channel (x4 RGBA) for a total of 64-bit depth. (Read the faq: http://www.libpng.org/pub/png/pngfaq.html)

duartix
10th March 2004, 13:31
@Virus:
My bad. :(
When I said I didn't understand why J2K hasn't become a standard (which I know it is) I meant for the user. I expected it to be as widely used as JPEG or MP3. I expected digital cameras to store files as J2K 3 years ago...

@Tommy Carrot:BTW, i cannot see any evidence for the so called superiority of jpeg2000. At lower rates it's better than the good old jpeg, but not convincingly, it just trades the blocks for blurriness. But for high quality purposes it's definitely inferior, it's blurrier and less detailed. I was talking about PSNR values (and perceived image quality) from what I gathered here:

http://www.aware.com/products/compression/demos/lena_compare.html
http://www.aware.com/products/compression/demos/girl_compare.html
http://www.aware.com/products/compression/demos/compare_kids.html

But since you raised the rabbit, I've downloaded this testing tool:
http://www.leadtools.com/adtk/leaddownload.asp?Download=J2KDemo13&Dest=http://www.leadtools.com/evaldownloads/jpeg2kDemo/LEADTOOLSJPEG2000Demo.exe and now I'm not so sure...:scared:
Bad Tommy !!! ;)

Tommy Carrot
10th March 2004, 14:37
Hehe, it's always great to spoil the fun. :D :D

But seriously, did you have the same observation, jpeg2000 is not doing so well at high quality image compression?

Originally posted by cypher_soundz

just a thought , but could some of the code for Xvid be modified to produce a picture output? with compresion? please corect me if im WAY off :p


I suppose it's possible, but the keyframe algorithm of h.264 would be even better.

duartix
10th March 2004, 16:28
The tool doesn't allow less than around 15x compression.
Here are my findings with this (http://public.fotki.com/duartix/thailand_-_phi_phi/) image:

at 15x :
JPEG has some minor ringing and has more texture (noise in original).
J2K has no ringing and is cleaner. Doesn't lack detail but noise texture is absorbed. Almost invisible blocks in sky.

at 26x :
JPEG has moderate ringing and preserves a lot more noise from the original. Has some small sized blocks on beach sand.
J2K still has no ringing and is cleaner than before. Doesn't lack detail but noise texture is almost lost. Medium sized blocks start to show on textured beach sand. Some larger blocks also on sky but less visible.

at 42x :
JPEG has hard ringing already and small blocks scattered everywhere. Texture on sand is still better than J2K.
J2K still manages no ringing at all. Noise texture is completely lost. Blocks on textured beach sand are bigger but somehow harder to spot. Blocks on sky still big but hardly visible.

at 68x :
JPEG has horrible ringing and small blocks are everywhere.
J2K still manages almost no ringing at all. There is no noise texture. Textured sand is already blurred. Blocks on textured beach sand and sky still big, but you still have to look for them to spot them.

at 100x :
JPEG is blocked beyond common use.
J2K starts to show some ringing. Textured beach is more blurred but the sky is still very good. Same kind of blocks.

at 125x :
JPEG has already massive colour dithering. Useless beyond hope.
J2K shows moderate ringing. Textures are very blurred but overall the file is still very usable. Some large region blocks are spotable.

From my personal taste, from 26x and further the ringing and blocking will make me vote for J2K. At higher bitrates I guess JPEG preserved a lot more texture (original image noise) even if I would tie them on detail.

This was a limited test with a "relatively" clean image.
Cleaner images will favour J2K even more, whilst in another picture I had use to test before (with more digital camera noise) my results were in favour of JPEG because J2K was blurring too much.

virus
10th March 2004, 19:53
Originally posted by Tommy Carrot
But seriously, did you have the same observation, jpeg2000 is not doing so well at high quality image compression?
JPEG 2000 is optimized for very low rates (below 1.0 bpp), but going near 1.5 bpp or above it should provide the same quality than JPEG. This means that someone may like JPG, and someone JP2 ;)
Both schemes are not so good for high quality, though. If you want to compress at high bitrates, I'd suggest to try a lossless scheme working in "near-lossless" mode (JPEG-LS can do that). It usually delivers great quality with very low hardware requirements.

But the power of JPEG 2000 relies not only on pure compression... the embedded bitstream which already contains lower resolution versions of the image (i.e. thumbnails) is an example. The simultaneous support for lossy/lossless compression is another strong point. What about the ability to split your image in parts ordered by resolution, or by component, or by layer (with different bitrate for every layer)? Or the ability to code arbitrary-shaped regions of interest in a very clever way, almost without side information to be coded? And so on... ;)

cheers
virus

duartix
10th March 2004, 20:45
But the power of JPEG 2000 relies not only on pure compression... the embedded bitstream which already contains lower resolution versions of the image (i.e. thumbnails) is an example. The simultaneous support for lossy/lossless compression is another strong point. What about the ability to split your image in parts ordered by resolution, or by component, or by layer (with different bitrate for every layer)? Or the ability to code arbitrary-shaped regions of interest in a very clever way, almost without side information to be coded? And so on... Yes, besides incredible detail preservation at extreme low bitrates, is fun (and very usefull too) to have progressively detailed images (or colour layers) as the transmission goes on...
Think about it!
(Almost) instant thumbnails! :D :D :D As the image is downloading, the detail level is increased 2x, 4x, 8x, 16x ...