Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

•Re: GIF patent

by merlyn (Sage)
on Jun 18, 2003 at 20:09 UTC ( #266973=note: print w/replies, xml ) Need Help??


in reply to GIF patent

PNG is not a lossy compression technique while JPEG, well, yes.
Please stop saying that as if it was a bad thing. JPEG is not lossy on the things it was meant to capture: natural images. For a fixed number of output bits, JPEG is less lossy on natural images than PNG could ever be.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: GIF patent
by sauoq (Abbot) on Jun 19, 2003 at 02:49 UTC
    JPEG is not lossy on the things it was meant to capture: natural images.

    JPEG is just as lossy with natural images as it is with everything else. It's the same algorithm no matter what the image source. The key factor, which you neglect to mention, is the human eye. With the right subject matter and the right compression "quality" setting, most people won't be able to distinguish, by eye, the JPEG from an uncompressed format. Software will though. (Thus, we don't store satellite imagery, for example, in JPEG because of the need for automated analysis.)

    For a fixed number of output bits, JPEG is less lossy on natural images than PNG could ever be.

    The number of output bits is irrelevant. It's the number of input bits that matters. Neither PNG nor JPEG provides a way to say "compress this image to exactly X bytes." The issue is whether you can decompress your data and retrieve, unaltered, the original input.

    It's simple. Both PNG and JPEG are compressed file formats. JPEG makes a trade-off: a slight loss of information for a smaller file size. That's why it is called lossy. PNG doesn't make that trade-off. That's why it is called lossless. Trying to look at it bass-ackward, from the perspective of how many output bits each format results in, and claiming JPEG is "less lossy" than PNG isn't helping anyone, especially not those that are unfamiliar with the concepts.

    I know you already understand this merlyn, but instead of a condescending response tainted with a judgement about the original poster's tone ("please stop saying that as if it was a bad thing") why not just make your point...

    "JPEG is a very good format for its intended use."

    -sauoq
    "My two cents aren't worth a dime.";
    
      Neither PNG nor JPEG provides a way to say "compress this image to exactly X bytes."

      Just because your image software doesn't have a slider for this, doesn't mean that isn't exactly what you are doing. When you prepare an JPG for the web, you select a compression ratio. If the final image isn't small enough, you select a higher compression ratio and try again, till you hit the desired size.

      There's no ratio dial for PNG images though. The only way to make the file smaller is to resize it. Again, there's no dial or slider for "desired file size". You shrink the image until it is the desired file size.

      Both these processes degrade the image.

      merlyns view is only arse-forwards if you are facing the wrong way (arse-backwards makes no sense, your arse is always backwards) . merlyn has thought about the situation and noticed that both resizing something and lossily compressing something result in less of an intangible thing, which usually gets called 'information'.

      Yes, he made a silly statement with "jpeg is not lossless", although it can work in lossless mode if you want it too. But he then made the good point that thanks to the design of JPG's algorithm, JPG usually gives better. more accurate pictures than a PNG of the same size.

      And regarding the satellite imagery - the same situation as the web occurs, but because you are focussing on the word 'lossless', you are missing the bigger picture, where the trade-off is made.

      When the Martian lander transmitted its pictures back, the engineers had to make a choice. They had a fixed (quite small) bandwidth. That's like the file size merlyn was talking about. To fit a picture into this bandwidth, they could either: reduce the picture size or lossily compress it.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.

      PNG doesn't make that trade-off.
      No, but PNG makes a different tradeoff... a maximum width-by-height resolution for a given number of output bits.

      They're both lossy, just in different directions. Information theory says so. You take the entire rich original experience, and put it into 100K. PNG and JPEG just do it differently. PNG sacrifices width-and-height, while JPEG sacrifices some of the subtler items of a natural image.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        They're both lossy, just in different directions.

        Now I'm beginning to wonder if you really haven't gotten yourself confused.

        for a given number of output bits.

        Forget the output bits. It's the input bits that matter. PNG doesn't truncate¹ the input data. If you want to do that in order to achieve the same output size, that's your business, not your file format's.

        There just aren't two ways about it. PNG isn't lossy as long as you define the term "lossy" in a manner everyone else who talks about compression will understand. Using Information Theory as an excuse to suggest we hold output size constant and then redefine "lossy" to mean "lower compression ratio" doesn't help understanding or foster meaningful communication. Nor is it cool.

        1. I'm using the term "truncate" loosely, of course. I mean to say that conversion to PNG doesn't delete pixel data from the source image.

        -sauoq
        "My two cents aren't worth a dime.";
        
        You are using a different definition of lossy from everyone else. Lossy means that information is lost in the compression process; the output is different from the input. PNG is not lossy; the exact image is reconstructed.

        You are comparing how much original image can fit into a fixed size of compressed image. This is a backwards way to look at things. I guess it makes some sense if you are trading off compression quality, image size, and number of images on a fixed size memory card. Most people have fixed size images that need to compress to the minimum size without too much loss of quality.

        The compression depends heavily on what the original image looks like. You can compress an enormous, single color image much better with PNG. JPEG would result in smaller input images for the fixed output size. For photos, the reverse is true. But this only holds when the quality reduction is acceptable. For some applications, the output image must be 100% the same as the input. Only lossless compression is acceptable in that case.

Re: •Re: GIF patent
by DrHyde (Prior) on Jun 18, 2003 at 21:21 UTC
    Well, mostly. But once something has been JPEGified it is for many intents and porpoises uneditable, because it's a lossy format. This is why I get slightly irritated that my digital camera defaults to saving stuff as JPEG. Thankfully, it can do TIFF too.
Re^2: GIF patent
by Aristotle (Chancellor) on Jun 30, 2003 at 21:04 UTC

    I've pondered this argument a long time because something in it didn't sit right with me. I agree with you, but then sauoq is correct as well.

    The problem is we're talking about two different levels here.

    One is the representation of an image. Even capturing it on any kind of media is already a lossy step, because nothing short of an exact replica of of the entire scenery (that is, in meatspace, with the exact same materials and everything used) can ever record that image absolutely faithfully. Here indeed PNG is lossy as well - by definition, in fact, since there is no such thing as a lossless image capture media.

    The other is the representation of a finite stream of bits. On this level it is certainly very possible to achieve an entirely faithful capture of the input. I don't think we need to argue this any further.

    I agree with you insofar as people do tend to confuse these issues. However, you failed to point out the distinction as well. I knew both positions in the argument where right even though they seemed to conflict - and even though I'd consider myself at least somewhat knowledgable of information theory, and it is so very obvious in hindsight, it is obviously easy to confuse these.

    Also note that repeated reserialization of an image into a bit stream as performed by JPEG will reduce the accuracy of the reconstructed input. JPEG being "lossy" in both sense thus is a downside if you're going to manipulate the image further. It is a mighty fine final storage format, of course.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://266973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2019-12-16 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?