Image Processing

Manikandan Prabhakaran
3 min readMar 26, 2020

Image processing can be used in various fields like medical imaging, identifying cancer cells, classifying flower families to face recognition. image-processing works by taking an image as an input and using a set of algorithms to extract the information from the image.

when an image is captured it will be stored as a two-dimensional matrix contains pixel values in each of its cells. Normally pixel values vary from 0–255 based on the colour intensity. while talking about colours we should know about the colour channels as well. The RGB images usually contain three channels as the name intends Red, Green and Blue.

we will be using these images to train an ML model based on our need. for that, we need to preprocess the image data we collected. Preprocessing involves reducing as much unwanted information in the images to be used in the model.

Preprocessing is a major task in image processing. Normally our image contains a lot of data. we need to suppress the background information and track the object of our interest. For that, we need to perform certain operations.

operations like,

  1. Smoothening
  2. grayscaling
  3. Thresholding

will be performed.

  1. Smoothening:

Smoothening is the process used to reduce the background details in an image. we can use a Gaussian filter to smoothen the image. In this normal blurring of an image will be performed. The Gaussian kernel will act as a low pass filter here(which allows the only low frequency to pass through). Edges in our images will be having high contrasting changes in pixel values based on the gradient change.

Edge description

This is how an edge is gonna a look like. The edge sectors will be having high pixel values due to sharp changes. The Gaussian filter will allow only low pixel values and ignores high pixel values. so we can get the Smoothened image.

2. Grayscaling:

Grayscaling the process of conversion of our image into black and white, which will reduce a lot of information in our image. we can say it is the midpoint between the black (0) and white (255). There are many versions of grayscale conversions.

I suggest, RGB[A] to Gray: Y←0.299⋅R+0.587⋅G+0.114⋅B the formula for conversion of RGB images into Grayscale.

RGB to grayscale conversion

3. Thresholding:

Thresholding is the process of segmenting the foreground from the background, which will be very useful to track our objects. As we are using image data of pixel values (0–255) we can fix a threshold value for segmenting foreground and background. We can say 120 in the sense the pixel values above 120 will be converted into white(255) and below 120 will be converted into black(0). That's how the foreground is segmented from the background.

Thresholded image.

Thus our image data is ready for Preprocessing.

--

--

Manikandan Prabhakaran

Computer Programming student, ML Intermediate, Django-ist