Uploaded by Dylan Govender

DSPB 301 Theory NOTES 3

advertisement
DSPB 301 Digital Image Processing(Theory Notes 3)
Page |1
1. Arithmetic Operations Between Images
These are array operations which are carried out between corresponding pixel pairs. The operations
are as follows:
s( x, y)  f ( x, y)  g ( x, y)
d ( x, y)  f ( x, y)  g ( x, y)
𝑝(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) × 𝑔(𝑥, 𝑦)
𝑣(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) ÷ 𝑔(𝑥, 𝑦)
If the result is a floating-point number, round off the value.
If the result is above the pixel range (0-255), select the max range value.
If the result is infinity, write it as zero.
1.1 Addition of Images
A+B
0 100 10
10 100 5
10 200 15
[4
0
10] + [ 2
0
0]=[6
0
10]
8
0
5
0
10 10
8
10 15
Addition and averaging to remove noise
Image averaging
1.2 Subtraction of Images
A-B
0 100 10
10 100 5
0 0
[4
0
10] − [ 2
0
0 ] = [2 0
8
0
5
0
10 10
8 0
5
10]
0
The absolute minimum of a pixel is zero (black), a pixel cannot have a negative value.
Enhances the difference between images
Mask modes in medical radiography
1.3 Multiplication of Images
AxB
0 100 10
10 100 5
0 255 50
[4
0
10] ∗ [ 2
0
0 ] = [8
0
0]
8
0
5
0
10 10
0
0
50
The maximum value of a pixel is capped at 255.
Shading correction
Masking the Region of Interest (ROI)
DSPB 301 Digital Image Processing(Theory Notes 3)
1.4 Division of Images
A/B
0 100 10
0 1
10 100 5
[4
0
10] ÷ [ 2
0
0 ] = [2 0
8
0
5
0 0
0
10 10
2
0]
1
The final pixel division = 0.5, rounding – off =1
Shading Correction
Logic Operations on Images
1.5 AND Operation (Use the Truth Table)
A and B
1 1 0
0 1 0  0 1 0 
0 0 1 AND 1 1 0  0 0 0



 

1 0 1
0 0 1 0 0 1
1.6 OR Operation (Use the Truth Table)
A OR B
1 1 0 
0 1 0 1 1 0
0 0 1 OR 1 1 0  1 1 1



 

1 0 1
0 0 1 1 0 1
1.7 NOT Operation (Use the Truth Table)
Applying the NOT Operation to the Image
1 1 0   0 0 1 
 0 0 1   1 1 0 

 

1 0 1  0 1 0
Page |2
DSPB 301 Digital Image Processing(Theory Notes 3)
Page |3
2. Point Operations Between Images
A Method of image processing in which each pixel in the output image in which each in the output
image is only dependent on the corresponding pixel in the input image and is independent of its
location or neighbouring pixels.
2.1 Thresholding an Image
Consider the following Image
4
3

2

7
3 5 2
6 4 6
2 6 5

6 4 1
s  ( L  1)  r where
s  the resulting pixel value
r  the pixel value in the orginal image
( L  1)  the highest gray value in the input image
To find L, the highest pixel value is 7, so the highest power if the image is a 3 bit image is 2 3  8
Therefore,
L = 8, r=0 (min value)
L-1=8-1=7
Example: Perform Thresholding on the given Image if:
 L  1  7 ; r  4
s

r  4
 0
 r  0, 1, 2, 3  s  0 
r  4, 5, 6, 7  s  7


7
0

0

7
0 7 0
7 7 7 
= resulting threshold image
0 7 7

7 7 0
Graph
S
7=L-1
r
T=4
L-1=7
DSPB 301 Digital Image Processing(Theory Notes 3)
Page |4
2.2 Clipping an Image
Consider the following Image
4
3

2

7
3 5 2
6 4 6
2 6 5

6 4 1
s  ( L  1)  r where
s  the resulting pixel value
r  the pixel value in the orginal image
( L  1)  the highest gray value in the input image
To find L, the highest pixel value is 7, so the highest power if the image is a 3 bit image is 2 3  8
Therefore,
L = 8, r=0 (min value)
L-1=8-1=7
Example: Perform Clipping on the given Image if:
L  1  7 ;2  r  5 
s

otherwise
 0
 r  0, 1, 6, 7  s  0 
r  2, 3, 4, 5  s  7


7
7

7

0
7 7 7
0 7 0
= resulting Clipped image
7 0 7

0 7 0
Graph
S
L-1 =7
L-1 = 7
0
R
2
5
DSPB 301 Digital Image Processing(Theory Notes 3)
Page |5
3. Histogram Image Processing
The histogram of a monochrome image is a graphical representation of the frequency of
occurrence of each gray level in the image. The data structure that stores the frequency values
is a 1D array of numerical values, h, whose individual elements store the number (or
percentage) of image pixels that correspond to each possible gray level. Histograms can be
represented using a bar chart or graph, with one bar per gray level in which the height of the
bar is proportional to the number (or percentage) of pixels that corresponds to that particular
gray level.
Consider the two 4x4 gray scale images
(a)
(b)
Example: Sketch the Histogram for the images above
Graph
Mathematically
A normalized histogram is defined as:
Probability Distribution Function (PDF)= p(rk ) 
nk
where p ( rk ) is the probability (percentage) of
n
the kth gray level ( rk ) , n is the total number of pixels in the image and ( n k ) is the total number of
elements in the set.
Histogram Equalisation
Histogram Equalization (continued)
Is a technique by which the gray-level distribution of an image is changed to obtain a uniform
resulting histogram in which the percentage of pixels of every gray level is the same.
DSPB 301 Digital Image Processing(Theory Notes 3)
Page |6
Example 1: Perform Histogram Equalisation using the table shown, assume an 8x8 image
Gray Levels Intensity ( rk )
0
1
2
3
4
5
6
7
No. of Pixels ( n k )
9
8
11
4
10
15
4
3
Draw Histogram/Graph (x-axis gray = ( rk ) and levels and y-axis the number of pixels = ( n k ) )
Gray Levels
No. of Pixels
( rk )
(nk )
p(rk ) 
𝑠𝑘
nk
n
PDF
𝑠𝑘 𝑥7
Histogram
Equalisation
CDF
Sk x 7
0
9
0.141
0.141
0.987
1
1
8
0.125
0.266
1.862
2
2
11
0.172
0.438
3.066
3
3
4
0.0625
0.5005
3.5035
4
4
10
0.156
0.6565
4.5955
5
5
15
0.234
0.8905
6.2335
6
6
4
0.0625
0.953
6.671
7
7
3
0.047
1
7
7
n=64
PDF = Probability Distribution Function
9/64 = 0.141, 8/64=0.125, 11/64 = 0.172, ……….. 3/64 = 0.047
CDF =Cumulative Distributive Function
0.141 + 0.125 = 0.266
0.266 + 0.172 = 0.438
0.438 + 0.0625 = 0.5005
…….. = 1
𝑠𝑘 𝑥7
0.141 x 7 =0.987
0.266 x 7 =1.862
0.438 x 7 = 3.066
… , …, …,
Histogram Equalisation = round off
𝑠𝑘 𝑥7
DSPB 301 Digital Image Processing(Theory Notes 3)
Page |7
Draw the final histogram of the output image
New Gray Levels Intensity of
1
2
3
4
9
8
11 4
5
6
7
10
15
7
OUTPUT image (Column 6)
No. of Pixels ( n k ) (Column 2)
Example 2: Perform Histogram Equalisation for the following image (5x5)
1
2
f ( x, y )  2
2
1
2
5
5
5
1
1
3
5
3
1
1
5
5
5
2
1
2
2
2
1
max value = 5
STEP 1:
2 0  1, 21  2, 2 2  4, 2 3  8 , 5 is less than 8, therefore L=8 and L-1=7
Gray Levels Intensity (x axis)
0
1
2
3
4
5
6
7
No. of Pixels ( n k ) (y axis)
0
8
8
2
0
7
0
0
STEP 2: INPUT IMAGE
Draw Histogram/Graph (x-axis gray = ( rk ) and levels and y-axis the number of pixels = ( n k ) )
DSPB 301 Digital Image Processing(Theory Notes 3)
Page |8
STEP 3: Complete the tables
Gray Levels
No. of Pixels
( rk )
(nk )
p(rk ) 
𝑠𝑘
nk
n
𝑠𝑘 𝑥7
Histogram
Equalisation
PDF
CDF
0
0
0
0
0
0
1
8
0.32
0.32
2.24
2
2
8
0.32
0.64
4.48
4
3
2
0.08
0.72
5.04
5
4
0
0
0.72
5.04
5
5
7
0.28
1
7
7
6
0
0
1
7
7
7
0
0
1
7
7
n=25
Gray Levels Intensity (x axis)
0
2
4
5
0
8
8
2
5
7
New Image
No. of Pixels ( n k ) (y axis)
STEP 4: Draw New Histogram
STEP 5: Show Image Mapping
1
2
f ( x, y )  2
2
1
2
5
5
5
1
1
3
5
3
1
1
5
5
5
2
1
2 4
2
4 7
2  4 7
2
4 7
1
2 2
2
5
7
5
2
2
7
7
7
4
2
4
4
4
2
7
7
7
Download