Digital Image Processing Part 2 Contrast processing.
Post on 18-Jan-2018
217 Views
Preview:
DESCRIPTION
Transcript
Digital Image Processing
Part 2Contrast processing
Brightness and Contrast
• Grey scale and histogram of pixel values
Dark and Light Images
Low Contrast
To lighten or darken, shift the distribution left or right
To increase contrast, stretch the distribution over a wider range
Good Contrast
• Almost full dynamic range used. Could contrast stretch slightly
Point process contrast
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
Contrast stretch result
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
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
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
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
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
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
• 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
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
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)
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
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
• 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
top related