Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: •Re: GIF patent

by sauoq (Abbot)
on Jun 19, 2003 at 02:49 UTC ( [id://267058]=note: print w/replies, xml ) Need Help??


in reply to •Re: GIF patent
in thread GIF patent

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.";

Replies are listed 'Best First'.
Re: Re: •Re: GIF patent
by jepri (Parson) on Jun 20, 2003 at 02:51 UTC
    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.

•Re: Re: •Re: GIF patent
by merlyn (Sage) on Jun 19, 2003 at 03:13 UTC
    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.";
      
        PNG doesn't truncate¹ the input data.
        Right, because it doesn't need to, since that had to have been done in the first place when you picked a width-and-height.

        Think of it this way. From the original image, for a given output file size, there is an upper bound on the number of pixels times the absolute accuracy of each pixel times the overall accuracy of the image. Information theory tells us that. PNG choses to hold the overall accuracy and absolute accuracy constant, thus bounding the number of pixels. JPEG choses to hold only the overall accuracy of the picture constant, thus allowing the number of pixels to vary inversely with the individual accuracy.

        Certainly, if individual accuracy is important, you can't use JPEG. I'm not arguing that. I'm just saying that at some point, you had to go from "real world continuous values" into "discrete values stored in a file". That's lossy. PNG just lets you pick certain things to hold sacred in that process, and JPEG lets you pick certain other things to hold sacred. I'm happy we have both.

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

      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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-26 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found