%   prog2p2.m -- Image Processing with Haar Wavelets
%   Written December 7, 2011 by Eric Olson for Math 761
%
%   This program was developed and tested using GNU Octave.
%   It should also work with MATLAB.

clear all
more off
disp('prog2p2.m -- Image Processing with Haar Wavelets');
disp('Written December 7, 2011 by Eric Olson for Math 761');
disp('');

epsilon=0.1;
disp('Reading image1.pgm...');
y=double(imread('image1.pgm'))/255.0;
N=length(y);

disp('Processing...');
y=haar2d(y);
for n=1:N
    for m=1:N
        if abs(y(n,m))<epsilon
            y(n,m)=0;
        end
    end
end
y=ihaar2d(y);

disp('Writing test.pgm...');
imwrite(uint8(y*255),'test.pgm','pgm');
