Professional Documents
Culture Documents
Name of Faculty:
Dr. Umesh Sahu
(Assistant Professor)
Manipal Institute of Technology, Manipal, India
−1−
Syllabus
Image acquisition and pre-processing: [15]
Vision system components, Image acquisition and analysis, Image
formation - Sampling & Quantization, simple operations on image,
Image enhancement: Spatial Domain and frequency domain
methods, Image noise, image restoration , morphological operations,
Segmentation, image analysis, representation of regions, Feature
extraction, fundamentals of color image processing, conversion of
color spaces.
Enhance
Enhance
• Histogram Processing
• Basic Intensity (Gray level) transformations
• Point Processing
• Neighborhood processing (Spatial Filtering)
Frequency of occurrence
0 4 8 10 12
12 16 5 0 16
4 16 8 5 10 5 5
10 0 4 12 16 4
5
12 0 16 0 8 3 3 3
4
2
3
2
1
0 4 5 8 10 12 16
Gray Level
130
36 36
22
0 1 2 3 level
Image 16x14 = 224 pixels
6000
5000
4000
3000
2000
1000
4
x 10
4
3.5
2.5
1.5
0.5
• MATLAB
• To create a histogram of our image data, we use the imhist() function.
https://www.geeksforgeeks.org/opencv-python-program-analyze-image-using-histogram/
Manipal Institute of Technology, Manipal, India
− 19 −
Histogram Processing: Histogram Equalization
Histogram h(rk ) = nk
rk is the k th intensity value
nk is the number of pixels in the image with intensity rk
nk
Normalized histogram p(rk ) =
MN
nk : the number of pixels in the image of size M N with intensity rk
Mathematical Derivation:
Gonzalez, Rafael C., and Richard E. Woods. "Digital Image Processing, New Jersey.", 2007. 3rd edition. (Chapter-3, Page-144)
• OpenCV Python
• use cv2.equalizeHist() to find the histograms Equalization of a image.
• MATLAB
• Histogram equalization: histeq()
https://www.geeksforgeeks.org/histograms-equalization-opencv/
Manipal Institute of Technology, Manipal, India
− 33 −
Histogram Processing:
▪ Histogram Equalization
• Histogram Processing
• Basic Intensity (Gray level) transformations
• Point Processing
• Neighborhood processing (Spatial Filtering)
Original Processed
Image image
T
(x,y) (x,y)
–E.g. Low pass filter/ smoothing filter, high pass filter/ sharpening filters.
▪ Spatial filters are versatile as they are used in linear as well as non-linear.
g ( x, y) = T [ f ( x, y)]
Original Processed
Image image
T
(x,y) (x,y)
u
0 L
This transformation
maps a narrow range
of low intensity
values in the input
image to a wider
range of output level
and vice versa.
(x,y) (x,y)
▪ Known as neighborhood processing or spatial filtering, with the second term being more
prevalent.
▪ If the computations performed on the pixels of the neighborhoods are linear, the
operation is called linear spatial filtering (the term spatial convolution also used);
▪ Otherwise it is called nonlinear spatial filtering.
7 9 11
0 0 0 0 0
10 50 8
0 7 9 11 0
9 5 6
Original Image 0 10 50 8 0
0 9 5 6 0
1 1 1
1/9 1 1 1 0 0 0 0 0
0 9 5 6 0
0 0 0 0 0
0 x 1/9 + 0 x 1/9 + 0 x 1/9 + 0x 1/9 + 7 x 1/9 + 9 x 1/9 + 0 x 1/9 + 10 x 1/9 + 50 x 1/9 = 8.4
Manipal Institute of Technology, Manipal, India
− 60 −
Movement of Spatial Mask (Cont..)
0 9 5 6 0
0 0 0 0 0
0 x 1/9 + 0 x 1/9 + 0 x 1/9+ 7 x 1/9 + 9 x 1/9 + 11 x 1/9 +10 x 1/9 +50 x 1/9 + 8 x 1/9 = 10.5
0 9 5 6 0
0 0 0 0 0
0 x 1/9 + 0 x 1/9 + 0 x 1/9+9 x 1/9 +11 x 1/9 + 0 x 1/9 + 50 x 1/9 + 8 x 1/9 + 0 x 1/9 = 8.6
0 0 0 0 0
0 0 0 0 0
0 x 1/9 + 7 x 1/9 +9 x 1/9 + 0 x 1/9 +10 x 1/9 + 50 x 1/9 + 0 x 1/9 + 9 x 1/9 + 5 x 1/9 = 10
Manipal Institute of Technology, Manipal, India
− 63 −
Movement of Spatial Mask (Cont..)
0 0 0 0 0
0 0 0 0 0
=
7 x 1/9 + 9 x 1/9 + 11 x 1/9 +10 x 1/9 + 50 x 1/9+8 x 1/9 + 9 x 1/9 +5 x 1/9 + 6 x 1/9 12.7
Manipal Institute of Technology, Manipal, India
− 64 −
Movement of Spatial Mask (Cont..)
0 0 0 0 0
0 0 0 0 0
9 x 1/9 + 11 x 1/9 + 0 x 1/9 + 50 x 1/9 + 8 x 1/9 + 0 x 1/9 + 5 x 1/9+ 6 x 1/9 + 0 x 1/9 = 9.8
0 0 0 0 0
0 7 9 11 0
0 x 1/9 + 10 x 1/9 +12 x 1/9 + 0 x 1/9 + 9 x 1/9 + 5 x 1/9 + 0 x 1/9 + 0x 1/9 + 0 x 1/9 = 8.2
Manipal Institute of Technology, Manipal, India
− 66 −
Movement of Spatial Mask (Cont..)
0 0 0 0 0
0 7 9 11 0
10 x 1/9 +50 x 1/9 + 8x 1/9 + 9 x 1/9 + 5 x 1/9 + 6 x 1/9 + 0 x 1/9 + 0 x 1/9 + 0 x 1/9 = 9.7
0 0 0 0 0
0 7 9 11 0
12 x 1/9 + 5 x 1/9 + 0 x 1/9 + 4 x 1/9 + 6 x 1/9+ 0 x 1/9 + 0 x 1/9 + 0 x 1/9 + 0 x 1/9 = 7.6
0 0 0 0 0
0 0 0 0 0
7 9 11 8 11 9
10 50 8 10 13 10
9 5 6 8 10 8
3x3
Smoothing
filter
5x5
Smoothing
filter
• MATLAB
• fspecial() useful to create filters
• imfilter() does cross correlation
• OpenCV Python
• Python | Intensity Transformation Operations on Images
https://www.geeksforgeeks.org/python-intensity-transformation-operations-on-images/
1 1 1 1
1 1 1
9
1 1 1
Original Image 1 1 2 1
2 4 2
16
1 2 1
Non-linear Filters
▪ The mean filter is a simple sliding-window ▪ The median filter is also a sliding-window
spatial filter that replaces the center value in spatial filter, but it replaces the center value
the window with the average (mean) of all in the window with the median of all the pixel
the pixel values in the window. The window, values in the window. As for the mean filter,
or kernel, is usually square but can be any the kernel is usually square but can be any
shape. An example of mean filtering of a shape. An example of median filtering of a
single 3x3 window of values is shown single 3x3 window of values is shown
below. below.
5 + 3 + 6 + 2 + 1 + 9 + 8 + 4 + 7 = 45
45 / 9 = 5 0, 2, 3, 3, 4, 6, 10, 15, 97
MATLAB
DEMO