You are on page 1of 27

Machine

Learning Based
Image Master Thesis II
Compression Advisor: Dr. Mohamad Raad
Committee: Dr. Majd ghareeb
Dr. Hadi Nour Elddine

Raed Abdel-Al
Submitted by:
Kotaiba El-Jaja
1
Why Image Compression
• The main advantages of
compression are reductions in
storage hardware, data
transmission time, and
communication bandwidth. This
can result in significant cost savings.
Compressed files require
significantly less storage capacity
than uncompressed files, meaning a
significant decrease in expenses for
storage
2 2
Selected Topics
This topics that are selected in this presentation:
1. The importance in machine learning
2. Apply KLT or PCA for Image Compression
3. Multi-Layer Perceptron
4. Improve KLT by MLP (Multi-Layer Perceptron)
5. Result
6. Evaluation
7. Advantage and Disadvantages
8. Conclusion
9. Future Work
3 3
The importance in machine learning
Why Machine Learning?

• Machine Learning(ML) is constructing


computer programs that develop
solutions and improve with experience
• Solves problem that cant be solved by
enumerative methods or calculus-based
techniques

4 4
Karhunen–Loève Transform (KLT)
In part I, we apply KLT or PCA for the
image
We got the eigen values and eigen vectors
Using 1 principal
Which called PCA Values component

So we want to improve the KLT using


neural networks and we choose MLP
(Multi-Layer Perceptron)

Using 150 principal


component

5 5
Karhunen–Loève Transform (KLT)

Convert Picture Calculate the Subtract From Find the Calculate Eigen
to Gray Scale Mean the Mean Variance and Value and
Covariance vector

Choice
Recover
Final data =A (X-µ) property
Original Image
vectors

6 6
Multi-Layer Perceptron
A Multilayer Perceptron (MLP) is a type of artificial neural
network that consists of multiple layers of interconnected
artificial neurons, it has:
• Input layers: The input layer receives the input data,
which could be a feature vector or an image. Each neuron
in the input layer represents an input feature.
• Hidden layers: MLPs can have one or more hidden layers,
where each layer consists of multiple neurons. These
hidden layers allow the network to learn complex non-
linear relationships and capture higher-level abstractions
in the data
• Output layers: The output layer produces the final output
of the network. The number of neurons in the output
layer depends on the type of problem being solved
77
7
Multi-Layer Perceptron
• Weights and Biases: The connections
between neurons in the MLP are
assigned weights, which determine
the strength or importance of each
connection
• Training: MLPs are typically trained
using the backpropagation algorithm,
which involves propagating the error
from the output layer back through
the network to adjust the weights and
biases.
8 8
Improve KLT by MLP (Multi-Layer
Perceptron)
• The major goal of using Multi-Layer
Perceptron (MLP) with the Karhunen-
Loève Transform (KLT) for feature
selection can be done to improve the
performance and efficiency of the
KLT. By incorporating an MLP, you can
introduce a trainable mechanism that
determines which PCA values to
discard or keep based on the learned
weights.

9 9
Improve KLT by MLP (Multi-Layer
Perceptron)
• By incorporating the MLP, it allow the model to learn and adapt the
feature selection process based on the specific task requirements. This
can potentially enhance the performance of the KLT by selecting the
most informative PCA values while discarding the less relevant ones.

• It's worth noting that the exact implementation details, such as the
specific MLP architecture, training algorithm, and threshold selection,
may vary depending on the problem and datasets.

10 10
Implementation

Divide image Calculate the


Convert Picture Subtract From
into micro Mean of each Apply PCA
to Gray Scale the Mean
blocks block

Recover
Calculate PSNR
Original Image

1. Divide image into macro blocks


2. Extract PCA for each macro blocks
3. Quantize PCA for all blocks
4. For each approximation of PCA values, reconstruct the
image and calculate PSNR of re-constructed image

11
Implementation

The next step is implanting MLP


When we are encoding, the encoder will be
given the image block and the target PSNR.
The encoder will calculate the PCA for the
given block.
The encoder will input [targetPSNR [calculated Apply PCA
PCA values]] as one vector into the MLP.
The MLP generates the weights vector.

Since the weights are 0 or 1, then the encoder


Calculate PSNR
knows which PCA values to discard and which
to keep.

12
Implementation
Then ready for training

• To train the MLP - create a data set that has PCA values for many blocks,
different weights applied for each block and the PSNR value when those
weights are used.
• The MLP then takes as input [PSNR [PCA values]] and as target output [PCA
weights] for each instance of a coded block
• So if the principal componets are 32, the number input with PSNR is 33 and the
number of output is 32
• So you will have many data points for training.
• Once the training is completed the MLP can be used as part of an encoder that
simply determines which PCA values to keep and which to discard for each
block.
13
Implementation
• The encoder will calculate the PCA for the given block.
• The encoder will input [targetPSNR [calculated PCA values]] as one vector into the
MLP.
• The MLP generates the weights vector.
• Since the weights are 0 or 1, then the encoder knows which PCA values to discard
and which to keep.
• To train the MLP - create a data set that has PCA values for many blocks, different
weights applied for each block and the PSNR value when those weights are used.
• The MLP then takes as input [PSNR [PCA values]] and as target output [PCA weights] for each
instance of a coded block
• So you will have many data points for training.
• Once the training is completed the MLP can be used as part of an encoder that simply
determines which PCA values to keep and which to discard for each block.
14 14
Implementation
• We use Python Language to implement the system, and I choose Python
because:
• There are a lot of available Python libraries for PCA and MLP training and testing.
• Easy for used and online compiling and testing (Colab)
• Python is the most widely used language for machine learning due to its
extensive libraries and frameworks
• The test image that I use is Lena.png

15 15
Implementation
So these are the functions of this project
Functions Main Return Role
load_and_preprocess_image_blocks imageblocks Load the image and divide it
into macro blocks.
perform_pca(image_block, pca_dim) pcavalues Apply PCA to image

calcpsnr(original_img, compressed_img) targetPSNR Deduce Target PSNR

Apply_threshold(encoded_blocks, pca_values) binarypcavalue Apply threshold and set the


values 0 or 1
def create_mlp_model(input_dim, output_dim, hiddenlayer): mlp Set MLP Configuration

train_mlp_model(mlp, X_train, y_train,targetpsnr, epochs, hiddenleayers) targetweight Apply MLP to PCA Values and
Target PSNR

Keep_or_discard_pca_values(pca_weights, pca_values ) Reconstructed Inverse PCA


decode_and_reconstruct_image(decoded_pca_values, pca_values) imageblocks

Calculate_mean_square_error(original_image, reconstructed_image) MSE_value Compare the original with


compressed image

16
Result
• the result is depends on these points
1. Number of principal component to choose the input and outputs
2. Number of hidden layers
3. Number of epoch or iteration
4. Number of threshold

• So we test the project using:


• 32 and 64 principal component
• Threshold = 1
• Iteration = 1000

17 17
Result
First lets see the PCA before and after applying MLP
so these pictures is shown the difference in values before and after applying PCAs

18 18
Result
Reconstruction Image or decompress the image (max iteration is 1000), and
threshold > 1

32 principal component 64 principal component


19 19
Evaluation
• To evaluate we want to compare before and after using MLP by
calculating the MSE and PCNR using different approaches

MSE = 0 MSE = 15.02 MSE = 435.63 MSE = 16.72

20
Evaluation
• So after apply these options we got:

Before MLP after MLP

21
Evaluation
• The good things about this method that we can
recover the message in different performance
related to the number of principal component,
threshold, and number of iteration, and each
parameters have many performance calculations
such as: Using 1 principal Using 20 principal Using 50 principal
component component component
1. Time execution
2. GPU used
3. RAM Used
4. CPU power
5. Others power and memory usage
• I focused more on the quality of the compression
and these performance will be continue on it in Using 150 principal Using 252 principal
component component
the future work

22 22
Advantages and Disadvantages
• Advantage
1. Enhanced Feature Selection
2. Nonlinear Relationships
3. Robustness to Noise

• Disadvantages of improving PCA with MLP:


1. Increased Complexity
2. Training and Computational Cost
3. Risk of Overfitting

23
Conclusion
• MLPs can be effectively applied to enhance PCA image compression.
• The MLP learns nonlinear relationships in the compressed coefficients,
improving reconstruction quality, and make PCA values more simple.
• It offers better compression performance and quality compared to PCA alone.
• Future research can explore advanced MLP architectures and training
techniques for further improvements.
• As the number of iteration increase the time and power of (CPU, GPU and Ram)
increase, also if the principal component increase the calculation will increase
• Removing thresholds using MLP (Weight Outputs) is better and gives better
quality the estimating the threshold of PCA

24 24
Future Work
• Evaluate on Different Datasets: Assess the performance of the improved PCA-MLP
model on diverse datasets beyond the Lena image. This will help validate its
effectiveness and generalizability across various types of data and applications
• Real-World Application: Apply the improved PCA-MLP method to a real-world
problem or dataset relevant to your field of interest. This could involve tasks such
as image classification, anomaly detection, signal processing, or any other
application where feature selection is critical.
• Interpretability and Visualization: Investigate techniques to interpret and visualize
the selected PCA values or the decision-making process of the MLP. This can
provide insights into which features contribute most to the model's predictions and
help in understanding the underlying patterns in the data.
• Calculate advanced performance: Time execution, GPU used, RAM Used, CPU
power, Others power and memory usage

25 25
Reference
[1] S. Kunwar, "mage Compression Algorithm and JPEG Standard," International Journal of Scientific and
Research Publications, vol. 7, no. 12, p. 9, December 2017.
[2] J.-J. D. a. J.-D. Huang, "Image Compression by Segmentation and," Master’s Thesis,National Taiwan
University, Taipei, 2007.
[3] C. L. a. Q. Zhao, "A Universal PCA for Image Compression," d8061105,qf-zhao, The University of Aizu.
Aizuwakamatsu, Japan 965-8580 , 2004.
[4] E. K. R. R. a. P. Yip., "Karhunen-Loève Transform," in The Transform and Data Compression Handbook,
Boca Raton, CRC Press LLC, 2001, p. 35.
[5] I. W. S. e. al, "Discrete Cosine and Sine Transforms," in The Transform and Data Compression Handbook,
Boca Raton, n, CRC Press LLC, 2001, p. 55.
[6] G. T. Younes, "Digital Image Compression using Karhunen-Loève Transform," Al-Rafidain Journal of
Computer Science and Mathematics, vol. 10, no. 3, p. 13, 2013.
[7] R. S. A. &. S. BHOSALE, "STEGANOGRAPHY USING KARHUNEN-LOEVE TRANSFORM AND," International
Journal of Electrical and Electronics Engineering Research (IJEEER) , vol. 4, no. 2, p. 6, Apr 2014.
[8] G. T. Y. K. A. Sundus Khaleel, "Copyright Authentication By Using Karhunen-Loeve Transform," J. of
university of anbar for pure science, vol. 6, no. 2, p. 8, 2012.

26
Thank
you

27 27

You might also like