SlideShare a Scribd company logo
1 of 19
Image Compression
using K-Means
Clustering Method
In Supervision of:
Prof. Amit Mitra
Submitted By:
Gyanendra Awasthi(201315)
Pankaj Kumar(170455)
Contents
Clustering
K-means Clustering
Cost Function
Display on actual Dataset
Code Snippets
Examples of some original and compressed images
Uses of image compression
Results
Drawbacks of K-means
References
Clustering
•Group of collection of points into clusters
• Patterns are extracted from variables without
analysing any variable – unsupervised learning
•The points in each cluster are closer to one
another and far from points in other clusters
K-Means Clustering
• Unsupervised learning algorithm.
• Grouping of different data points which are like each other.
• Forming dissimilar groups and each group containing similar data points
• To partition data into distinct K clusters. K is defined by user.
•Works on predefined distinct K clusters in which each data point belongs to a
particular cluster.
Cost Function
•The goal is to minimize within-cluster dissimilarity.
•The Cost function(J) is:
J= 𝑖=1
𝑁
𝑘=1
𝐾
𝑟𝑖𝑘 𝑥(𝑖)
− 𝜇𝑘
2
Where= 𝑥(𝑖)
are data points
𝜇𝑘 is center of cluster k.
𝑟𝑖𝑘 = 1 if 𝑥(𝑖)
belongs to cluster k and 0 if it doesn’t belong to cluster k.
k = 1,.,…,K where K is the number of clusters provided
N is the number of total data points
•J represents sum of distances between each data 𝑥(𝑖)
and cluster center 𝜇𝑘.
• Cost function J is minimized for optimal clustering.
•After each iteration 𝜇𝑘 is obtained by the formula
𝜇𝑘 =
𝑖=1
𝑁
𝑟𝑖𝑘𝑥𝑖
𝑖=1
𝑁
𝑟𝑖𝑘
K- Means Algorithm
Step1- Randomly initialize the K data points as initial centroids for K clusters
Step2- Until the cluster centers are changed or for max iteration
◦ Allocate each data point to centroid whose data point is nearest
◦ Replace the cluster centres with the mean of the element in their
clusters
end
Display on actual dataset
Code- Snippets
To compute the nearest centroids for data points.
Image Compression
•An image is made up of small intensity dots called pixels.
•Each pixel contains three values which are the values of intensities of Red, Blue, Green colors
respectively for that pixel
•Reducing the size that an image takes while storing and transmitting
• Reducing the number of colors occurred in image to the most frequent colors appearing in it
• Essentially forming the different clusters of frequent occurring colors present in the image by
using pixel values
Original and Compressed Image-Parrot
𝑡𝑛= time taken for K- means algorithm to run for n iterations
Fig1b. 𝑡10= 1min 42sec
Fig1a. Original Image
Original and Compressed Image-Parrot
Fig1c. 𝑡10= 6min 32sec Fig1d. 𝑡10= 12min 42sec Fig.1e 𝑡10= 50min 40sec
Original and Compressed Image-Scenery
Fig2b. 𝑡10= 2 min 10sec
Fig2a. Original Image
Original and Compressed Image-Scenery
Fig2e. 𝑡10= 63 min 30sec
Fig2d. 𝑡10= 15 min 30sec
Fig2c. 𝑡10= 8 min 15sec
Uses of Image Compression
•Lesser data for storing the compressed image compared to original image,
reducing the cost of storage and transmission
• K-Means is utilized to compress visual contents in vast nexus of social
messaging app for its faster transmission and less storage utilization
•Used for archival purpose and for medical imaging, technical drawings
•Widely used in remote sensing via satellite, television broadcasting, for
capturing and transmitting satellite images
Results
Actual Size of Image of
Parrot
Number of clusters(K)
Specified while
Compressing the image
Reduced Size of the
Image of Parrot
1,87,236 bytes
100 52,032 bytes
20 54,888 bytes
15 54,888 bytes
12 54,351 bytes
2 43,616 bytes
Table1. Results of K-means clustering applied on parrot.jpg
Results
Actual Size of Image of
Scenery
Number of clusters(K)
Specified while
Compressing the image
Reduced Size of the
Image of Scenery
5,50,287 bytes
50 1,01,404 bytes
10 1,01,813 bytes
5 95,616 bytes
2 83,729 bytes
Table2. Results of K-means clustering applied on scenery.jpg
Drawbacks of K-means
• Gets sluggish as the size of data(image) increases.
• Time taken by algorithm increases as the number of cluster (K) increases.
• Results may represent a suboptimal local minimum.
• Works only for linear or almost linear boundaries
References
•Xing Wan (2019), “Application of K-means Algorithm in Image Compression”, IOP Conference
Series: Materials Science and Engineering, 563 052042,
•B. Reddaiah “A Study on Image Compression and its Applications”, International Journal of
Computer Applications, Volume 177 – No. 38, February 2020
•Hartigan, J. A., Wong, M. A. (1979). Algorithm as 136: a k-means clustering algorithm. Journal of
the Royal Statistical Society, 28(1), 100-10
•https://www.simplilearn.com/tutorials/machine-learning-tutorial/k-means-clustering-algorithm
•Van der Geer, J., Hanraads, J.A.J., Lupton, R.A. (2010) The art of writing a scientific article. J. Sci.
Commun., 163: 51–59.
Image Compression using K-Means Clustering Method

More Related Content

What's hot

What's hot (20)

Chapter 9 morphological image processing
Chapter 9 morphological image processingChapter 9 morphological image processing
Chapter 9 morphological image processing
 
image compression ppt
image compression pptimage compression ppt
image compression ppt
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compression
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
 
Otsu binarization
Otsu binarizationOtsu binarization
Otsu binarization
 
Introduction to Image Compression
Introduction to Image CompressionIntroduction to Image Compression
Introduction to Image Compression
 
Morphological image processing
Morphological image processingMorphological image processing
Morphological image processing
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processing
 
Sharpening spatial filters
Sharpening spatial filtersSharpening spatial filters
Sharpening spatial filters
 
BASICS OF DIGITAL IMAGE PROCESSING,MARIA PETROU
BASICS OF DIGITAL IMAGE PROCESSING,MARIA PETROUBASICS OF DIGITAL IMAGE PROCESSING,MARIA PETROU
BASICS OF DIGITAL IMAGE PROCESSING,MARIA PETROU
 
Edge linking in image processing
Edge linking in image processingEdge linking in image processing
Edge linking in image processing
 
JPEG
JPEGJPEG
JPEG
 
Compression: Images (JPEG)
Compression: Images (JPEG)Compression: Images (JPEG)
Compression: Images (JPEG)
 
Gradient-Based Low-Light Image Enhancement
Gradient-Based Low-Light Image EnhancementGradient-Based Low-Light Image Enhancement
Gradient-Based Low-Light Image Enhancement
 
EDGE DETECTION
EDGE DETECTIONEDGE DETECTION
EDGE DETECTION
 
Digital image processing using matlab
Digital image processing using matlab Digital image processing using matlab
Digital image processing using matlab
 
Deep learning for image video processing
Deep learning for image video processingDeep learning for image video processing
Deep learning for image video processing
 
Intensity Transformation
Intensity TransformationIntensity Transformation
Intensity Transformation
 
ImageProcessing10-Segmentation(Thresholding) (1).ppt
ImageProcessing10-Segmentation(Thresholding) (1).pptImageProcessing10-Segmentation(Thresholding) (1).ppt
ImageProcessing10-Segmentation(Thresholding) (1).ppt
 
Chap6 image restoration
Chap6 image restorationChap6 image restoration
Chap6 image restoration
 

Similar to Image Compression using K-Means Clustering Method

Deep Local Parametric Filters for Image Enhancement
Deep Local Parametric Filters for Image EnhancementDeep Local Parametric Filters for Image Enhancement
Deep Local Parametric Filters for Image Enhancement
Sean Moran
 

Similar to Image Compression using K-Means Clustering Method (20)

Pillar k means
Pillar k meansPillar k means
Pillar k means
 
Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)
 
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
 
Digital Image Fundamentals - II
Digital Image Fundamentals - IIDigital Image Fundamentals - II
Digital Image Fundamentals - II
 
Deep Local Parametric Filters for Image Enhancement
Deep Local Parametric Filters for Image EnhancementDeep Local Parametric Filters for Image Enhancement
Deep Local Parametric Filters for Image Enhancement
 
Master defense presentation 2019 04_18_rev2
Master defense presentation 2019 04_18_rev2Master defense presentation 2019 04_18_rev2
Master defense presentation 2019 04_18_rev2
 
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
 
IRJET- Finding Dominant Color in the Artistic Painting using Data Mining ...
IRJET-  	  Finding Dominant Color in the Artistic Painting using Data Mining ...IRJET-  	  Finding Dominant Color in the Artistic Painting using Data Mining ...
IRJET- Finding Dominant Color in the Artistic Painting using Data Mining ...
 
WEB IMAGE RETRIEVAL USING CLUSTERING APPROACHES
WEB IMAGE RETRIEVAL USING CLUSTERING APPROACHESWEB IMAGE RETRIEVAL USING CLUSTERING APPROACHES
WEB IMAGE RETRIEVAL USING CLUSTERING APPROACHES
 
Report
ReportReport
Report
 
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
 
Unsupervised Learning Clustering KMean and Hirarchical.pptx
Unsupervised Learning Clustering KMean and Hirarchical.pptxUnsupervised Learning Clustering KMean and Hirarchical.pptx
Unsupervised Learning Clustering KMean and Hirarchical.pptx
 
Object Shape Representation by Kernel Density Feature Points Estimator
Object Shape Representation by Kernel Density Feature Points Estimator Object Shape Representation by Kernel Density Feature Points Estimator
Object Shape Representation by Kernel Density Feature Points Estimator
 
Kyle DiGirolamo octave project summary
Kyle DiGirolamo octave project summaryKyle DiGirolamo octave project summary
Kyle DiGirolamo octave project summary
 
Quality and size assessment of quantized images using K-Means++ clustering
Quality and size assessment of quantized images using K-Means++ clusteringQuality and size assessment of quantized images using K-Means++ clustering
Quality and size assessment of quantized images using K-Means++ clustering
 
presentation 2019 04_09_rev1
presentation 2019 04_09_rev1presentation 2019 04_09_rev1
presentation 2019 04_09_rev1
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Final edited master defense-hyun_wong choi_2019_05_23_rev21
Final edited master defense-hyun_wong choi_2019_05_23_rev21Final edited master defense-hyun_wong choi_2019_05_23_rev21
Final edited master defense-hyun_wong choi_2019_05_23_rev21
 
master defense hyun-wong choi_2019_05_14_rev19
master defense hyun-wong choi_2019_05_14_rev19master defense hyun-wong choi_2019_05_14_rev19
master defense hyun-wong choi_2019_05_14_rev19
 
defense hyun-wong choi_2019_05_14_rev18
defense hyun-wong choi_2019_05_14_rev18defense hyun-wong choi_2019_05_14_rev18
defense hyun-wong choi_2019_05_14_rev18
 

More from Gyanendra Awasthi

More from Gyanendra Awasthi (8)

Gradient Based Learning Applied to Document Recognition
Gradient Based Learning Applied to Document RecognitionGradient Based Learning Applied to Document Recognition
Gradient Based Learning Applied to Document Recognition
 
Modelling Frontier Mortality using Bayesian Generalised Additive Models
Modelling Frontier Mortality using Bayesian Generalised Additive ModelsModelling Frontier Mortality using Bayesian Generalised Additive Models
Modelling Frontier Mortality using Bayesian Generalised Additive Models
 
Hyperloop- A 21st century transportation revolution
Hyperloop- A 21st century transportation revolutionHyperloop- A 21st century transportation revolution
Hyperloop- A 21st century transportation revolution
 
Study and performance analysis of combustion chamber using
Study and performance analysis of combustion chamber usingStudy and performance analysis of combustion chamber using
Study and performance analysis of combustion chamber using
 
Study and performance analysis of combustion chamber using ANSYS
Study and performance analysis of combustion chamber using ANSYSStudy and performance analysis of combustion chamber using ANSYS
Study and performance analysis of combustion chamber using ANSYS
 
Manufacturing of Stuffing box
Manufacturing of Stuffing boxManufacturing of Stuffing box
Manufacturing of Stuffing box
 
Microstructure and chemical compositions of ferritic stainless steel
Microstructure and chemical compositions of ferritic stainless steelMicrostructure and chemical compositions of ferritic stainless steel
Microstructure and chemical compositions of ferritic stainless steel
 
Hyperloop- A 21st century transportation revolution
Hyperloop- A 21st century transportation revolutionHyperloop- A 21st century transportation revolution
Hyperloop- A 21st century transportation revolution
 

Recently uploaded

Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
amitlee9823
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 

Recently uploaded (20)

Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 

Image Compression using K-Means Clustering Method

  • 1. Image Compression using K-Means Clustering Method In Supervision of: Prof. Amit Mitra Submitted By: Gyanendra Awasthi(201315) Pankaj Kumar(170455)
  • 2. Contents Clustering K-means Clustering Cost Function Display on actual Dataset Code Snippets Examples of some original and compressed images Uses of image compression Results Drawbacks of K-means References
  • 3. Clustering •Group of collection of points into clusters • Patterns are extracted from variables without analysing any variable – unsupervised learning •The points in each cluster are closer to one another and far from points in other clusters
  • 4. K-Means Clustering • Unsupervised learning algorithm. • Grouping of different data points which are like each other. • Forming dissimilar groups and each group containing similar data points • To partition data into distinct K clusters. K is defined by user. •Works on predefined distinct K clusters in which each data point belongs to a particular cluster.
  • 5. Cost Function •The goal is to minimize within-cluster dissimilarity. •The Cost function(J) is: J= 𝑖=1 𝑁 𝑘=1 𝐾 𝑟𝑖𝑘 𝑥(𝑖) − 𝜇𝑘 2 Where= 𝑥(𝑖) are data points 𝜇𝑘 is center of cluster k. 𝑟𝑖𝑘 = 1 if 𝑥(𝑖) belongs to cluster k and 0 if it doesn’t belong to cluster k. k = 1,.,…,K where K is the number of clusters provided N is the number of total data points •J represents sum of distances between each data 𝑥(𝑖) and cluster center 𝜇𝑘. • Cost function J is minimized for optimal clustering. •After each iteration 𝜇𝑘 is obtained by the formula 𝜇𝑘 = 𝑖=1 𝑁 𝑟𝑖𝑘𝑥𝑖 𝑖=1 𝑁 𝑟𝑖𝑘
  • 6. K- Means Algorithm Step1- Randomly initialize the K data points as initial centroids for K clusters Step2- Until the cluster centers are changed or for max iteration ◦ Allocate each data point to centroid whose data point is nearest ◦ Replace the cluster centres with the mean of the element in their clusters end
  • 8. Code- Snippets To compute the nearest centroids for data points.
  • 9. Image Compression •An image is made up of small intensity dots called pixels. •Each pixel contains three values which are the values of intensities of Red, Blue, Green colors respectively for that pixel •Reducing the size that an image takes while storing and transmitting • Reducing the number of colors occurred in image to the most frequent colors appearing in it • Essentially forming the different clusters of frequent occurring colors present in the image by using pixel values
  • 10. Original and Compressed Image-Parrot 𝑡𝑛= time taken for K- means algorithm to run for n iterations Fig1b. 𝑡10= 1min 42sec Fig1a. Original Image
  • 11. Original and Compressed Image-Parrot Fig1c. 𝑡10= 6min 32sec Fig1d. 𝑡10= 12min 42sec Fig.1e 𝑡10= 50min 40sec
  • 12. Original and Compressed Image-Scenery Fig2b. 𝑡10= 2 min 10sec Fig2a. Original Image
  • 13. Original and Compressed Image-Scenery Fig2e. 𝑡10= 63 min 30sec Fig2d. 𝑡10= 15 min 30sec Fig2c. 𝑡10= 8 min 15sec
  • 14. Uses of Image Compression •Lesser data for storing the compressed image compared to original image, reducing the cost of storage and transmission • K-Means is utilized to compress visual contents in vast nexus of social messaging app for its faster transmission and less storage utilization •Used for archival purpose and for medical imaging, technical drawings •Widely used in remote sensing via satellite, television broadcasting, for capturing and transmitting satellite images
  • 15. Results Actual Size of Image of Parrot Number of clusters(K) Specified while Compressing the image Reduced Size of the Image of Parrot 1,87,236 bytes 100 52,032 bytes 20 54,888 bytes 15 54,888 bytes 12 54,351 bytes 2 43,616 bytes Table1. Results of K-means clustering applied on parrot.jpg
  • 16. Results Actual Size of Image of Scenery Number of clusters(K) Specified while Compressing the image Reduced Size of the Image of Scenery 5,50,287 bytes 50 1,01,404 bytes 10 1,01,813 bytes 5 95,616 bytes 2 83,729 bytes Table2. Results of K-means clustering applied on scenery.jpg
  • 17. Drawbacks of K-means • Gets sluggish as the size of data(image) increases. • Time taken by algorithm increases as the number of cluster (K) increases. • Results may represent a suboptimal local minimum. • Works only for linear or almost linear boundaries
  • 18. References •Xing Wan (2019), “Application of K-means Algorithm in Image Compression”, IOP Conference Series: Materials Science and Engineering, 563 052042, •B. Reddaiah “A Study on Image Compression and its Applications”, International Journal of Computer Applications, Volume 177 – No. 38, February 2020 •Hartigan, J. A., Wong, M. A. (1979). Algorithm as 136: a k-means clustering algorithm. Journal of the Royal Statistical Society, 28(1), 100-10 •https://www.simplilearn.com/tutorials/machine-learning-tutorial/k-means-clustering-algorithm •Van der Geer, J., Hanraads, J.A.J., Lupton, R.A. (2010) The art of writing a scientific article. J. Sci. Commun., 163: 51–59.