Ec4091-Digital Signal Processing Lab: Electronics and Communication Engineering National Institute of Technology, Calicut
Ec4091-Digital Signal Processing Lab: Electronics and Communication Engineering National Institute of Technology, Calicut
Submitted by:
Ashna KK B160750EC
ABSTRACT:
INTRODUCTION:
BLOCK DIAGRAM:
THEORY AND IMPLEMENTATION:
On this step the colors of the RGB (Red, Green, Blue) image are
converted to YCbCr (Luminance, Chrominance Blue, Chrominance
Red). During this conversion we take three standard channels (RGB)
and convert them into a different representation which is based on a
luminance (brightness) channel and two opposing color channels. These
three channels are typically less interdependent then the RGB channels.
That allows us to store them with different resolution. If the image is
CMYK or grayscale, it is processed without any color conversion.
Chroma Subsampling:
Quantization:
Huffman encoding:
P SN R =− 10log 10 MSSE
2
OBSERVATIONS:
Compression Ratio:
PSNR:
I = imread('peppers.png');
Y_d = rgb2ycbcr( I );
% Downsample:
Y_d(:,:,2) = 2*round(Y_d(:,:,2)/2);
Y_d(:,:,3) = 2*round(Y_d(:,:,3)/2);
% DCT compress:
A = zeros(size(Y_d));
B = A;
Q = [16 11 10 16 24 40 51 61 ;
12 12 14 19 26 28 60 55 ;
14 13 16 24 40 57 69 56 ;
14 17 22 29 51 87 80 62 ;
18 22 37 56 68 109 103 77 ;
24 35 55 64 81 104 113 92 ;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99];
figure
imshow(ycbcr2rgb(Y_d))
title('Original')
figure
imshow(ycbcr2rgb(uint8(B)));
title('Compressed')
size(ycbcr2rgb(Y_d))/size(ycbcr2rgb(uint8(B)));
ImageSize = 8*prod(size(I))
CompressedImageSize = 8*nnz(A(:,:,1)) +
7*nnz(A(:,:,2)) + 7*nnz(A(:,:,3))
ImageSize/CompressedImageSize
/////huffmann coding
b = A(:);
b = b(:);
b(b==0)=[]; %remove zeros.
b = floor(255*(b-min(b))/(max(b)-min(b)));
symbols = unique(b);
prob = histcounts(b,length(symbols))/length(b);
dict = huffmandict(symbols, prob);
enco = huffmanenco(b, dict);
FinalCompressedImage = length(enco)
ImageSize/length(enco)
mean_square_error=MSE(ycbcr2rgb(Y_d),ycbcr2rgb(uint8
(B)))
peaksnr = psnr(ycbcr2rgb(Y_d),ycbcr2rgb(uint8(B)))