JPEG Compression

(sophielwang.com)

126 points | by vinhnx 4 days ago

8 comments

  • chromakode 0 minutes ago
    The DCT is a cool primitive. By extracting the low frequency coefficients, you can get a compact blurry representation of an image. This is used by preload thumbnail algorithms like blurhash and thumbhash. It's also used by some image watermarking techniques to target changes to a detail level that will be less affected by scaling or re-encoding.

    I made a notebook a few years back which lets you play with / filter the DCT coefficients of an image: https://observablehq.com/d/167d8f3368a6d602

  • danwills 23 minutes ago
    Having played a bit with Discrete FFT (with FFTW on 2D images in a Shake plugin we made at work ages ago) makes the DCT coefficients make so much more sense! I really wonder whether the frequency-decomposition could happen at multiple scale levels though? Sounds slightly like wavelets and maybe that's how jpeg2000 works?.. Yeah I looked it up, uses DWT so it kinda sounds like it! Shame it hasn't taken off so far!? Or maybe there's an even better way?
  • tmilard 7 minutes ago
    Thanks for the sharing : I now understood more how sampling of image works. And going from RGB to lunimesence+chroma works. interesting and usefull
  • bambax 20 minutes ago
    So the idea behind JPEG is the same as behind MP3: we filter out what we don't perceive.

    I wonder if other species would look at our images or listen to our sounds and register with horror all the gaping holes everywhere.

    • masklinn 7 minutes ago
      Gaping holes seems unlikely, more loss of detail or shifted colors.

      You can experience something like that by using plugins which simulate CVD / color blindnesses.

    • Simran-B 5 minutes ago
      My dog doesn't react to familiar voices over the phone at all. The compression and reproduction of audio, while fine for humans, definitely doesn't work for her animal ears.
  • NooneAtAll3 57 minutes ago
    > Application error: a client-side exception has occurred (see the browser console for more information).

    seems like website doesn't work without webgl enabled... why?

    • Tempest1981 22 minutes ago
      It is a nicely done interactive page, if you can get it to work.
    • maxloh 50 minutes ago
      They use 3D graphs to show the Math.
  • jbverschoor 1 hour ago
    Application error: a client-side exception has occurred (see the browser console for more information).
  • 7777777phil 1 hour ago
    • NSPG911 1 hour ago
      The post you linked to was made after this post.
      • 7777777phil 1 hour ago
        my bad, I just saw 2 hours ago on this one - either way they could be merged
        • vinhnx 33 minutes ago
          I think my submission about this post was selected to "second-chance" pool by HN Moderators. Hence it's being shown again. Thanks for the heads up!
  • tomalaci 58 minutes ago
    I usually have a script/alias cmd to automatically convert images to webp. The webp format has pretty much replaced jpg/jpeg (lacks transparency/alpha support) and png (no compression) formats for me.

    There is also AVIF format which is newer and better but it needs to still mature a bit with better support/compatability.

    If you are hosting images it is nice to use avif and fallback to webp.

    • xp84 16 minutes ago
      I know it’s more efficient, but It’s too bad webp is basically supported in browsers and nowhere else. I don’t think any OS even makes a thumbnail for the icon! Forget opening it in an image editor, etc. And any site that wants you to upload something (e.g. an avatar) won’t accept it. So, webp seems in practice to be like a lossy compression layer that makes images into ephemeral content that can’t be reused.

      (Yes, I know, I should just make a folder action on Downloads that converts them with some CLI tool, but it makes me sad that this only further degrades their quality.)

    • ledoge 20 minutes ago
      > png (no compression)

      To be clear, PNG only supports lossless compression, while WebP has separate lossy and lossless modes. AVIF can do lossless compression too, but you're usually better off using WebP or PNG (if you need >8 bpc) instead as it really isn't good at that.

    • lifthrasiir 49 minutes ago
      It is not that trivial, because there are tons of existing JPEG files and lossy recompression costs quality. (PNG does get replaced primarily because lossless WebP is kinda a superset of what PNG internally does.)
      • Zardoz84 0 minutes ago
        Just re-encode it to Jpeg XL without loss of quality, and use less space.