UNIT-II_Low Level Computer Vision
UNIT-II_Low Level Computer Vision
UNIT -II
Low Level
Computer Vision
VIDYA JAGTAP
Low Level Image Processing: Image filtering, 2D
Convolution, smoothing, sharpening Spatial and
frequency domain filtering,
Introduction to Low Level Image Processing:
These processes are typically performed on the pixel level and are
used to:
VIDYA JAGTAP
Low-level image processing techniques include:
1. *Linear filters*:
- Mean filter (average neighboring pixels)
VIDYA JAGTAP
- Gaussian filter (weighted average)
2. *Non-linear filters*:
- Sobel filter (edge detection)
- Laplacian of Gaussian (LoG) filter (edge detection)
- Canny filter (edge detection)
3. *Frequency domain filters*:
- Fourier transform (filter in frequency domain)
- Wavelet transform (filter in frequency domain)
4. *Morphological filters*:
- Erosion (remove small features)
- Dilation (expand features)
- Opening (erosion followed by dilation)
- Closing (dilation followed by erosion)
5. *Other filters*:
- Bilateral filter (edge-preserving smoothing)
- Anisotropic diffusion filter (edge-preserving smoothing)
VIDYA JAGTAP
Filtering can be applied in various domains,
including:
1. *Spatial domain*: Directly manipulate pixel values.
2. *Frequency domain*: Modify image data in the frequency domain.
3. *Wavelet domain*: Use wavelet transforms to filter images.
2. *Kernel Padding*: Pad the kernel with zeros to match the size of the image,
if necessary.
3. *Image Padding*: Pad the image with zeros to ensure that the kernel can
slide over the entire image, if necessary.
VIDYA JAGTAP
4. *Kernel Sliding*: Slide the kernel over the image, starting
from the top-left corner.
VIDYA JAGTAP
Mathematical Representation of 2D Convolution:-
Let `I` be the image, `K` be the kernel, and `O` be the output image.
The 2D convolution is represented as:
where `x` and `y` are the coordinates of the output pixel,
`i` and `j` are the coordinates of the kernel,
`ΣΣ` denotes the summation over the kernel.
VIDYA JAGTAP
Types of 2D Convolution:_
1. _Valid Convolution_: Only compute output pixels where the kernel fully overlaps with
the image.
2. _Same Convolution_: Compute output pixels even when the kernel partially overlaps
with the image, padding with zeros if necessary.
3. _Full Convolution_: Compute output pixels for all possible kernel positions, padding
with zeros if necessary.
Applications of 2D Convolution:
1. _Image Filtering_: Apply filters to enhance or restore images (e.g., blur, sharpen,
edge detection).
2. _Image Feature Extraction_: Extract features like edges, lines, or textures.
3. _Image Denoising_: Remove noise from images.
Sometimes, images can be noisy or have rough textures. That's where smoothing
comes in - a technique in low-level image processing to reduce noise and smooth out
textures.
2. *Median Filter*: Replaces each pixel with the median value of neighboring pixels.
3. *Gaussian Filter*: Uses a Gaussian distribution to weight neighboring pixels.
VIDYA JAGTAP
Advantages of Smoothing:
1. *Reduce noise*
2. *Remove small details*
VIDYA JAGTAP
Histogram processing (equalization, matching) Edge
detection (Sobel, Canny)
Histogram processing :-
Histogram processing is a technique used in image processing to
analyze and modify the distribution of pixel values in an image.
A histogram is a graphical representation of the frequency of each
pixel value in an image.
VIDYA JAGTAP
Histogram processing is used for:
1. _Image enhancement_
2. _Contrast adjustment_
3. _Brightness adjustment_
4. _Noise reduction_
5. _Image segmentation_
*Example:*
Original Image:
```
Pixel Values: [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
Histogram: [5, 5]
```
VIDYA JAGTAP
After Histogram Equalization:
Pixel Values: [0, 0, 0, 1, 1, 1, 1, 1, 1, 1]
Histogram: [5, 5]
In this example, the original image has a skewed histogram with most
pixels having a value of 0 or 1. After histogram equalization, the pixel
values are adjusted to create a more uniform distribution, enhancing
the contrast of the image.
*Steps:*
1. Calculate the histogram of the original image.
2. Calculate the cumulative distribution function (CDF) of the
histogram.
3. Map each pixel value to its corresponding CDF value.
4. Scale the CDF values to the range [0, 255] (or the maximum pixel
value).
VIDYA JAGTAP
*Code Example (Python):*
import cv2
import numpy as np
```
Histogram matching :
Histogram matching is a technique used to transform the histogram of an image to match
a reference histogram. This is useful for:
1. _Image normalization_: To reduce variations in lighting conditions.
2. _Image registration_: To align multiple images.
3. _Image fusion_: To combine multiple images.
Reference Histogram:
```
[0, 0, 0, 10, 20, 30, 20, 10, 0, 0]
```
Original Image Histogram:
```
[0, 5, 10, 15, 20, 15, 10, 5, 0, 0]
```
```
[0, 0, 0, 10, 20, 30, 20, 10, 0, 0]
```
VIDYA JAGTAP
Example (Python):_
```
import cv2
import numpy as np
1. *Sobel:* Simple and fast, but sensitive to noise and may detect
false edges.
VIDYA JAGTAP
Sobel Edge Detection Example:
Original Image:
```
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
```
Sobel Horizontal Gradient:
```
-2 -1 0 1 2
-2 -1 0 1 2
-2 -1 0 1 2
-2 -1 0 1 2
-2 -1 0 1 2
```
VIDYA JAGTAP
```
Sobel Vertical Gradient:
-10 -8 -6 -4 -2
-8 -6 -4 -2 0
-6 -4 -2 0 2
-4 -2 0 2 4
-2 0 2 4 6
```
```
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
```
VIDYA JAGTAP
Canny Edge Detection Example:_
Original Image:
```
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
```
Canny Edge Detection Output:
```
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
```
Canny output is similar to the Sobel output, but with more refined edges and
less noise.
VIDYA JAGTAP
Local pre-processing :
Local pre-processing operators in image processing are techniques
applied to small regions of an image to enhance or transform the
image. These operators are used to:
These local operators are applied to small regions (typically 3x3 or 5x5
pixels) and are used as a pre-processing step for various image
processing tasks, such as:
1. *Image segmentation*
2. *Object recognition*
3. *Feature extraction*
4. *Image compression*
VIDYA JAGTAP
Line and corner detection :
Line and corner detection are essential techniques in image processing for identifying important
features in images.
*Line Detection:*
Line detection involves identifying straight lines or edges in an image. Common techniques
include:
1. *Hough Transform:* A popular method for detecting lines, circles, and ellipses.
2. *Canny Edge Detection:* Detects edges, which can be used to identify lines.
3. *Sobel Operator:* Detects edges, which can be used to identify lines.
*Example:*
Original Image:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
VIDYA JAGTAP
*Corner Detection:*
Corner detection involves identifying points of interest in an image where two edges
meet. Common techniques include:
*Example:*
Original Image:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
OpenCV (Open Source Computer Vision Library) is a widely used, open-source library for
computer vision and machine learning. It provides a comprehensive set of functions and
tools for image and video processing, feature detection, object recognition, and more.
Key Features:
Main Modules:
1. _Core_: Basic data structures and functions.
2. _ImgProc_: Image processing and feature detection.
3. _Video_: Video processing and analysis.
4. _Features2D_: 2D feature detection and description.
5. _ObjDetect_: Object detection and recognition.
6. _Calib3D_: 3D calibration and reconstruction.
7. _ML_: Machine learning and statistical functions.
VIDYA JAGTAP
Popular OpenCV Applications:
1. _Image and video processing_
2. _Object recognition and detection_
3. _Facial recognition and tracking_
4. _Motion analysis and tracking_
5. _3D reconstruction and modeling_
6. _Robotics and autonomous systems_
7. _Healthcare and medical imaging_
VIDYA JAGTAP
Tools to open and display images using
Python:
VIDYA JAGTAP
VIDYA JAGTAP
VIDYA JAGTAP
VIDYA JAGTAP
VIDYA JAGTAP
VIDYA JAGTAP
VIDYA JAGTAP