Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: •Re: Re: •Re: GIF patent

by sauoq (Abbot)
on Jun 19, 2003 at 03:38 UTC ( #267073=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
•Re: Re: •Re: Re: •Re: GIF patent
by merlyn (Sage) on Jun 19, 2003 at 07:31 UTC
    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.

      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.

      The point you are arguing is completely void of semantic content.

      File formats and compression algorithms have nothing to do with the inability to perfectly reproduce a visual scene. That doesn't matter because you couldn't get two people to agree on what a perfect reproduction was anyway. It only matters that you have the ability to capture X bits of information. After you capture those X bits of raw information, you are faced with the problem of storing them and must choose a file format.

      If you pick JPEG, you can store that information in less space, but you'll never be able to reproduce your original X bits of information. Hence, we call it "lossy."

      If you pick PNG, you can store that information in less space though probably not as little space as you could if you had chosen JPEG. On the other hand, you will be able to reproduce your original X bits of information. Hence, we call it "lossless."

      Let's hit the salient points again.

      • You can only capture X bits of information.
      • If you choose JPEG to store those X bits, you won't be able to get them back again.
      • If you choose PNG to store those X bits, you will be able to get them back again.

      Hence, we call JPEG "lossy" and PNG "lossless". The accepted terminology is really quite simple.

      Yes, collecting real world data is inherently a "lossy" process. No, that's not relevant to discussing the differences between PNG and JPEG which are applied after the data is already collected.

      -sauoq
      "My two cents aren't worth a dime.";
      
        You can only capture X bits of information.

        This is where you are getting it backwards. You can take your 3 megapixel camera, take a photo and compress it with PNG to get a X Mb file.

        I can then then go get a 4 megapixel (oh how I wish), take a photo and also compress it to X Mb.

        But the JPG may actually have more information, because it had more pixels to analyse while is was compressing. It could make a choice about with pixels to drop. However your 3 megapixel camera has already performed a lossy compression by throwing out a random 1 million pixels.

        Hence, we call JPEG "lossy" and PNG "lossless". The accepted terminology is really quite simple.

        The terminology is also quite deceiving. Of course if you feed digital data like an executable into both formats, JPG will corrupt it and PNG won't. But that's not what we are doing. We are feeding a digital representation of analog data into the formats. You have to consider the system as a whole.

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

      Merlyn says: I wonder if the picture people are ever going to stop arguing...the one s that don't understand that all file formats are lossy

      If my camera captures an image and saves it in tiff format. NO INFORMATION IS LOST. Non-lossy file format.

      If I then choose to convert this tiff into a .png, the image will be compressed, the output file size will be reduced, but STILL NO INFORMATIO WILL BE LOST. A non-lossy, compressed file format.

      If I choose to convert this program to a .jpg, the output file size will smaller than the tiff, and depending upon the options select during conversion, it may also be smaller than the .png. BUT THIS OUTPUT FILE SAVING WILL HAVE COME AT THE COST OF LOST INFORMATION. DETAIL WILL HAVE BEEN DISCARDED FROM THE ORIGINAL IMAGE. This is a lossy format.

      All the images will remain the same size (width x height) as the original (unless I choose to crop the image, which has nothing to do with the output file format).

      Your statements in this thread that elude to the idea that .png is a lossy format are simply false, misleading and wrong.

        If my camera captures an image and saves it in tiff format. NO INFORMATION IS LOST.
        But that's the step at which information is lost, but you're part of the process.

        For you to have a PNG of a certain file size, you are picking an upper-bounded width and height to take your picture.

        JPEG allows you to make that tradeoff later in the cycle by trading some of the individual bit accuracy for the overall pixel count.

        There is always a loss in the process. You do not record every nuance of the original analog experience. You are reducing it to some discrete value in various stages along the process, during the capture by deciding bits-per-pixel and total pixels, and during file storage by deciding whether you are willing to trade either or both of bits-per-pixel or accuracy of individual pixels to retain overall image quality. PNG and JPEG just do that second step differently. PNG is optimized for when the individual bit accuracy is important. JPEG is optimized for when the individual bit accuracy can be traded off so that the overall image information can have a higher number of pixels.

        {sigh}

        Please go study some information theory. Ten pounds of information doesn't fit in a five pound sack, no matter how you represent it. It's like why you can't keep gzip'ing a file over and over again to get a smaller file.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2020-02-19 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (81 votes). Check out past polls.

    Notices?