0% found this document useful (0 votes)
27 views5 pages

Jai DCT

The document outlines an experiment on implementing the Discrete Cosine Transform (DCT) for image processing, focusing on frequency domain analysis and image reconstruction using Inverse DCT. It includes theoretical background, a step-by-step procedure, MATLAB code for execution, and results showcasing the original and reconstructed images. The conclusion emphasizes the DCT's effectiveness in image compression and detail preservation.

Uploaded by

Praveen K S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Jai DCT

The document outlines an experiment on implementing the Discrete Cosine Transform (DCT) for image processing, focusing on frequency domain analysis and image reconstruction using Inverse DCT. It includes theoretical background, a step-by-step procedure, MATLAB code for execution, and results showcasing the original and reconstructed images. The conclusion emphasizes the DCT's effectiveness in image compression and detail preservation.

Uploaded by

Praveen K S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment - 9

Discrete Cosine Transform (DCT)

JAYAKUMAR E
208124014
March 2025

1 Objective
To implement the Discrete Cosine Transform (DCT) on an image, analyze its frequency domain
characteristics, and reconstruct the image using the Inverse DCT.

2 Theory
The Discrete Cosine Transform (DCT) is used to represent an image as a sum of cosine functions
of varying frequencies. It is widely used in image compression techniques such as JPEG due to its
energy compaction properties. The mathematical expression for 2D-DCT is:
M −1 N −1    
X X π(2m + 1)u π(2n + 1)v
F (u, v) = αu αv f (m, n) cos cos (1)
m=0 n=0
2M 2N
where αu and αv are scaling factors:

 √1 , u = 0
αu = qM2 (2)
M, 1 ≤ u ≤ M −1


 √1 , v = 0
αv = qN2 (3)
N, 1 ≤ v ≤ N −1

The inverse DCT (IDCT) reconstructs the image as:


M −1 N −1    
X X π(2m + 1)u π(2n + 1)v
f (m, n) = αu αv F (u, v) cos cos (4)
u=0 v=0
2M 2N

3 Procedure
1. Load an image and convert it to grayscale.

2. Compute the cosine transform matrix for the given image dimensions.
3. Apply the DCT transformation to the image.
4. Analyze the characteristics of the transformed image.

5. Apply the inverse DCT to reconstruct the image.


6. Compare the original and reconstructed images.

49
4 MATLAB CODE

clc;
clear all;
close all;

% Read and preprocess image


f = rgb2gray(im2double(imread(’jai.jpg’)));
f1 = imresize(f, [256 256]);

% Define DCT Matrix


N = 256;
c = zeros(N);
c(1,:) = repmat(1/N,1,N);
for u = 0:N-1
if u == 0
uscale = sqrt(1/N);
else
uscale = sqrt(2/N);
end
for v = 0:N-1
c(u+1,v+1) = uscale * cos((2*v+1)*pi*u/(2*N));
end
end

% Compute 2D-DCT
F_dct = (c * f1) * c’;

% Compute Inverse DCT


fidct = (c’ * F_dct) * c;

% Display results
figure(1);
subplot(1,2,1);
imshow(f1); title(’Original Image’);

subplot(1,2,2);
imshow(fidct); title(’Reconstructed Image’);

figure(2);
imshow(F_dct, []); title(’2D DCT of Image’);

50
5 Results
5.1 Original and Reconstructed Images

Figure 1: Original Image

Figure 2: Reconstructed Image using IDCT

51
5.2 Magnitude Spectrum of Image

Figure 3: DCT Magnitude Spectrum

52
6 Conclusion
In this experiment, we implemented the Discrete Cosine Transform (DCT) to analyze an image
in the frequency domain. The DCT conversion helps in understanding the frequency components
of an image. The transformed coefficients demonstrate the energy compaction property of DCT,
which is useful in compression techniques like JPEG. The reconstructed image obtained using the
Inverse DCT was nearly identical to the original image, demonstrating that the transform preserves
essential image details. This experiment highlights the significance of DCT in image processing
applications such as compression, filtering, and enhancement.

53

You might also like