Feb 2
continue discussion of compression algorithms.
Homework for next week: (not posted yet, but will be)
1. implement markov-2 (or higher) entropy model, extending previous
2. implement a lossless compression algorithm of your choice;
be ready to discuss and show next Tue
Arithmetic
From our textbook, page 64, example 4.18
Find code word for βω :
p(βω) = 0.01
a(βω) = .31 + .13 + .04 + .02 + .13 + .15 + .01 = 0.79
1/P = 100
n_P = 7 (since 2**7 = 128 > 100)
n = 8 (n_P + 1) = number of bits
c = 203 ( c-1 < 0.79 * 2**8 = 202.24 < c )
c(βω) = 11001011
Why is this any better than Huffman? Answer: the fact that you don't have to recreate the whole tree to get one symbol means that its easier to change your model of the source as you go. That's called "adaptive" coding ... which isn't what we're doing in this little example.
burrows-wheeler
From it's wikipedia article, discuss this compression
scheme, including the run-length and move-front schemes
that actually produce the encoding.
Also look at the bzip2 wikipedia article.
LZMA and 7z
... I know little about, but is worth mentioning in passing.
lossy methods
General idea: throw away information to get even
better compression. Particularly if our senses
(sight or hearing) can barely tell the difference anyway.
So generally useful for pictures, sounds, and video.
File details: codec vs container
Bandwidth estimates of our senses (sound,image,video) ... perhaps as a class exercise.
jpeg
Basic idea (from wikipedia article) :
1. RGB to YCbCr (brightness, 2 chroma)
2. reduce resolution of chromas
3. discrete cosine transform on 8x8 pixel blocks
4. reduce resolution of higher spatial frequencies
5. lossless coding via variation of huffman
The "quality" setting effects step 4, particularly.
Color :
Using constants Kb and Kr, and letting (R,G,B) range 0 to 1
the color transformation is :
Y = Kr*R + Kb*B + (1-Kr-Kb)*G
Pb = 0.5 * ( B - Y ) / (1 - Kb)
Pr = 0.5 * ( R - Y ) / (1 - Kr)
A typical value for the constants is Kb=0.0722, Kr=0.2126
30 times smaller without much loss in photo quality is typical.
Discuss the basic idea of compression via
filtering high 2D Fourier components.
audio
Tricky stuff; details are generally complicated
and rely on our perception of sound, trying to
get reproduced signals that "sound the same" to people.
Prob'ly most popular (although patented) is MP3 (actually MPEG-2 Audio Layer III), came from two ideas :
- typical compression (e.g. run length encoding or freq components)
- auditory masking (if it gets busy, we don't hear softer sounds)
First technique works better when sound is boring; second when waveform gets too complicated for simple prediction.
Another open source one is
50 times smaller is not unusual with these sorts of methods.
Also Apples (AAC, Advanced Audio Encoding),
and lossless audio
Finally, a full list of lossless methods is given at