Introduction to CNN and Its Applications in Computer Vision
1. Introduction
Humans can easily recognize objects, faces, animals, vehicles, handwritten text, and different activities in images. For example, when we see an image of a cat, we can identify it even when its position, size, colour, background, or direction changes.
For a computer, an image is not directly understood as a cat, person, car, or building. A computer reads an image as a collection of numerical pixel values.
A Convolutional Neural Network, commonly called a CNN, is a deep learning model specially designed to process and understand visual data such as images and videos.
CNN is a type of deep neural network that automatically identifies important visual features and uses them for image classification, detection, recognition, and other computer vision tasks.
What Is Computer Vision?
Computer Vision is a branch of Artificial Intelligence that enables computers to extract meaningful information from images and videos.
The main objective of computer vision is to help machines perform visual tasks that humans perform using their eyes and brain.
Examples
- Recognizing a person's face
- Detecting a vehicle in traffic
- Identifying a disease from a medical image
- Reading handwritten digits
- Detecting defective products
- Identifying objects in CCTV footage
3. How Does a Computer Read an Image?
A digital image consists of small elements called pixels.
Each pixel contains a numerical value representing colour or brightness.
Grayscale Image
A grayscale image contains pixel values between:
Where:
-
0represents black -
255represents white - Values between 0 and 255 represent different shades of grey
For example:
This matrix represents the pixel values of a small grayscale image.
Colour Image
A colour image generally contains three channels:
- Red
- Green
- Blue
This is called an RGB image.
Each pixel contains three values:
Therefore, a computer processes images as numerical matrices rather than directly understanding the objects present in them.
4. What Is a Convolutional Neural Network?
A Convolutional Neural Network is a specialised deep learning architecture used mainly for processing image data.
A CNN automatically learns visual features such as:
- Edges
- Lines
- Corners
- Curves
- Textures
- Shapes
- Object parts
- Complete objects
A traditional machine learning model may require manual feature extraction. In CNN, feature extraction is performed automatically during training.
Basic Working
Input Image → Edges → Shapes → Cat Features → Cat Prediction
5. Why Is CNN Used for Images?
Images usually contain a very large number of pixel values.
Consider a colour image of size:
The total number of input values is:
If all these pixels are directly connected to every neuron in a traditional Artificial Neural Network, the number of parameters becomes extremely large.
This creates several problems:
- High computational cost
- Large memory requirement
- Longer training time
- Increased possibility of overfitting
- Loss of spatial information
CNN solves these problems by examining small regions of an image and sharing the same feature detector across different image locations.
Difference Between ANN and CNN
| Artificial Neural Network | Convolutional Neural Network |
|---|---|
| Used mainly for structured or tabular data | Used mainly for images and visual data |
| Input is generally a one-dimensional feature vector | Input can be a two-dimensional or three-dimensional image |
| Every neuron may connect with all input values | Neurons examine small local regions |
| Requires a large number of parameters for images | Uses fewer parameters through weight sharing |
| Does not naturally preserve spatial relationships | Preserves spatial relationships between pixels |
| Feature extraction may be performed manually | Features are learned automatically |
| Suitable for prediction and classification | Suitable for image recognition, detection and segmentation |
7. What Does Spatial Information Mean?
Spatial information describes the position and relationship of pixels within an image.
For example, in a face:
- Eyes are generally above the nose.
- The nose is generally above the mouth.
- The eyes are located near each other.
- The mouth is located in the lower part of the face.
The position of these features is important for recognizing the object.
A CNN preserves these relationships while processing an image.
Spatial information tells the model where visual features are located and how they are related to one another.
8. How Does CNN Recognize an Object?
A CNN learns image features gradually through multiple layers.
Consider the classification of a human face.
Initial Layers
The first few layers may identify simple features such as:
- Horizontal edges
- Vertical edges
- Curved edges
- Brightness changes
Middle Layers
The middle layers may combine simple features to identify:
- Eyes
- Nose
- Mouth
- Ears
Deeper Layers
The deeper layers combine all these features to recognize:
- A complete face
- A particular person
- A facial expression
The process can be represented as:
Pixels
↓
Edges
↓
Lines and curves
↓
Object parts
↓
Complete object
↓
Prediction
This is known as hierarchical feature learning.
9. Hierarchical Feature Learning
CNN does not identify a complete object in a single step. It learns features at different levels.
| CNN Layer Level | Features Learned |
|---|---|
| Initial layers | Edges, lines and colour patterns |
| Middle layers | Curves, textures and simple shapes |
| Deeper layers | Eyes, wheels, ears and object components |
| Final layers | Complete objects such as a person, car, dog or tumour |
Simple Example
For a car image:
Pixels → Edges → Curves → Wheels and windows → Complete car
For a face image:
Pixels → Lines → Eyes and nose → Facial structure → Face
10. Why Is It Called a Convolutional Neural Network?
It is called a Convolutional Neural Network because it uses a mathematical operation called convolution.
During convolution, a small matrix called a filter or kernel moves across the image and identifies important features.
For example, a filter may identify:
- Vertical edges
- Horizontal edges
- Curves
- Textures
- Colour patterns
The detailed convolution operation will be studied in the next section.
11. Basic CNN Architecture
A CNN generally contains the following layers:
Input Image ↓ Convolution Layer ↓ Activation Function ↓ Pooling Layer ↓ Flatten Layer ↓ Fully Connected Layer ↓ Output Layer
Role of Each Layer
| Layer | Main Function |
|---|---|
| Input Layer | Receives the image |
| Convolution Layer | Extracts important image features |
| Activation Layer | Introduces non-linearity |
| Pooling Layer | Reduces feature-map size |
| Flatten Layer | Converts feature maps into a one-dimensional vector |
| Fully Connected Layer | Performs classification |
| Output Layer | Produces the final prediction |
Applications of CNN in Computer Vision
12. Image Classification
Image classification assigns one class label to an entire image.
Examples
- Cat or dog
- Benign or malignant tumour
- Healthy or diseased plant
- Car, bus or motorcycle
- Normal or defective product
Input Image → CNN → Predicted Class
For example:
Chest X-ray → CNN → Normal or Pneumonia
13. Object Detection
Object detection identifies:
- Which objects are present
- Where the objects are located
It usually draws a rectangular box called a bounding box around each detected object.
Examples
- Detecting people in CCTV footage
- Detecting vehicles on roads
- Detecting helmets worn by riders
- Detecting tumours in medical images
- Detecting products on store shelves
Difference from Classification
| Image Classification | Object Detection |
|---|---|
| Predicts one label for an image | Identifies multiple objects |
| Does not show object location | Shows object location using bounding boxes |
| Example: “This image contains a car” | Example: “There are three cars at these locations” |
14. Image Segmentation
Image segmentation divides an image into meaningful regions.
Instead of drawing only a rectangular box, segmentation identifies the exact pixels belonging to an object.
Examples
- Identifying the exact tumour region
- Separating roads, vehicles and pedestrians
- Identifying damaged regions in machinery
- Separating land, water and vegetation in satellite images
- Identifying organs in medical images
Input Image → CNN → Pixel-level object regions
15. Face Recognition
CNNs are widely used for recognising and verifying human faces.
Applications
- Smartphone face unlocking
- Attendance systems
- Airport security
- Employee verification
- Surveillance systems
- Banking authentication
CNN extracts facial features and compares them with stored facial information.
16. Medical Image Analysis
CNNs can analyse medical images such as:
- X-rays
- Computed Tomography scans
- Magnetic Resonance Imaging scans
- Ultrasound images
- Mammograms
- Skin lesion images
Applications
- Breast cancer detection
- Brain tumour detection
- Pneumonia detection
- Lung disease classification
- Skin cancer detection
- Diabetic retinopathy detection
CNN assists doctors by identifying patterns that may indicate disease. It supports medical decision-making but does not independently replace medical professionals.
17. Autonomous Vehicles
Self-driving vehicles use CNNs to understand road scenes.
CNNs can identify:
- Roads
- Traffic signals
- Pedestrians
- Vehicles
- Road signs
- Lane markings
- Obstacles
Example:
Camera Image → CNN → Road objects → Driving decision
18. Handwriting Recognition
CNNs are used to recognize handwritten characters and digits.
Applications
- Reading postal codes
- Processing bank cheques
- Digitizing handwritten forms
- Recognizing handwritten numbers
- Optical Character Recognition systems
The MNIST handwritten-digit dataset is commonly used to introduce CNN-based image classification.
19. Industrial Quality Inspection
CNNs can automatically inspect products in manufacturing industries.
Applications
- Detecting cracks
- Identifying scratches
- Finding missing parts
- Identifying incorrect shapes
- Detecting surface defects
- Separating defective products
This improves production quality and reduces dependence on manual inspection.
20. Agriculture
CNNs are used in smart agriculture for:
- Plant disease detection
- Fruit classification
- Crop monitoring
- Weed identification
- Pest detection
- Fruit quality assessment
For example:
Leaf Image → CNN → Healthy or Diseased
21. Security and Surveillance
CNNs help analyse images and videos collected through surveillance cameras.
Applications
- Person detection
- Suspicious activity detection
- Intrusion detection
- Crowd monitoring
- Weapon detection
- Vehicle-number recognition
22. Satellite and Remote-Sensing Images
CNNs can analyse satellite and aerial images.
Applications
- Land-use classification
- Forest monitoring
- Flood detection
- Fire detection
- Urban-development analysis
- Crop-area identification
- Disaster assessment
23. Real-Life Example
Consider a hospital where a mammogram image is submitted for breast cancer analysis.
The CNN processes the image through several layers:
Mammogram Image ↓ Edges and boundaries ↓ Textures and shapes ↓ Suspicious tumour patterns ↓ Benign or Malignant prediction
The initial layers detect basic edges and textures. The deeper layers identify complex tumour-related patterns. Finally, the fully connected and output layers generate the classification result.
24. Advantages of CNN
- Automatically extracts relevant features
- Preserves spatial relationships in images
- Requires less manual feature engineering
- Uses fewer parameters than a fully connected network for image processing
- Provides high performance in visual-recognition tasks
- Can learn simple as well as complex image patterns
- Can be applied to images, videos and medical scans
- Supports classification, detection and segmentation
25. Limitations of CNN
- Requires a sufficiently large dataset
- Training can require high computational power
- Complex CNNs may require a Graphics Processing Unit
- Model training may take considerable time
- Performance depends on the quality of the images
- CNN decisions may be difficult to interpret
- Incorrect or biased training data can produce unreliable predictions
- Hyperparameters and architecture must be carefully selected
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏