DSP Lab 13
DSP Lab 13
DSP Lab 13
MATLAB
MATLAB>max(FF(:)
Quality
MATLAB
MATLAB
for j=1:40
count=count+1;
PI(1:8,1:8,count)=YIQ((i-1)*8+1:i*8,(j-1)*8+1:j*8,2);
end
end
for m=1:1200
F(:,:,m)=round(dct2(PI(:,:,m))); %DCT transform
FFI(:,:,m)=round(F(:,:,m)./QC); % DCT coefficient quantization
end
count=0;
% operating for Q component
for i=1:30
for j=1:40
count=count+1;
PQ(1:8,1:8,count)=YIQ((i-1)*8+1:i*8,(j-1)*8+1:j*8,3);
end
end
for m=1:1200
F(:,:,m)=round(dct2(PQ(:,:,m))); %DCT transform
FFQ(:,:,m)=round(F(:,:,m)./QC); % DCT coefficient quantzation
end
% Further coding and lossless compression (not included)
%decoding
for m=1:1200
FC(:,:,m)=FF(:,:,m) .*Q;
% recovering DCT coefficients
PP(:,:,m)=round(idct2(FC(:,:,m))); % recovering 8x8 image block for Y component
end
count=0;
for i=1:30
for j=1:40
count=count+1;
YY((i-1)*8+1:i*8,(j-1)*8+1:j*8,1)=PP(1:8,1:8,count); % Y components
end
end
for m=1:1200 %recoverinbg the I component
FIC(:,:,m)=FFI(:,:,m).*QC;
PPI(:,:,m)=round(idct2(FIC(:,:,m)));
end
count=0;
for i=1:30
for j=1:40
count=count+1;
YY((i-1)*8+1:i*8,(j-1)*8+1:j*8,2)=PPI(1:8,1:8,count);
end
end
for m=1:1200 %recoverinbg the Q component
FQC(:,:,m)=FFQ(:,:,m).*QC;
PPQ(:,:,m)=round(idct2(FQC(:,:,m)));
end
MATLAB
count=0;
for i=1:30
for j=1:40
count=count+1;
YY((i-1)*8+1:i*8,(j-1)*8+1:j*8,3)=PPQ(1:8,1:8,count);
end
end
%transform to RGB
RGB(:,:,1)=1.0*YY(:,:,1)+0.956*YY(:,:,2)+0.621*YY(:,:,3);
RGB(:,:,2)=1.0*YY(:,:,1)-0.272*YY(:,:,2)-0.647*YY(:,:,3);
RGB(:,:,3)=1.0*YY(:,:,1)-1.106*YY(:,:,2)+1.703*YY(:,:,3);
X=uint8(X); %level adjustment
RGB=uint8(RGB);%level adjustment
subplot(1,2,1),imshow(X);title('Original image');
subplot(1,2,2),imshow(RGB); title('JPEG image');
Run the MATLAB program to complete the following table using the specified scale factors, and examine
the ranges of the quantized DCT coefficients and image quality.
Factor Y
1
2
5
10
4
Factor C
1
2
4
8
10
MAT>max(FF(:) )
MAT>max(FFI(:))
MAT>max(FFQ(:))
Quality