function problem5(imageName, p)

% Obtain image data from file
[x,r,g,b,ni,nj] = loadImage(imageName);

% Produces Discrete Cosine Transorm Matrix
C = makeDCTMatrix(8);

% Generates linear quantization matrix
Q = createQuantizationMatrix(p, 'linear');

% Compresses each color of image
compRed = compressImage(r, ni, nj, C, Q);
compGreen = compressImage(g, ni, nj, C, Q);
compBlue = compressImage(b, ni, nj, C, Q);

% Decompress each color of image
rebuiltRed = decompressImage(compRed, ni, nj, C, Q);
rebuiltGreen = decompressImage(compGreen, ni, nj, C, Q);
rebuiltBlue = decompressImage(compBlue, ni, nj, C, Q);

% Combine the colors back into one image
rebuiltImage(1:ni*8,1:nj*8,1) = rebuiltRed;
rebuiltImage(1:ni*8,1:nj*8,2) = rebuiltGreen;
rebuiltImage(1:ni*8,1:nj*8,3) = rebuiltBlue;

rebuiltImage = uint8(rebuiltImage);

figure(1);imagesc(rebuiltRed);colormap(gray);
figure(2);imagesc(rebuiltGreen);colormap(gray);
figure(3);imagesc(rebuiltBlue);colormap(gray);
figure(4);imagesc(rebuiltImage);