BTL DSRR

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Ho Chi Minh City University of Technology (HCMUT)

REPORT SUBJECT

LINEAR ALGEBRA
SVD

GROUP: 03, CLASS: CC03, HK231

LECTURER: Phan Thị Khánh Vân

STUDENT PERFORMANCE

NO. ID NAME
1 2352945 Võ Tá Phúc
2 2353376 Ngô Hải Long
3 2352716 Trần Xuân Lộc

Table of contents

1
Acknowledgement……………………………………………2
I. Introduction………………………………………………… 2
II. Background…………………………………………………3
2.1 Singular Value Decomposition (SVD) ………………4
2.2. Applying SVD in image compression ………………5
III. Matlab code and result……………………………………7
IV. Conclusion…………………………………………………10
References……………………………………………………10

ACKNOWLEDGEMENT

From the bottom of our heart, we want to


say thank to Mrs Phan Thi Khanh Van
for teaching us all the basis and useful knowledge.
We are extremely grateful for it

I. Introduction
In an era dominated by technology, the daily generation of vast
datasets has become a norm, with information conveyed in various
formats, prominently through images. The ubiquity of smartphones and
smart gadgets has amplified the importance of images as a means of
communication. As data scientists grapple with the management of
massive digital data, the cost and bandwidth implications of
uncompressed data storage and transmission have led to a surge in
interest within the scientific community regarding data compression
strategies.

This article focuses on the application of the Singular Value


Decomposition (SVD) method to mitigate storage challenges associated
with image data. Image compression, aimed at reducing the data
required to represent images, is a critical aspect discussed herein. The
technique seeks to represent digital images with the fewest number of
bits, capitalizing on redundant information present in image files. The
delicate balance between maintaining image quality and achieving
compression efficiency is explored, recognizing that different
applications have distinct requirements.

2
The representation of an image as a matrix of size m×n, where m and
n denote the pixel height and width, respectively, forms the basis of the
discussion. Each pixel's brightness or darkness is represented by a matrix
element, with grayscale images ranging from 0 (black) to 1 (white). In
the realm of colored imagery, the RGB model assigns values to pixels in
three separate matrices. The storage implications of colored images are
elucidated, considering the increased space requirements due to the
presence of multiple layers.

The practicality of implementing SVD in reducing storage needs for


image data is highlighted, making it a valuable approach in fields such as
signal processing, pattern recognition, and artificial intelligence. By
delving into the intricacies of image compression and the role of SVD,
this article aims to provide insights into the dynamic relationship
between data quality, compression efficiency, and the diverse
applications of image representation.

II. Background

In the realm of data compression, the impact of redundancy is a central


consideration. Redundancy manifests in various forms, including coding
redundancy, inter-pixel redundancy, and psycho-visual redundancy.
Coding redundancy involves inefficient code words, addressed by
methods such as arithmetic coding and Huffman coding. Inter-pixel
redundancy predicts pixel values based on nearby pixels, and psycho-
visual redundancy acknowledges the non-uniform sensitivity of the
human eye to frequency bands.

This article explores the integration of Singular Value Decomposition


(SVD) as an approach to reduce redundancy and achieve effective data
compression. SVD implementations aim to create a more concise
representation of data by identifying and capitalizing on redundancy.
The algorithm maximizes the utilization of redundant components,
facilitating the subsequent deletion of less critical parts, thus producing
smaller images. Importantly, SVD achieves compression while preserving
the integrity of the image, making it a valuable tool in the optimization
of data storage and transmission.

2.1.Singular Value Decomposition (SVD)

3
SVD stands for Singular Value Decomposition, and it is a mathematical
technique used in linear algebra. It is a factorization method that
decomposes a matrix into three other matrices, which can be useful in
various applications such as data compression, dimensionality reduction,
and solving linear equations.

Given a matrix A, the Singular Value Decomposition of A is represented


as: A=U ∑ V T .

where:

° U is a orthogonal matrix (i.e., U U T =U T U =I ).


° ∑ is a diagonal matrix containing the singular values of A.
°V T is the transpose of an orthogonal matrix V.

The singular values in ∑ are non-negative and are arranged in descending


order. The columns of U and V are called the left and right singular
vectors, respectively.

Decomposing the original matrix is typically how Singular Value


Decomposition (SVD) functions. With fewer dimensions, SVD seeks to
approximate a data set with many dimensions. By converting the higher
dimensional data into lower dimensions data, SVD examines highly
variable, high dimensional data points and reveals the substructure of
the original data. By exposing the substructure, the data are sorted from
greatest variance to smallest variation. This aids in identifying the area
with the highest level of variance, which may subsequently be
reduced using SVD.

In essence, SVD divides the supplied matrix into many matrices. The
above matrix, which has m rows and n columns, is factored by the SVD
into three matrices, which are denoted by the notation M =U ∑ V T ,
where U and V T are orthogonal matrices of orders m×m and n×n,
respectively, and ∑ is a diagonal matrix of order m×n. The singular values
of M are nonnegative real numbers that make up the diagonal matrix ∑.
According to [1] and [2], the m columns of U and the n columns of V T
are the left and right singular vectors of M, respectively.

Following are the steps to compute the SVD of a given matrix:

4
+ Find A AT and AT A from the given matrix M.
+ To create U, use A AT . This is done by figuring out the eigenvalues and
eigen vectors of A AT .
+ The eigenvalues and eigen vectors of AT A can also be calculated in
order to generate V.
+ Each eigen vector is divided by its magnitude to produce columns of U
and V.
+ By calculating the square root of the eigenvalues, singular values are
calculated. The diagonal
matrix has them ordered in descending order.

2.2. Applying SVD in image compression

As we've seen previously, the original matrix is rewritten by the SVD as


the sum of smaller, rank one matrices. SVD divides a given image matrix
into three distinct matrices when applied. However, SVD application by
itself does not aid in compression. The majority of the single values will
be eliminated while just a small number will be kept once the SVD is
applied from [3] and [4]. This reduction is aided by the fact that we
arrange the singular values in the diagonal matrix's decreasing order. As
a result of this configuration, the diagonal matrix's initial value includes
the most information about the picture, while all subsequent values
carry progressively less information. Therefore, we may say that the
information contained in these solitary values is quite little. As a result,
throwing away such information results in a smaller overall image
without any discernible distortion from the original image. The process
shown above was formalized in the following phases.

Let A be the matrix of the given image. It can be expressed as


T T
A=U ∑ V =∑ μ i ui Vi :

Summation ranging from 1 to r.

Expanding the summation,


𝐴 = μ 1u 1 v 1T + μ 2 u 2 v 2T + ...+ + μ r u r v r T

5
As we have seen, it is not necessary to compute the summation to the
very last of the values in the matrices. Smaller values are dropped before
the summation. After truncating the matrix, we get the following
summation.

A k= μ 1u 1 v 1T + μ 2 u 2 v 2T + ...+ μ k u k v k T

The reductions matrix A k needs k(m + n + 1) units of storage. The value


of k will be smaller than n but closer to n. As a result, the final image will
have high resolution and little distortion. There is no doubt that the
value of k determines how much storage space is needed for the
compressed image. Therefore, the value of k may be changed to suit the
situation. Figure 2 shows this method in action.

6
Figure 2. Image compression using SVD

7
III. Matlab code and result
Input: Image matrix I
Output : Compressed image I’

MATLAB CODE

% Choose an image from your computer


[filename, pathname] = uigetfile({'*.jpg;*.png;*.jpeg;*.gif','Image Files
(*.jpg, *.png, *.jpeg, *.gif)'},'Select your image');
if isequal(filename,0)
disp('No image selected.');
else
disp(['You have selected: ', fullfile(pathname, filename)]);
% Read the selected image
X = imread(fullfile(pathname, filename));
% Display the image
figure('Name','Selected Image');
subplot(1, 2, 1);
imshow(X);
title('Original Image');

% Image processing
close all
clc
figure('Name','ORIGINAL component of the imported image');
subplot(4,2,1);
imshow(X);
imwrite(X, 'original.jpg');
title('Original image')
R = X(:,:,1);
G = X(:,:,2);
B = X(:,:,3);
Rimg = cat(3, R, zeros(size(R)), zeros(size(R)));
Gimg = cat(3, zeros(size(G)), G, zeros(size(G)));
Bimg = cat(3, zeros(size(B)), zeros(size(B)), B);
Red = double(R);
Green = double(G);
Blue = double(B);
r=[200,100,50,30,20,10,5,1];
for i=1:length(r)

8
% Compute values for the red image
[U,S,V]=svd(Red);
C = S;
C(r(i)+1:end,:)=0;
C(:,r(i)+1:end)=0;
Dr=U*C*V';
% Compute values for the green image
[U2, S2, V2]=svd(Green);
C = S2;
C(r(i)+1:end,:)=0;
C(:,r(i)+1:end)=0;
Dg=U2*C*V2';
% Compute values for the blue image
[U3, S3, V3]=svd(Blue);
C = S3;
C(r(i)+1:end,:)=0;
C(:,r(i)+1:end)=0;
Db=U3*C*V3';
% Rebuild a colored image with the corresponding data and show it
subplot(4,2,i+1);
buffer = sprintf(' %d singular values', r(i));
Cimg = cat(3, Dr, Dg, Db);
imshow(uint8(Cimg));
imwrite(uint8(Cimg), sprintf('%dcolor.jpg', r(i)));
title(buffer);
end
end

9
RESULT

IV. Conclusion
Singular Value Decomposition (SVD) is a powerful mathematical
technique that has revolutionized several fields by extracting meaningful
information form complex data sets. SVD offers numerous advantages,
such as dimentionality reduction, noise tolerance and data compression.
Its ability to reveal hidden patterns, reduce dimensionality, and provide

10
a compact representation makes it indispensable in numerous
applications.

One significant application of SVD is in image conpression, where it


offers an effective approach to reduce image size while preserving
essential visual information. This approach is simple and can be used to
overcome limitations of existing algorithms. By exploiting the inherent
redundancy in images, SVD-based compression techniques have found
widespread application in diverse domains, enabling efficient storage,
transmission, and display of images. SVD enables lossless compression,
ensuring that the compressed image retains the same quality as the
original. This is particularly important in applications where high quality
images are required, such as medical imaging, satellite imaging, and
archival purposes.

References:
[1]. H RGB Kotera to spectral lmage conversion using spectral pallete and
compression by svd 461–464.
[2]. S. Jabbar 2015 Using Approximate K-SVD Algorithm.
[3]. M.Dixit and P.K.Kulkarni 2012 Variable Scaling Factor based Invisible Image
Watermarking using Hybrid DWT-SVD Compression-Decompression Technique 2–5.
[4]. Rufai, A.M. Anbarjafari, G.Demirel, Huffman Coding and Singular Value
Decomposition.

11

You might also like