Anjani Kumar
3 min readOct 28, 2023
image courtesy educba

Convolutional Neural Network(CNN) Simplified(Part 1) :

A Convolutional Neural Network (CNN) is a class of deep learning neural networks primarily designed for processing grid-like data,
such as images and videos. They are very effective in tasks like image recognition, object detection, and even in some natural language
processing applications.

CNNs are particularly well-suited for these tasks because they can automatically and adaptively learn spatial hierarchies of features
from input data. They do this through a series of convolutional and pooling layers.

Now we know the definition of CNN, Before Moving to CNNs deeply, let’s understand why we should not use ANN for image recognition and other image and video processing tasks.

Reasons are below:

  1. High Computation Cost(due to fully connected layers)
  2. Overfitting
  3. Loss of important information like spatial arrangement of pixels of an image.

Let us understand working of CNNs :

An image is 2D grid of Pixels. Given an image, we apply filters(also called kernels) whose main role is to find the primitive features and
later more complex features in a given image.

Types of images:

We have two type of images

1 ) Black & White image(also called Grey Scale Images)
2 ) Colored Image(also called RGB(Red Blue & Green) images)

Just to re-iterate an image is made up of Pixels.Our main task is to detect edges in the given image using convolutional operation
Detecting edges means checking for intensity change in that given image.

To Perform a convolutional operation we require filters/kernels. Below images will give an idea.

We have greyscale (black & white) image of 6*6 pixels. We have applied a horizontal filter of 3*3 on that image. As a result we got the feature map of size 4*4

Calculation to get the feature map of 4*4(performing for 1st row of 1st column of the feature map)

0*-1+0*-1+0*-1+0*0+0*0+0*0+0*1+0*1+0*1=0

Similarly we will perform the convolution operation for all the cells.

Equation to get 4*4 feature map when the image size is 6*6.

Let Image is n,filter/kernel is m then feature map will be calculated using below formula

Feature Map=(n-m+1)*(n-m+1) =(6–3+1)*(6–3+1)=4*4

Horizontal Edge detection Filter/Kernal
Horizontal Edge Detection Filter

Similarly we can apply a vertical edge Detection filter of 3*3 and we will be able to find the vertical edges.

In case of colored(RGB) images we have three channels of Red, Blue and Green and convolution operation will look like below. While performing convolution operation, it will look like a cuboid placed on top of the image.

Here 3 in 6*6*3 & 3*3*3 denotes the Channel (red, blue & green)

The Complete CNN Operation looks like below

image courtesy internet

I hope you like my article on CNN(Part 1).Please click on Clap if you liked and want me to motivate to write more .Share with your friends too.

Want to connect :

Linked In : https://www.linkedin.com/in/anjani-kumar-9b969a39/

If you like my posts here on Medium and would wish for me to continue doing this work, consider supporting me on patreon

Anjani Kumar

I am Lead Data Scientist and having interest to create blogs in Data Science,AI/ML,LLMs