1. Fundamentals
  2. Image Enhancement
  3. Morphological Operation (merged with 4)
  4. Blob Detection (merged with 3)
  5. Image Segmentation
  6. Image Differencing
  7. Projective Transformation
  8. Leaf Classification
  9. Template Matching
  • Quite a practical one, but when using different libraries, if you are not getting the result that you were expecting or none at all, try to check or play around with the channels that you pass through the function. Sometimes a function is looking for three, sometimes it’s expecting only one channel.
  • Thresholding always helps. It’s nice to be able to manipulate images while only…

First, let’s see our source image:

from skimage.io import imread, imshow
from skimage.color import rgb2gray
carrier = imread('aircraft_carrier.jpg')
carrier_gray = rgb2gray(carrier)
imshow(carrier_gray);

Then, we define our template. For this image we just choose one of the planes:

template = carrier_gray[648:744,775:838]
imshow(template);

Visualizing an example

import numpy as np
import matplotlib.pyplot as plt
import skimage.io as skio
from skimage import img_as_ubyte, img_as_float
from skimage.io import imread, imshow
plt.figure(dpi=200)
plant = imread('plantA_1.jpg')
imshow(plant);

Let’s try preparing this image for segmentation. We also crop the borders of the image as there some to be extra pixels from the original picture:

from skimage.morphology import erosion, dilation, opening, closing
from skimage.measure import label, regionprops
from skimage.color import label2rgb
def multi_dil(im,num):
for i in range(num):
im = dilation(im)
return im
def multi_ero(im,num):
for i in range(num):
im = erosion(im)
return im
plt.figure(dpi=200)
leaves = 1.0 * ((plant/255) < 0.4)[5:-5,5:-5,0]
imshow(leaves);


In this article, I will tackle how to project an image from a perspective to a top-down view. We will use the following book cover for this purpose:

This should be straight forward. We will identify the corners of the book in the original image. We go about this counter-clockwise starting from the upper-left corner:


Change is inevitable. But with so much of our world changing, it’s great if we are able to measure how much change has occurred.

In this article I will be discussing how to measure how much change has occurred to this satellite image over some months:


Since I’ve already established the fundamentals in Seeing the World in Code, this is going to be a relatively short article about how you can use the RGB and HSV channels. We will use the image I used in White Balancing to get the labels out of the bottles in the image:

Let us try the RGB channel first:

from skimage.io import imread, imshowimg = imread('img1.jpg')# RGB Channels
img_r = img[:,:,0]
img_g = img[:,:,1]
img_b = img[:,:,2]
# Segmenting the image through their RGB channels res_b = ((img_r < 101) & (img_g < 101) & (img_b >=101))/255 red_b…


View from Mt. Makiling Traverse, Philippines. [Image by Tonee L. Bayhon]

Agriculture is one of the key contributors to economies that have arable land to its resources. In this time that most industries are integrating smart technologies, agriculture cannot be left behind. I come from a country and a community where agriculture is the foundation to development thus talking about smart agriculture is close to my heart.

This article will discuss a simple way how we can use image processing to aid in smart agriculture. Specifically, we will try to localize crop trees to aid farmers in monitoring them by using morphological operations and blob detection. …


We’re living in a world overrun by filters and airbrushed models. However, I personally believe that beauty and meaning are found where truth is. The same goes for images. So, we perform image enhancements, primarily to restore images to how they should really look.

This article will discuss the following white balancing techniques for image enhancement:

  • White Patch Algorithm
  • Gray-World Algorithm
  • Ground Truth Algorithm


Makati Central Business District Skyline viewed from Barangka Ilaya, Mandaluyong city. [Image by Tonee Bayhon.]

255. It’s a number I’ve seen for the longest time and only ever considered it as a value that I enter in dialog boxes on some photo-editing software. However, using Python code to perform image processing has definitely given a new meaning to “255” along with everything I know and do not know about digital images.

Let us begin by Zooming into a 2x2 black and white image. In order for us to visualize this, we will use numpy as we will mostly process images using their numeric array form.

import numpy as np
from skimage.io import imshow, imread

Tonee Bayhon

Am I doing this data science thing right?

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