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

KS DCT

The document outlines an experiment on the Discrete Cosine Transform (DCT) applied to image processing, detailing its mathematical foundation and implementation in MATLAB. The experiment successfully demonstrates the transformation and reconstruction of an image, highlighting the DCT's effectiveness in image compression and data reduction. Results indicate minimal quality loss during reconstruction, affirming DCT's significance in digital image processing and multimedia applications.

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)
15 views5 pages

KS DCT

The document outlines an experiment on the Discrete Cosine Transform (DCT) applied to image processing, detailing its mathematical foundation and implementation in MATLAB. The experiment successfully demonstrates the transformation and reconstruction of an image, highlighting the DCT's effectiveness in image compression and data reduction. Results indicate minimal quality loss during reconstruction, affirming DCT's significance in digital image processing and multimedia applications.

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

DSIP Lab Experiment - 9

Discrete Cosine Transform


Praveen K S
208124023
March 2025

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

2 Theory
The Discrete Cosine Transform (DCT) is a mathematical transformation that represents an image as
a sum of cosine functions of different frequencies. It is widely used in image compression techniques
such as JPEG due to its energy compaction property.
The 2D-DCT of an image f (m, n) of size M × N is given by:
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 the scaling factors are:

 √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 Program

clc;
clear all;
close all;

% Read and preprocess image


f = rgb2gray(im2double(imread(’C:\Users\208124023\Downloads\mk.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 Image and Reconstructed Image

Figure 1: Original Image

Figure 2: Reconstructed Image using IDCT

51
5.2 2D DCT Transformed Image

Figure 3: 2D DCT of Image

52
6 Conclusion
The Discrete Cosine Transform (DCT) was successfully implemented in MATLAB to analyze an
image in the frequency domain. It helps separate the important image details from less significant
ones, making it useful for compression techniques like JPEG. By transforming an image, we can
reduce the amount of data needed to store it while preserving important visual information. The
experiment showed that the DCT efficiently converts spatial information into frequency components.
After applying the inverse DCT, the original image was reconstructed with minimal quality loss.
This proves that DCT is an effective method for image processing and compression. It helps reduce
storage space while maintaining image clarity. The results demonstrate how DCT plays a key role in
reducing redundancy in images. It is widely used in multimedia applications to improve efficiency.
Overall, DCT is an essential technique for digital image processing.

53

You might also like