TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

RGB Color Image Compression Using Principal Component Analysis

9 min readMar 29, 2022

--

(Image by author)

Previously, we’ve discussed how we can use PCA to compress grayscale images in the MNIST digits dataset. You can read that article here.

This is an advanced version of the previously published article. This time, we apply the same concepts to compress an RGB color image, not a grayscale image.

The difference between RGB and grayscale images

The primary difference between RGB and grayscale images is the number of color channels that the image has. An RGB image has three color channels: Red, Green and Blue while a grayscale image has only a single color channel.

Red, Green and Blue color channels of an RGB image (Image by author)
Single color channel of a grayscale image (Image by author)

Another difference is the representation of RGB and grayscale images in ML and DL. A grayscale image is represented by a two-dimensional (2D) NumPy array. It can also be represented by a flattened one-dimensional (1D) NumPy array.

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Rukshan Pramoditha
Rukshan Pramoditha

Written by Rukshan Pramoditha

3,000,000+ Views | BSc in Stats (University of Colombo, Sri Lanka) | Top 50 Data Science, AI/ML Technical Writer on Medium

Responses (2)