For this article, I will discuss two topics about image processing: Homography Matrix & Template Matching

Homography transformations

Homography is defined as mapping between two different projections of an image and is represented by a 3x3 transformation matrix in a homogenous coordinates space. We can use this to transform an image through a combination of rotation, translation, scaling, or skew operations. Let’s use this chess board as an example:

A chess board

The image above was taken in an angle where it appears to be slanted. Let’s try to make it on top-view:

src = np.array([391, 100,
14, 271,
347, 624,
747, 298,
]).reshape((4, 2))

Image segmentation is the process of partitioning an image into several segments or extracting a specific part or information of an image. For this article, I will discuss how we would be able to segment the image using two kinds of color segmentation: RGB and HSV, and also via image differentiation.

Color segmentation

It is possible to segment images based on their color via RGB and HSV. Depending on which segmentation technique you will use, you will be able to extract a specific segment of the image as long as it is colored. Let’s use this colored balls for this one:

RGB balls

Via RGB color space


Blobs are pixels that are grouped or connected together that share common properties in an image. Blobs may take different kinds of objects In this article, we will attempt to correctly detect these blobs using this image:

A set of US coins

Our aim is to be able to detect the coins correctly. In order to do this we need to transform the image into a binary format since blobs could be identified as bright areas in a dark background or vice-versa.

from import imread, imshow
from skimage.color import rgb2gray
im = rgb2gray(imread(‘coins.jfif’))
im_bw = im < 0.85

Digital images could not only be enhanced, but could also be filtered or morphed. In this article, I will discuss two ways: spatial filters and morphological operations

Spatial filters

Spatial filters are matrix filters that are applied on an image using convolution. There are different kinds of spatial filters that could be applied in an image, however I will only discuss two spatial filters: horizontal and vertical sobel filters. Let’s use this image again:

Guinan & Captain Jean-Luc Picard aboard USS Enterprise-D
import matplotlib.pyplot as plt
from scipy.signal import convolve2d
gp_bw = rgb2gray(imread('guinanpicard.png'))
## Applying Horizontal Sobel Filter
## Horizontal Sobel Filter
kernel1 = np.array([[1, …

In my previous article, I discussed how we could a little bit more understand a digital image using Python. Now I will discuss how we will be able to enhance digital images still using Python via White Balancing and Histogram Manipulation.

White Balancing

White balancing is a method where we correct a digital image by turning white or neutral colored regions appear white in a digital image. I will discuss three algorithms of white balancing: white patch, gray world, and ground-truth. For the sake of simplicity, let’s reuse the image from my previous article:

Guinan & Captain Jean-Luc Picard aboard USS Enterprise-D

White patch algorithm

This algorithm normalizes each color channel depending on…

In this article, I will discuss how could we do basic digital image processing using Python and extract information from images.

It is known that digital images are digital representations of images and are usually represented as n-dimensional matrix values called pixels. Let’s try it in this “futuristic” image of Guinan and Captain Jean-Luc Picard of the USS Enterprise (yes, because I am a Star Trek fan) and extract its pixel values:

Guinan & Captain Jean-Luc Picard aboard USS Enterprise-D
## Import the image using imread
guinanpicard = imread(‘guinanpicard.jpg’)
## Output of guinanpicard array([[[ 73, 81, 156], [ 73, 83, 154], [ 67, 80, 148], ..., […

Cymon Marcaida

A developer by day, a programmer by night

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store