Digital Image Processing Part 2 Contrast processing.

20
Digital Image Processing Part 2 Contrast processing

description

Dark and Light Images

Transcript of Digital Image Processing Part 2 Contrast processing.

Page 1: Digital Image Processing Part 2 Contrast processing.

Digital Image Processing

Part 2Contrast processing

Page 2: Digital Image Processing Part 2 Contrast processing.

Brightness and Contrast

• Grey scale and histogram of pixel values

Page 3: Digital Image Processing Part 2 Contrast processing.

Dark and Light Images

Page 4: Digital Image Processing Part 2 Contrast processing.

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.

Good Contrast

• Almost full dynamic range used. Could contrast stretch slightly

Page 6: Digital Image Processing Part 2 Contrast processing.

Point process contrast

Page 7: Digital Image Processing Part 2 Contrast processing.

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.

Contrast stretch result

Page 9: Digital Image Processing Part 2 Contrast processing.

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.

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.

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.

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.

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.

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.

• 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.

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.

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.

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.

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.

• 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