Digital Image Processing Intensity Transformations Histogram Processing Christophoros

  • Slides: 47
Download presentation
Digital Image Processing Intensity Transformations (Histogram Processing) Christophoros Nikou cnikou@cs. uoi. gr University of

Digital Image Processing Intensity Transformations (Histogram Processing) Christophoros Nikou cnikou@cs. uoi. gr University of Ioannina - Department of Computer Science

Contents 2 Over the next few lectures we will look at image enhancement techniques

Contents 2 Over the next few lectures we will look at image enhancement techniques working in the spatial domain: – Histogram processing – Spatial filtering – Neighbourhood operations C. Nikou – Digital Image Processing (E 12)

Image Histograms 3 Frequencies The histogram of an image shows us the distribution of

Image Histograms 3 Frequencies The histogram of an image shows us the distribution of grey levels in the image Massively useful in image processing, especially in segmentation Grey Levels C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 4 Histogram Examples C.

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 4 Histogram Examples C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 5

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 5 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 6

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 6 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 7

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 7 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 8

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 8 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 9

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 9 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 10

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 10 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 11

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 11 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 12

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 12 C. Nikou – Digital Image Processing (E 12)

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 13

Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 13 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 14 Histogram Examples (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 14 Histogram Examples (cont…) • A selection of images and their histograms • Notice the relationships between the images and their histograms • Note that the high contrast image has the most evenly spaced histogram C. Nikou – Digital Image Processing (E 12)

15 Contrast Stretching • We can fix images that have poor contrast by applying

15 Contrast Stretching • We can fix images that have poor contrast by applying a pretty simple contrast specification • The interesting part is how do we decide on this transformation function? C. Nikou – Digital Image Processing (E 12)

16 Histogram Equalisation • Spreading out the frequencies in an image (or equalising the

16 Histogram Equalisation • Spreading out the frequencies in an image (or equalising the image) is a simple way to improve dark or washed out images. • At first, the continuous case will be studied: – r is the intensity of the image in [0, L-1]. – we focus on transformations s=T(r): • T(r) is strictly monotonically increasing. • T(r) must satisfy: C. Nikou – Digital Image Processing (E 12)

17 Histogram Equalisation (cont. . . ) • The condition for T(r) to be

17 Histogram Equalisation (cont. . . ) • The condition for T(r) to be monotonically increasing guarantees that ordering of the output intensity values will follow the ordering of the input intensity values (avoids reversal of intensities). • If T(r) is strictly monotonically increasing then the mapping from s back to r will be 1 -1. • The secondition (T(r) in [0, 1]) guarantees that the range of the output will be the same as the range of the input. C. Nikou – Digital Image Processing (E 12)

18 Histogram Equalisation (cont. . . ) a) We cannot perform inverse mapping (from

18 Histogram Equalisation (cont. . . ) a) We cannot perform inverse mapping (from s to r). b) Inverse mapping is possible. C. Nikou – Digital Image Processing (E 12)

19 Histogram Equalisation (cont. . . ) • We can view intensities r and

19 Histogram Equalisation (cont. . . ) • We can view intensities r and s as random variables and their histograms as probability density functions (pdf) pr(r) and ps(s). • Fundamental result from probability theory: – If pr(r) and T(r) are known and T(r) is continuous and differentiable, then C. Nikou – Digital Image Processing (E 12)

20 Histogram Equalisation (cont. . . ) • The pdf of the output is

20 Histogram Equalisation (cont. . . ) • The pdf of the output is determined by the pdf of the input and the transformation. • This means that we can determine the histogram of the output image. • A transformation of particular importance in image processing is the cumulative distribution function (CDF) of a random variable: C. Nikou – Digital Image Processing (E 12)

21 Histogram Equalisation (cont. . . ) • It satisfies the first condition as

21 Histogram Equalisation (cont. . . ) • It satisfies the first condition as the area under the curve increases as r increases. • It satisfies the secondition as for r=L-1 we have s=L-1. • To find ps(s) we have to compute C. Nikou – Digital Image Processing (E 12)

22 Histogram Equalisation (cont. . . ) Substituting this result: to Uniform pdf yields

22 Histogram Equalisation (cont. . . ) Substituting this result: to Uniform pdf yields C. Nikou – Digital Image Processing (E 12)

23 Histogram Equalisation (cont. . . ) The formula for histogram equalisation in the

23 Histogram Equalisation (cont. . . ) The formula for histogram equalisation in the discrete case is given where • rk: input intensity • sk: processed intensity • nj: the frequency of intensity j • MN: the number of image pixels. C. Nikou – Digital Image Processing (E 12)

24 Histogram Equalisation (cont. . . ) Example A 3 -bit 64 x 64

24 Histogram Equalisation (cont. . . ) Example A 3 -bit 64 x 64 image has the following intensities: Applying histogram equalization: C. Nikou – Digital Image Processing (E 12)

25 Histogram Equalisation (cont. . . ) Example Rounding to the nearest integer: C.

25 Histogram Equalisation (cont. . . ) Example Rounding to the nearest integer: C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 26 Histogram Equalization (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 26 Histogram Equalization (cont…) Example Notice that due to discretization, the resulting histogram will rarely be perfectly flat. However, it will be extended. C. Nikou – Digital Image Processing (E 12)

Equalisation Transformation Function Images taken from Gonzalez & Woods, Digital Image Processing (2002) 27

Equalisation Transformation Function Images taken from Gonzalez & Woods, Digital Image Processing (2002) 27 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 28 Equalisation Examples 1

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 28 Equalisation Examples 1 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 29 Equalisation Transformation Functions

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 29 Equalisation Transformation Functions The functions used to equalise the images in the previous example C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 30 Equalisation Examples 2

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 30 Equalisation Examples 2 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 31 Equalisation Transformation Functions

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 31 Equalisation Transformation Functions The functions used to equalise the images in the previous example C. Nikou – Digital Image Processing (E 12)

Equalisation Examples (cont…) 3 Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Equalisation Examples (cont…) 3 Images taken from Gonzalez & Woods, Digital Image Processing (2002) 32 4 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 33 Equalisation Transformation Functions

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 33 Equalisation Transformation Functions The functions used to equalise the images in the previous examples C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 34 Histogram Specification •

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 34 Histogram Specification • Histogram equalization does not always provide the desirable results. • Image of Phobos (Mars moon) and its histogram. • Many values near zero in the initial histogram C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 35 Histogram Specification (cont.

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 35 Histogram Specification (cont. . . ) Histogram equalization C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 36 Histogram specification (cont.

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 36 Histogram specification (cont. ) • In these cases, it is more useful to specify the final histogram. • Problem statement: – Given pr(r) from the image and the target histogram pz(z), estimate the transformation z=T(r). • The solution exploits histogram equalization. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 37 Histogram specification (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 37 Histogram specification (cont…) • Equalize the initial histogram of the image: • Equalize the target histogram: • Obtain the inverse transform: In practice, for every value of r in the image: • get its equalized transformation s=T(r). • perform the inverse mapping z=G-1(s), where s=G(z) is the equalized target histogram. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 38 Histogram specification (cont…)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 38 Histogram specification (cont…) The discrete case: • Equalize the initial histogram of the image: • Equalize the target histogram: • Obtain the inverse transform: C. Nikou – Digital Image Processing (E 12)

Histogram Specification (cont. . . ) Example 39 Consider again the 3 -bit 64

Histogram Specification (cont. . . ) Example 39 Consider again the 3 -bit 64 x 64 image: It is desired to transform this histogram to: with C. Nikou – Digital Image Processing (E 12)

40 Histogram Specification (cont. . . ) Example The first step is to equalize

40 Histogram Specification (cont. . . ) Example The first step is to equalize the input (as before): The next step is to equalize the output: Notice that G(z) is not strictly monotonic. We must resolve this ambiguity by choosing, e. g. the smallest value for the inverse mapping. C. Nikou – Digital Image Processing (E 12)

41 Histogram Specification (cont. . . ) Example Perform inverse mapping: find the smallest

41 Histogram Specification (cont. . . ) Example Perform inverse mapping: find the smallest value of zq that is closest to sk: e. g. every pixel with value s 0=1 in the histogramequalized image would have a value of 3 (z 3) in the histogram-specified image. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 42 Histogram Specification (cont.

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 42 Histogram Specification (cont. . . ) Example Notice that due to discretization, the resulting histogram will rarely be exactly the same as the desired histogram. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 43 Histogram Specification (cont.

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 43 Histogram Specification (cont. . . ) Original image Histogram equalization C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 44 Histogram Specification (cont.

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 44 Histogram Specification (cont. . . ) Histogram equalization C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 45 Histogram Specification (cont.

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 45 Histogram Specification (cont. . . ) Specified histogram Transformation function and its inverse Resulting histogram C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 46 Local Histogram Processing

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 46 Local Histogram Processing • Image in (a) is slightly noisy but the noise is imperceptible. • HE enhances the noise in smooth regions (b). • Local HE reveals structures having values close to the values of the squares and small sizes to influence HE (c). C. Nikou – Digital Image Processing (E 12)

Summary 47 We have looked at: – Different kinds of image enhancement – Histograms

Summary 47 We have looked at: – Different kinds of image enhancement – Histograms – Histogram equalisation – Histogram specification Next time we will start to look at spatial filtering and neighbourhood operations C. Nikou – Digital Image Processing (E 12)