Image Processing: Color Conversions

Adrienne Kline
CodeX
Published in
5 min readApr 24, 2022

--

Image processing is needed in many applications. This article (and several to follow) is dedicated to highlighting how to perform classic image processing techniques in Python. Specifically, in this article, we will cover some color conversions/separations:

  1. Take a Red-Green-Blue (RGB) image as input into Python and separate individual color channels
  2. Recombine RGB color channels to reconstruct the initial image
  3. Convert an RGB image and convert it to a grayscale image in Python
  4. Convert an RGB image to a Hue-Saturation-Value (HSV) image in Python. Note, sometimes HSV is referred to HSI Hue-Saturation-Intensity

Our input image will be an image of one of the desserts I’ve made (see below) and took a photo of-crème brûlée!

Original RGB image (Image by Author)

Load Image

We will need to import libraries numpy and matplotlib.pyplot. Reading in images, can be done using the command: plt.imread. Images can be in .png, .tif, .jpg, or .svg formats.

# load our libraries:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure

--

--

Adrienne Kline
CodeX
Writer for

I'm an assistant professor @ Northwestern University and Head of AI & Eng. @ Northwestern Medicine's BCVI Center for AI