hn-classics/_stories/2006/14133221.md

8.4 KiB
Raw Permalink Blame History

created_at title url author points story_text comment_text num_comments story_id story_title story_url parent_id created_at_i _tags objectID year
2017-04-17T18:26:58.000Z MP3 for Image Compression (2006) http://keyj.emphy.de/mp3-for-image-compression/ joshumax 344 96 1492453618
story
author_joshumax
story_14133221
14133221 2006

Source

KeyJ's Blog : Blog Archive » MP3 for image compression

KeyJ's Blog : Blog Archive » MP3 for image compression

Welcome to the website of

KeyJ

Archives Select Month September 2017  (1) April 2017  (1) May 2014  (1) November 2012  (1) May 2012  (1) February 2012  (1) September 2011  (1) June 2011  (1) February 2011  (1) January 2011  (1) June 2010  (1) April 2010  (1) February 2010  (1) January 2010  (2) December 2009  (1) September 2009  (1) August 2009  (2) April 2009  (3) February 2009  (4) January 2009  (3) December 2008  (2) August 2008  (1) June 2008  (2) April 2008  (1) December 2007  (2) October 2007  (1) September 2007  (2) August 2007  (2) July 2007  (1) May 2007  (1) April 2007  (2) March 2007  (1) February 2007  (3) January 2007  (4) December 2006  (1) October 2006  (3) September 2006  (3) August 2006  (1) July 2006  (2) June 2006  (3) May 2006  (3) April 2006  (7) March 2006  (6) February 2006  (10) January 2006  (5)

4k Apple benchmark blog Breakpoint Demoscene Evoke games graphics H.264 Impressive iPod JPEG Linux MPUI OpenGL rant rePear video Windows

MP3 for image compression

(January 23, 2006)

During some random discussion with my colleague today, I rediscovered an experiment I did quite some years ago: MP3 compression of image data. This is, feed raw 8-bit-per-pixel grayscale image data into an MP3 encoder, let it compress it, and decode the MP3 file again. After some conversion (the decoder will always produce 16 bit signed output, but 8 bit unsigned image data is needed), a raw image file will result of this whole process, ready to be displayed with an arbitrary image viewer. Sounds simple, eh? :)

I just reimplemented the whole thing, this time using some more-or-less standard Unix tools (bash, ImageMagick, LAME, Python) instead of Turbo Pascal and Paint Shop Pro handiwork. For the first test, I used some representative image, scaled it down to 960×720 pixels, and pretended that it was a 24 kHz mono sound file. The LAME encoder options were -q 0 -k -b $SomeBitrate (maximum quality, no lowpass filtering) with bitrates from 8 kbps on. The results are not as bad as the rude misuse of an audio-specific algorithm for image compression would suggest: Above 24 kbps (about 1 bit per pixel), quality is actually quite acceptable. Of course, it doesnt even remotely match JPEGs quality, there are still much artifacts that look a bit like noisy analogue TV reception.

By the way, the generated MP3 files sound a bit like recordings from space probes, so if you need some nifty sound effects, mp3img might be the right tool for you :)

Files

  • mp3_vs_jpeg.png (355k) the MP3 vs. JPEG quality assessment
  • mp3img (1k) shell script to compress image files with MP3

(This article is also available in Russian at Softdroid)

Posted in Computer Fun, Hacks | 8 Comments ...

8 Responses to »MP3 for image compression«

  • MultimediaStudent (2014-02-25 23:25)

Cool!

  • Espen (2017-04-17 21:33)

Nice. How about AAC and OGG? :)

  • Toke Eskildsen (2017-04-17 22:15)

So I guess JPEG compression of a sound file is the next step?

  • Matthew Fernandez (2017-04-18 05:06)

@Toke, why not go for ethernet-over-audio by pumping arbitrary data through the MP3 encoder, playing it, recording it on another machine, then trying to reverse that to what the MP3 encoder saw? Purpose unknown, but sounds challenging in a fun way.

  • @Matthew (2017-04-18 09:55)

Youve just invented dialup

  • Liudas (2017-04-18 10:30)

Cool, so youre now halfways visualizing sounds from space ;)

Cool! I had a project in which the objective was sending images encoded as text. This comes in handy in remote areas where theres only eg. GSM available. The challenge is in compression. ;)

  • Tim (2017-05-02 08:15)

@Miguel, isnt this just using something like PNG or JPEG compression to get a byte stream, then using something like Base64 to encode it as text? I would imagine this is doable in about 2 dozen lines of code (less if you dont care about readability).

Post a Reply

Name (required)

Mail (will not be published) (required)

Website

XHTML: You can use these tags:

Captcha:
Which number is greater: 5 or 4?