function problem6Alt(imageName, p)

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

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

% Produces Quantization Matrices
Q = createQuantizationMatrix(p, 'jpeg');
Quv = createQuantizationMatrix(p, 'colordif');

% Converts to YUV color system
Y = 0.299*r + 0.587*g + 0.114*b;  % Luminance
U = b - Y;
V = r - Y;

% Compresses each color of image
compY = compressImage(Y, ni, nj, C, Q);
compU = compressImage(U, ni, nj, C, Quv);
compV = compressImage(V, ni, nj, C, Quv);

% Decompress each color of image
rebuiltY = decompressImage(compY, ni, nj, C, Q);
rebuiltU = decompressImage(compU, ni, nj, C, Quv);
rebuiltV = decompressImage(compV, ni, nj, C, Quv);

rebuiltRed = rebuiltV + rebuiltY;
rebuiltBlue = rebuiltU + rebuiltY;
rebuiltGreen = (rebuiltY - 0.299*rebuiltRed - 0.114*rebuiltBlue)/0.587;

% 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);