Image Compression you can implement in a day

  • Thread starter Thread starter Superposed_Cat
  • Start date Start date
  • Tags Tags
    Compression Image
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 2K views
Superposed_Cat
Messages
388
Reaction score
5
I need to implement a decent image compression algorithm in a day or two, without using libraries.
So it can't be anything with multiple layers, like jpeg.
I was thinking huffman encoding,

Which would be a good algorithm I can learn to implement in a day or two that is not terrible at it's job.
 
Physics news on Phys.org
Superposed_Cat said:
I need to implement a decent image compression algorithm in a day or two, without using libraries.
So it can't be anything with multiple layers, like jpeg.
I was thinking huffman encoding,

Which would be a good algorithm I can learn to implement in a day or two that is not terrible at it's [SIC] job.
You can find good examples on the internet of huffman encrypt/decrypt. I remember years ago lifting one and modifying it to my needs in a couple of hours.
 
  • Like
Likes   Reactions: Klystron, Superposed_Cat and anorlunda
.
phinds said:
You can find good examples on the internet of huffman encrypt/decrypt. I remember years ago lifting one and modifying it to my needs in a couple of hours.
Another idea is to compute the difference between a pixel value and the pixel value to the left or above it, and use huffman compression on those differences. (you can just use unsigned values,)
 
1) The simplest of course in just Run Length encoding. That takes advantage of correlations along scan lines.

2) The next step up is correlation between succesive scan lines (copy the pixel above) combined with Run Length.

3) One more step up is copy 2) above that is <offset or different length> by X pixels.

Number 3 above is used in FAX machines. The specific codes for the above are described in the FAX standard. I worked on the early prototypes several decades ago and don't recall the details. This Google search returns many results and probably has the actual standard listed.
https://www.google.com/search?&q=fax+code+standards
The hardware implementation required a one-scanline buffer for the look-behind, some logic, and 3 or 4 EEprom memories for the table lookup/encode-decode.

Cheers,
Tom
 
  • Like
Likes   Reactions: berkeman