% p1
I started detecting a slight difference at the 5th image, that is when cutoff = 16.

% start of file ps2p1.m

% part a
% Load flower matrix from image demos library
load imdemos flower; 
% Convert the matrix to double precision
flower = double(flower); 
% Create a grayscale for any pictures you want to display
colormap('gray'); 
% Display flower in the window
imshow(flower,[0 255]) %

% part b
b = blkproc(flower,[8 8],'dct2');
figure, imshow(b, [0 255]) %

% part c
b(abs(b)<10) = 0;

% part d
d = round(blkproc(b,[8 8],'idct2'));
figure, imshow(d, [0 255]) %

% part e
e = mean2((flower - d).^2) %

% Graph
dct = blkproc(flower,[8 8],'dct2');

% number of non-zero values of the matrix after cutoff procedure
x = [];
% mean square error
y = [];

for cutoff = 0:4:100,

dct(abs(dct)<cutoff) = 0;
idct = round(blkproc(dct,[8 8],'idct2'));

x = [x,nnz(dct)];
y = [y,mean2((flower - idct).^2)];

% Over x.dialup.mit.edu, this is overkill.
% figure, imshow(idct, [0 255])
end

figure, plot(x,y,'d-') %

% end of file ps2p1.m

% p2

now www.eecs.mit.edu not www-eecs.mit.edu

            Encoding                                Decoding
---------------------------                  ----------------------

Input       New dict. entry   Transmitted    Dict. entry     Output
---------   ---------------   -----------    -----------     ------
6E n                          (start)
6F o        80 no             6E n                           n
77 w        81 ow             6F o           80 no           o
20 space    82 w-space        77 w           81 ow           w
77 w        83 space-w        20 space       82 w-space      space
77 w        84 ww             77 w           83 space-w      w
77 w        ------            ------
2E .        85 ww.            84 ww          84 ww           ww
65 e        86 .e             2E .           85 ww.          .
65 e        87 ee             65 e           86 .e           e
63 c        88 ec             65 e           87 ee           e
73 s        89 cs             63 c           88 ec           c
2E .        8A s.             73 s           89 cs           s
6D m        8B .m             2E .           8A s.           .
69 i        8C mi             6D m           8B .m           m
74 t        8D it             69 i           8C mi           i
2E .        8F t.             74 t           8D it           t
65 e        ------            ------
64 d        90 .ed            86 .e          8F t.           .e
75 u        91 du             64 d           90 .ed          d
20 space    92 u-space        75 u           91 du           u
6E n        93 space-n        20 space       92 u-space      space
6F o        ------            ------
74 t        94 not            80 no          93 space-n      no
20 space    95 t-space        74 t           94 not          t
77 w        ------            ------
77 w        96 space-ww       83 space-w     95 t-space      space-w
77 w        ------            ------         
2D -        97 w-             84 ww          96 space-ww     ww
65 e        98 -e             2D -           97 w-           -
65 e        ------            ------
63 c        99 eec            97 ee          98 -e           ee
73 s        -----             ------
2E .        9A cs.            89 cs          99 eec          cs
6D m        ------            ------
69 i        9B .mi            8B .m          9A cs.          .m
74 t        ------            ------
2E .        9C it.            8D it          9B .mi          it
65 e        ------            ------
64 d        ------            ------
75 u        9D .edu           90 .ed         9C it.          .ed
                              75 u           9D .edu         u
                              (stop)

The encoded message is:

6E 6F 77 20 77 -- 84 2E 65 65 63 73 2E 6D 69 74 -- 86 64 75 20 -- 80 74 -- 83 -- 84 2D -- 97 -- 89 -- 8B -- 8D -- -- 90 75 

(Obviously, the '--' are not sent, but I keep them to visualize how much compression was achieved.)

41 characters in the plain message
(41 - 12 =) 29 characters in the encoded message
compression rate: (29*7)/(41*8) = 62% !!!

b. Limiting the dictionary entries to only the ASCII control characters is more efficient, 
   because the dictionnary won't required an increased number of bits per code sent.

   However, the cost of this efficiency is that the dictionnary can contain no more
   than 16 entries _at a time_. The encoder and decoder can agree on various behaviors to
   deal with this limitation, but the algorithm will be more complex.

c. Elle est bien bonne. :->
