digital image processing part 2 contrast processing
DESCRIPTION
Dark and Light ImagesTRANSCRIPT
![Page 1: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/1.jpg)
Digital Image Processing
Part 2Contrast processing
![Page 2: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/2.jpg)
Brightness and Contrast
• Grey scale and histogram of pixel values
![Page 3: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/3.jpg)
Dark and Light Images
![Page 4: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/4.jpg)
Low Contrast
To lighten or darken, shift the distribution left or right
To increase contrast, stretch the distribution over a wider range
![Page 5: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/5.jpg)
Good Contrast
• Almost full dynamic range used. Could contrast stretch slightly
![Page 6: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/6.jpg)
Point process contrast
![Page 7: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/7.jpg)
Contrast stretch
• Histogram towards right so bright
• Width narrow so low contrast
( , ) ( , )
Where = gradient and = lower limit, for all 0 <= x < image width and 0 <= y < image height
255( , ) ( , ) 100200 100
( , ) 2.55 ( , ) 100
So all pixels at 100 or less a
new
new
new
P x y m p x y l
m l
P x y p x y
P x y p x y
re set to 0, all at 200 or more are set to 255All pixels in between are evenly distributed across the range 0 to 255
![Page 8: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/8.jpg)
Contrast stretch result
![Page 9: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/9.jpg)
Contrast stretch limitations
• Subjective so needs human judgment• Best enhancement not always linear• May need to do brightness shift first• Sometimes need an automated method• Can be slow if each point is calculated so
use look-up table to speed-up processing
![Page 10: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/10.jpg)
Histogram equalisation
• Simple image with up to 10 brightness levels• Plot histogram
5 6 4 4 56 6 5 6 74 7 5 4 55 4 4 4 63 6 5 5 35 4 5 6 5
Pixel Level Histogram
0
2
4
6
8
10
12
Grey Levels
Pixe
l Int
ensi
ty
Freq
Freq 0 0 0 2 8 11 7 2 0 0
0 1 2 3 4 5 6 7 8 9
![Page 11: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/11.jpg)
Process• Determine the frequency of each pixel level
– i.e. distribution as on histogram• Determine the cumulative frequency
– How many pixels at level n plus all previous levels
• Determine new mapping function• Map old values to new values using the
new mapping function
![Page 12: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/12.jpg)
Mapping function
( ) ( )( )
th( )
( )
( )
max 0, 1
is the new g grey level
is the number of possible grey levels
the number of old grey levels at g or less (cumulative frequency)
is the to
g gg
g
g
g
N tF round
R C
F
N
t
R C
tal number of pixels Rows x Cols
![Page 13: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/13.jpg)
Worked ExampleLevel Freq
0 0
1 0
2 0
3 2
4 8
5 11
6 7
7 2
8 0
9 0
• Count the number of pixels at each level and create a frequency column
![Page 14: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/14.jpg)
Level Freq Cum Freq
0 0 0
1 0 0
2 0 0
3 2 2
4 8 10
5 11 21
6 7 28
7 2 30
8 0 30
9 0 30
• Cumulative frequency is the sum of the pixels at the current level and all previous levels
![Page 15: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/15.jpg)
• Use formula to create new mapping function
Level FreqCum Freq F(g)
0 0 0 0
1 0 0 0
2 0 0 0
3 2 2 0
4 8 10 2
5 11 21 6
6 7 28 8
7 2 30 9
8 0 30 9
9 0 30 9
![Page 16: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/16.jpg)
New Mapping FunctionF(g) mapping function
0
1
2
3
4
5
6
7
8
9
Old Pixel Values
New
Pix
el V
alue
s
F(g) 0 0 0 0 2 6 8 9 9 9
0 1 2 3 4 5 6 7 8 9
![Page 17: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/17.jpg)
New Pixel Levels
Level Freq CFrq F(g) New
0 0 0 0 2
1 0 0 0 0
2 0 0 0 8
3 2 2 0 0
4 8 10 2 0
5 11 21 6 0
6 7 28 8 11
7 2 30 9 0
8 0 30 9 7
9 0 30 9 2
• Old levels (Level) are converted to new levels (F(g))
• New histogram plotted from new distribution (New)
![Page 18: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/18.jpg)
Histogram comparisonPixel Level Histogram
0
2
4
6
8
10
12
Grey Levels
Pixe
l Int
ensi
ty
Freq
Freq 0 0 0 2 8 11 7 2 0 0
0 1 2 3 4 5 6 7 8 9
Equalised histogram
0
2
4
6
8
10
12
Grey Levels
Pixe
l Int
ensi
ty
New Levels
New Levels 2 0 8 0 0 0 11 0 7 2
0 1 2 3 4 5 6 7 8 9
![Page 19: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/19.jpg)
New Picture
6 8 2 2 68 8 6 8 92 9 6 2 66 2 2 2 80 8 6 6 06 2 6 8 6
Equalised histogram
0
2
4
6
8
10
12
Grey Levels
Pixe
l Int
ensi
ty
New Levels
New Levels 2 0 8 0 0 0 11 0 7 2
0 1 2 3 4 5 6 7 8 9
![Page 20: Digital Image Processing Part 2 Contrast processing](https://reader033.vdocument.in/reader033/viewer/2022052606/5a4d1b3c7f8b9ab05999f26e/html5/thumbnails/20.jpg)
• Does not need human intervention so can be used in systems which need automatic image enhancement
• Sometimes it makes a good job but not always– It will improve contrast for imaging systems but may
not always produce an image which is pleasing to the eye
Advantages and Disadvantages