0% found this document useful (0 votes)
2 views

Lecture 5 and 6

The document provides an overview of image and video processing, focusing on histograms, histogram equalization, and smoothing filters. It explains the concept of histograms in relation to pixel intensities and their applications in image enhancement and analysis. Additionally, it covers various smoothing techniques, including Box Car and Gaussian filters, and their effects on image quality.

Uploaded by

hurraysmart141
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lecture 5 and 6

The document provides an overview of image and video processing, focusing on histograms, histogram equalization, and smoothing filters. It explains the concept of histograms in relation to pixel intensities and their applications in image enhancement and analysis. Additionally, it covers various smoothing techniques, including Box Car and Gaussian filters, and their effects on image quality.

Uploaded by

hurraysmart141
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

CSET344/CMCA544

Image and Video Processing

Dr. Gaurav Kumar Dashondhi


Ph.D. IIT Bombay

Overall Course Coordinator- Lect. Week


Dr. Gaurav Kumar Dashondhi 20th Jan to 24th Jan 2025
[email protected]
1
Histogram
A histogram is a graphical representation that shows the relationship between gray levels (pixel intensities)
and their corresponding frequencies in an image.
h(rk) = nk for k = 0,1,2,3……L-1
Frequency

Where, nk is the number of pixels with intensity rk.

P(rk) = h(rk) / MN

P(rk) = Probabilities of Intensity levels occurring in an image.


Grey Levels
M,N are row and column of an image.

Sum of P(rk) for all values of k equal to 1.

Application
1. Image Enhancement
2. Image Thresholding
3. Image Segmentation
4. Image Analysis
2
Histogram Examples

3
Histogram Example
Histogram ? Intensity or Grey Level Frequency Normalized
Histogram
For a 3-bit image and size is 3x 3
1 3 3/9
1 2 6
2 1 1/9
6 1 3
3 1 1/9
1 6 6
6 4 4/9

For a 8-bit image and size is 3x3


150 200 115 Intensity or Grey Level Frequency Normalized
Histogram
200 125 150
250 100 250

4
Histogram Equalization
Its a technique used in image processing to improve the contrast of an image. It works by redistributing the intensity values
of the pixels in an image so that the histogram becomes more uniform.

Sk = T(rk)

Sk = L-1

Where –
L = number of possible intensity levels
Sk = output intensity levels
rk = input intensity levels
Why it is required ?

To enhance the contrast of an image, especially when the pixel intensity values are concentrated in a narrow range
(e.g., very dark or very bright images).

It makes details more visible in poorly contrasted images


5
Histogram Equalization

6
Histogram Equalization

7
Histogram Equalization Example
Consider a 3 bit image of size 64x64 (4096) with intensity distribution shown in the
below table. Calculate the Equalized histogram.

rk nk P(rk) Sk Approximate Value Updated nk Updated


of Sk P(rk)
0 790 790/4096
1 1023
2 850
3 656
4 329
5 245
6 122
7 81

Sk = T(rk)
S = L-1x(Pk) = 7x0.19 = 1.33
Sk = L-1 8
Histogram Equalization Example
Consider a 3 bit image of size 64x64 with intensity distribution shown in the below
table. Calculate the Equalized histogram.
rk nk P(rk) Sk Approximate Value Updated nk Updated
of Sk P(rk)
0 790 0.19 1.33 1 790 790/4096
1 1023 0.25 3.08 3 1023
2 850 0.21 4.55 5 850
3 656 0.16 5.67 6 656+329 = 985
4 329 0.08 6.23 6
5 245 0.06 6.65 7 245+122+81= 448
6 122 0.03 6.86 7
7 81 0.02 7.00 7

Sk = T(rk)

Sk = L-1
9
Concept of Kernal or Filter or Convolution Mask

X1
W1
W1X1 + W2X2

W2
X2

Weights Inputs Weighted Summation


W1 W2 W3 X1 X2 X3 W1X1 W2X2 W3X3
W4 W5 W6 X X4 X5 X6 = W4X4 W5X5 W6X6
W7 W8 W9 X7 X8 X9 W7X7 W8X8 W9X9

10
Spatial Correlation and Convolution: Padding size (M-1)/2 or (N-1)/2
Input Image 0 0 0 0 0 0 0
0 0 0 0 0 Kernel
0 0 0 0 0 0 0
0 0 0 0 0 1 2 3 0 0 0 0 0 0 0
0 0 1 0 0 4 5 6 0 0 0 1 0 0 0
0 0 0 0 0 7 8 9 0 0 0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

Correlation Convolution
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 9 8 7 0 0 0 0 1 2 3 0 0
0 0 6 5 4 0 0 0 0 4 5 6 0 0
0 0 3 2 1 0 0 0 0 7 8 9 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 11
Smoothing Spatial Filters
Smoothing Spatial Filter

Linear filter Non-Linear Filter or order static filters

Median Filters
Box Car or Mean
Filter
Max Filter
Weighted Avg.
Filter
Min Filter

Gaussian Filters

12
Image Smoothening: Box Car Filter

A filter that computes the average of pixels in the neighborhood blurs an image. Computing an average is analogous to
integration.
Or

A filter that reduces the sharp transition in the intensity called as smoothening or low pass filtering.

Convolving a smoothening kernel with image result in image blurring and the amount of blurring is always depends on
the size of the kernel.
Kernal Normalized Kernal
1 1 1 0.11 0.11 0.11
1/9 x 1 1 1 = 0.11 0.11 0.11
1 1 1 0.11 0.11 0.11

1 1 1 1
1 1 1 1
1/16 x
1 1 1 1
1 1 1 1 13
Image Smoothening: Box Car Filter
Comparison of outputs between Normalized and Non-Normalized Kernel
Image Normalized Kernel
1 2 3 0.11 0.11 0.11
4 5 6 0.11 0.11 0.11 0.11+0.22+0.33+0.44+0.55+0.66+0.77+0.88+0.99 = 4.95
7 8 9 0.11 0.11 0.11

Not Normalized Kernal


1 2 3 1 1 1
4 5 6 1+2+3+4+5+6+7+8+9 = 45
1 1 1
7 8 9 1 1 1

14
Working Example: Padding size (M-1)/2 or (N-1)/2
Input Image
1 2 5 3 4 Kernel
5 6 7 8 9 0.11 0.11 0.11
2 3 4 5 6 0.11 0.11 0.11
3 6 8 4 2 0.11 0.11 0.11
1 5 6 8 7

Limitation of Box Car Filter


Output is Blurred.
Solution
Circularly Symmetric or isotropic kernel.

Weighted Average Filter

1 2 1
1/16 x 2 4 2
1 2 1
15
Image Smoothening: Gaussian
Filter

(x-1,y-1) (x-1,y) (x-1,y+1)


(x,y-1) p(x,y) (x+1,y+1)
(x+1,y-1) (x+1,y) (x+1,y+1)

16
Image Smoothening: Gaussian
Filter
Calculate the gaussian Kernel for 3x3 Kernel

(x-1,y-1) (x-1,y) (x-1,y+1) -1,-1 -1,0 -1,1


(x,y-1) p(x,y) (x,y+1) 0,-1 0,0 0,1
(x+1,y-1) (x+1,y) (x+1,y+1) 1,-1 1,0 1,1

Consider SD = 1

X=0,y=0 : SD =1 : 1/2pi =

17

You might also like