Project 04

Due October 18, 2010

Problem 1 (15 points)

Write a module that converts a matrix representing a color image in YCbCr format to a matrix representing the image in RGB format. (Alternatively you can convert a RGB image to its YCbCr representation.)

Problem 2 (15 points)

Write two modules (if necessary) for Huffman encoding and decoding. Inputs to the first module should be a character string and a coding table; the output should be a binary sequence encoding the character string.

cstr="ABRACADABRA"

huff = {{"A", "0"}, {"R", "111"}, {"B", "10"}, {"D", "1101"}, {"C", "1100"}}

bstring=StreamEncoding[cstr,huff]

The second module should have as inputs a binary string and a coding table and output the corresponding character string:

StreamDecoding[bstring,huff]

You will need to consult the help section to find out about strings and replacement operators; the next command may be useful to rewrite the coding table as a list of replacement rules:

Apply[Rule,huff,2]