Assignment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Ho Chi Minh City University of

Technology (HCMUT)

REPORT SUBJECT
LINEAR ALGEBRA

GROUP: 05 , CLASS: CC02, HK222

LECTURER: ĐẬU THẾ PHIỆT

STUDENT PERFORMANCE

No. ID LAST NAME LEVEL OF CONTRIBUTION


1 2252100 Trương Phú Cường
2 2252001 Bùi Thái An
3 2252808 Đặng Duy Tiến
4 2252085 Vũ Trịnh Thanh Bình
5 2252057 Phạm Văn Bách

HO CHI MINH CITY, YEAR 2023


HO CHI MINH UNIVERSITY OF
TECHNOLOGY
THE REPORT OF ASSIGNMENT
LINEAR ALGEBRA
Semester: 222
SVD

ACKNOWLEGDEMENT
From the bottom of our heart, we want to
say thank to Mr. Dau The Phiet and Mr Nguyen Tien Dung
for teaching us all the basis and useful knowledge.
We are extremely grateful for it.

*Note: [1],[2],[3],[4] are references that you can check on the last page of this report

1. Introduction
Every day, enormous volumes of data are produced as technology becomes more and more integral
to our daily lives. This information can be in text, audio, video, and image formats, among others.
One of the most common ways to convey info is through images. Images are frequently used to
communicate information because "seeing is believing". The convenience of using image data has
increased because to the development of smartphones and smart gadgets. We data scientists use
this method to daily store, process, and communicate enormous volumes of digital data.
Uncompressed data storage can be quite costly in terms of space requirements. Furthermore,
uncompressed data transmission needs a lot of bandwidth. For these reasons, the scientific
community has become very interested in strategies for compressing data before storage and
transmission. It is particularly helpful in fields like signal processing, pattern recognition, and
artificial intelligence. The Singular Value Decomposition method will be highlighted in this article
as a way to decrease the amount of storage needed to store image data.
Reducing the amount of data needed to represent images is the subject of image compression.
Because digital images are represented digitally, the purpose of the image compression technique
is to do so with the fewest number of bits. It is possible to take advantage of redundant information
in the image file to cut down on the amount of bits needed. Redundancy is a roughly repeated
pattern that tends to increase the level of resolution in an image. The image's quality shouldn't be
degraded too much, though, lest the user find it confusing. This trade-off should be balanced with
a suitable image compression method. The balance between compression and data quality is often
determined by the needs of the application.

Typically, an image is represented by a matrix of size m×n. Here, m stands for the number of rows,
which represents the image's pixel height, and n stands for the number of columns, which
represents the image's pixel width. Every pixel that makes up the image is represented by one of
the matrix's elements. By allocating a number to each pixel in an image, the brightness or darkness
of a pixel in relation to neighboring pixels is represented. Each matrix member thus determines
the properties of the corresponding pixel. Each pixel's relative grayness is represented by a number
in the matrix that, for black-and-white images, spans from 0 (black) to 1 (one). Red, green, and
blue (RGB) are the three fundamental colors that make up colored imagery. The computer divides
each colored image into these three levels before storing it. When compared to grayscale
photographs, colorful images take up more space due to the additional layer needed. As a result,
each pixel in a colored image can be assigned to one of three values, ranging from 0 (not colored)
to 1 (saturated). Red, Green, and Blue are each given one of these three values. A 3000×3000
matrix, for instance, can be used to represent a 9 megapixel image. A grayscale 9 megapixel image
requires 9MB of storage space when taking into account a 1 byte per pixel storage space. An
number that ranges from 0 to 255 can be used to represent each pixel in the image matrix. The
image will have three parts (RGB) if it is colored. There needs to be a separate matrix for each
component. Therefore, in this scenario, storing a colored image requires 27Mb of storage space.

2. Background
The existence of redundancy in the data is one of the key elements that affect compression.
Redundancy may take the following forms:
+ Coding Redundancy: When less-than-ideal code words are used, there is redundant coding. The
implementation of the look up table makes the code reversible. Arithmetic coding and Huffman
coding are two examples of this method.
+ Inter-pixel Redundancy: A pixel's value is predicted based on the values of its nearby pixels. An
alternative format is chosen to map the original 2D pixel array. Inter-frame redundancy, geometric
redundancy, and spatial redundancy are additional names for inter-pixel redundancy.
+ Psycho-Visual Redundancy: The human eye is not perfectly calibrated to process all frequency
bands. As a result, not every piece of incoming data is treated with identical attention. The
information will include some elements that will stand out more than others. When picture
redundancies are eliminated, this fact can be taken advantage of. This component is used in
psycho-visual redundancy.

The purpose of the SVD implementations is to produce a smaller image by maximizing the use of
redundancy. This may be effective because the algorithm can only delete redundant parts after
being made aware of them in the image. The integrity of the image is preserved in this way.

2.1. Singular Value Decomposition (SVD)


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 ∑ 𝑉 𝑇 , where U and 𝑉 𝑇 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 𝑉 𝑇 are the left and right singular vectors of M, respectively.

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


+ Find AAT and 𝐴𝑇 𝐴 from the given matrix M.
+ To create U, use AAT . This is done by figuring out the eigenvalues and eigen vectors of AAT .
+ The eigenvalues and eigen vectors of 𝐴𝑇 𝐴 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.

Figure 1 shows the matrices obtained after splitting the original image matrix
Figure 1. Finding the matrices M = UΣVT

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


A = U ∑ 𝑉 𝑇 = ∑ 𝜇𝑖 𝑢𝑖 𝑣𝑖 𝑇 :
Summation ranging from 1 to r.
Expanding the summation,
𝐴 = 𝜇1 𝑢1 𝑣1 𝑇 + 𝜇2 𝑢2 𝑣2𝑇 +. . . +𝜇𝑟 𝑢𝑟 𝑣𝑟 𝑇
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.
𝐴𝑘 = 𝜇1 𝑢1 𝑣1 𝑇 + 𝜇2 𝑢2 𝑣2𝑇 +. . . +𝜇𝑘 𝑢𝑘 𝑣𝑘 𝑇
The reductions matrix 𝐴𝑘 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.

Figure 2. Image compression using SVD


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

close all

clear all

clc

filename = 'image.jpg';

[X, map] = imread(filename);

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)

% 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
This algorithm has been implemented in Matlab programming platform. An image of size 487KB is
considered. It is run through the algorithm, considering different number of columns (k) each time. Size
of output image is evaluated each time.

K Size of compressed image (in KB)

200 104

100 89

50 60

30 58

20 56

10 55

5 49

1 44

The figure below shows the compression images with different values of k:

Original K=200 K=100 K=50

K=30 K=20 K=10 K=5 K=1


4. 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 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.

Reference:
[1]. Kotera H RGB to spectral lmage conversion using spectral pallete and compression by svd
461–464.
[2]. Jabbar S 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

You might also like