Bifalgorithm post

"You probably know PNG and JPEG, but do you actually know the difference between them? And no, it's not just that PNG can have a transparent background. The biggest difference is compression. JPEG uses lossy compression. That means it removes some image data to make the file smaller. PNG, on the other hand, uses lossless compression. The file gets smaller, but the original image data can still be reconstructed exactly. So how does PNG actually do that? Let's zoom into an image. Closer, closer, right here. Imagine we're looking at an area between a blue sky and someone's hair. Something very common happens in photos. Neighboring pixels are usually similar. A blue pixel will often be surrounded by other blue pixels with only small changes. So instead of storing values like 145, 146, 149, we can store something closer to 145, then plus 1, then plus 3. Those smaller differences are easier to compress, and we can go even further. Across a large blue sky, the same small differences appear again and again. But a huge change, like going from blue sky to dark hair, happens much less often. So it would be pretty wasteful if both patterns required the same amount of storage. This is where Huffman coding comes in. Imagine we have a list of symbols and how often each one appears. We take the two least common symbols and combine them into one branch. Then we do it again, take the next two least common values, combine them, and we keep doing that until we build a tree. Now we can assign binary paths to every symbol. For example, go left, that's zero. Go right, that's one. Very common values end up with short binary codes. Rare values get longer codes, so instead of storing every value using the same amount of space, the patterns that appear constantly can be represented with just a few bits. That saves a lot of storage. Now, did I just completely explain how PNG compression works? Absolutely not. PNG also uses filtering, deflate compression, LZ77, sliding windows, and other techniques. But the main idea is this. PNG looks for predictable patterns and repetition in the image, then stores that information more efficiently without throwing anything away. And that's what makes it lossless. The same basic idea appears in many other formats too. Text compression, zip files, some types of audio, and more. You're essentially finding repetition and encoding it in a smarter way, so an uncompressed image that might take 40 megabytes could potentially become a 10 megabyte PNG, while still preserving every single pixel exactly."

"You probably know PNG and JPEG, but do you actually know the difference between them? And no, it's not just that PNG can have a transparent background. The bi…

Ideas in this flowchart

  • PNG vs JPEG Compression
  • Compression Types
  • JPEG Compression
  • Lossy Compression
  • Removes Image Data
  • PNG Compression
  • Lossless Compression
  • Retains Image Data
  • PNG Compression Techniques
  • Pattern Recognition
  • Neighboring Pixels Similarity
  • Huffman Coding
  • Binary Paths Assignment
  • Efficient Storage
  • Additional Techniques
  • Filtering
  • Deflate Compression
  • LZ77
  • Sliding Windows
  • Applications
  • Text Compression
  • Zip Files
  • Audio Formats
Feed/

"You probably know PNG and JPEG, but do you actually know the difference between them? And no, it's not just that PNG can have a transparent background. The biggest difference is compression. JPEG uses lossy compression. That means it removes some image data to make the file smaller. PNG, on the other hand, uses lossless compression. The file gets smaller, but the original image data can still be reconstructed exactly. So how does PNG actually do that? Let's zoom into an image. Closer, closer, right here. Imagine we're looking at an area between a blue sky and someone's hair. Something very common happens in photos. Neighboring pixels are usually similar. A blue pixel will often be surrounded by other blue pixels with only small changes. So instead of storing values like 145, 146, 149, we can store something closer to 145, then plus 1, then plus 3. Those smaller differences are easier to compress, and we can go even further. Across a large blue sky, the same small differences appear again and again. But a huge change, like going from blue sky to dark hair, happens much less often. So it would be pretty wasteful if both patterns required the same amount of storage. This is where Huffman coding comes in. Imagine we have a list of symbols and how often each one appears. We take the two least common symbols and combine them into one branch. Then we do it again, take the next two least common values, combine them, and we keep doing that until we build a tree. Now we can assign binary paths to every symbol. For example, go left, that's zero. Go right, that's one. Very common values end up with short binary codes. Rare values get longer codes, so instead of storing every value using the same amount of space, the patterns that appear constantly can be represented with just a few bits. That saves a lot of storage. Now, did I just completely explain how PNG compression works? Absolutely not. PNG also uses filtering, deflate compression, LZ77, sliding windows, and other techniques. But the main idea is this. PNG looks for predictable patterns and repetition in the image, then stores that information more efficiently without throwing anything away. And that's what makes it lossless. The same basic idea appears in many other formats too. Text compression, zip files, some types of audio, and more. You're essentially finding repetition and encoding it in a smarter way, so an uncompressed image that might take 40 megabytes could potentially become a 10 megabyte PNG, while still preserving every single pixel exactly."

"difference between PNG JPEG"

👍
0
0 comments0 shares

Sign in to view and post comments.