Engineering presentation
Digital Image Processing
EEE415
Lecture 4
Image Enhancement in Spatial Domain
Histogram: The histogram concisely displays the brightness distribution of an image, I.e. the number of pixels with a certain brightness. The histogram shows the likelihood of finding a pixel with a certain grey level.
Pixel Operations: Histogram Processing
The Histogram
The Histogram
The histogram contains no information about the spatial distribution of the pixels within the image.
The Histogram
Low contrast image.
High contrast image.
The Histogram
Well balanced contrast image.
A well balanced contrast image will make optimum use of the available brightness gray-scale.
The total sum of all pixels in the histogram equals the number of pixels in the digital image.
Pixel Operations: Histogram Processing
Histogram sliding adds or subtracts a constant offset brightness to each pixel intensity. Example:
Pixel Operations: Histogram Processing
The resultant image has the same contrast as before. The pixel brightness range has simply been relocated within the available grey level gray-scale.
Pixel Operations: Histogram Processing
Histogram stretching multiplies each pixel brightness with a constant gain factor. This increases (decreases) contrast for gain factors greater than one (< 1).
Example:
I(x,y) > 65, O(x,y) = 255
0 < I(x,y) <= 65, O(x,y) = 3.9 * I(x,y)
If I(x,y) = 0 then O(x,y) = 0
If I(x,y) = 65 then O(x,y) = 3.9*65 = 253.5
Non-integer pixel values must be rounded to the nearest integer.
Pixel Operations: Histogram Processing
The resultant digital image fully utilises the available grey-scale. The image has good contrast revealing important detail. The image is pleasing to the human eye.
Pixel Operations: Histogram Processing
Linear contrast stretching is a combination of histogram sliding and stretching.
Assume the darkest and brightness input image grey values are rmin and rmax and the desired darkest and brightest output grey levels are 0 and L then the formula for a linear contrast stretch is:
Usually, contrast stretching is done to occupy the maximum available grey level dynamic range (e.g. min=0, max=255)
*
*
An example:
O_max = 255, O_min = 0, I_max = 195, I_min = 130.
O(x,y) = (I(x,y) – 130) * (255/65).
Pixel Operations: Histogram Processing
rmin
rmax
0
L-1
Pixel Operations: Histogram Processing
Binary contrast enhancement, or thresholding, is an extreme example of contrast stretching. All grey levels below (above) a selected threshold are set to black (white).
This is commonly used to refresh old, faded or (water) damaged documents.
Pixel Operations: Histogram Processing
In adaptive thresholding, the threshold value varies across the image. This is not strictly pixel point processing.
Pixel Operations: Histogram Processing
Brightness slicing does a double binary contrast enhancement. This is used to highlight features within a chosen grey level range, e.g. enhanced sea-land boundary.
Pixel Point Processing
Histogram equalisation rearranges the pixel grey levels in order to achieve an equal density distribution.
This rearrangement process is different for every digital image.
This can enhance detail. The full grey level dynamic range is exploited.
*
*
Equal density distribution = equal area (intensity x number of pixels) on histogram.
Pixel Point Processing
Histogram equalisation can reveal detail otherwise invisible.
*
*
Equal density distribution = equal area (intensity x number of pixels) on histogram.
*
*
Histogram equalization
- Idea: To find a non-linear transformation
Y = T (x)
to be applied to each pixel of the input image f(x,y), such that a uniform distribution of gray levels in the entire range results for the output image g(x,y).
- Assuming ideal, continuous case, with normalized histograms
- that
- T(x) is single valued i.e., there exists x= T-1(y)
- T(x) is monotonically increasing
- Monotonic functions are functions that tend to move in only one direction as x increases
*
*
Histogram equalization
Example of a transformation function which is both single valued and monotonically increasing
A function T(x) is monotonically increasing
if T(r1) < T(r2) for r1 < r2,
and monotonically decreasing
if T(r1) > T(r2) for r1 < r2.
Implementation
- Consider a grayscale image, and let ni be the number of occurrences of gray level i. The probability of an occurrence of a pixel of level i in the image is
- L being the total number of gray levels in the image, n being the total number of pixels in the image, and p being in fact the image's histogram, normalized to 0..1.
Implementation
- Let us also define c as the cumulative distribution function corresponding to p, defined by:
- c is the image's accumulated normalized histogram.
Implementation
- We would like to create a transformation of the form that will produce a level y for each level x in the original image, such that the cumulative probability function of y will be linearized across the value range. The transformation is defined by:
- Notice that the T maps the levels into the domain of 0..1. In order to map the values back into their original domain, the following simple transformation needs to be applied on the result:
- Build a lookup table
- Image Mapping
*
*
Histogram equalization examples
Input image
Output image
Input histogram and cdf
Output histogram and cdf
*
*
Histogram equalization examples
Low contrast image
high contrast image
Output image
Output image
Equalized histogram
Equalized histogram
49.psd
50.psd
*
*
Histogram equalization examples
Output image
Output image
Dark input image
Bright input image
Equalized histogram
Equalized histogram
51.psd
52.psd
*
*
Histogram equalization examples
Transformation functions for histogram equalization
*
*
Histogram equalization examples
Histogram Mapping and Gamma function (recap)
Brighten image
Linear mapping
Darken image
Histogram Equalization
- Not actually changed the distribution
- For digital image, histogram equalization stretches the histogram to wider range
- Enhance the contrast of an image in some cases
- Possibly change the look of the image
Histogram specification/matching
Histogram equalization method:
- Only generates one result: an image with approximately uniform histogram (without any flexibility)
- Enhancement may not be achieved as desired
Histogram specification:
Transform an image according to a specified gray-level histogram
Includes
- Specify particular histogram shapes (pz(z)) capable of highlighting certain gray-level ranges
- Obtain the transformation function for transformation of r to z
Histogram specification/matching
Method (continuous case)
Notation:
r : gray level of input image (pdf: pr(r))
z : gray level of desired output image (pdf: pz(z))
s & v represent gray levels of histogram-equalized images hence
To obtain the transformed gray levels, we can apply:
Histogram specification/matching
Procedure of applying histogram specification
- Obtain transformation function T(r): integral of pr(r)
- Obtain transformation function G(z): integral of pz(z)
- Obtain the inverse function G-1(·)
- Finally, output image: z = G-1(T(r))
Modification for discrete case
Histogram specification/matching
Histogram matching example
Image of Mars
Histogram
Histogram matching example(continued)
Transformation Function
Histogram Equalized Image
Histogram of New Image
Histogram matching example(continued)
Specified Histogram
Histogram of Image
Enhanced Image using Mappings from Curve (2)
Transfer function and inverse transfer function
Local histogram processing
The histogram processing methods mentioned up to now are global transformation where:
Function is designed according to the gray-level
distribution over an entire image
Global transformation methods may not be suitable for enhancing details over small areas
(where number of pixels may have negligible influence on designing the global transformation function)
Local histogram processing
Implementation steps
1: Define a square or rectangular neighborhood (block), compute the histogram in the local block by designing the transformation functions based on the local gray-level distribution
2: Utilize the histogram equalization or specification method to generate the transformation function, perform the gray level mapping for each pixel in the block
3: Move the center of the block to an adjacent pixel location and repeat the procedure
Note
- The local histogram can be updated each time without re-computing the histogram over all pixels in the new block (since the block only shifts one pixel each time)
- If utilizing non-overlapping region shift, the processed image usually has an undesirable checkerboard effect
Local histogram equalization example
Original Image
Result of Global Histogram Equalization
Result of local Histogram Equalization
Local histogram equalization example
Original Image
Result of local Histogram Equalization using 9x9 window
Assignment-2
Apply following processes to given image:
Histogram,
Cumulative Histogram,
Cumulative Distribution Function (CDF), and
Output in Histogram Equalization
Due Date 25/10/2010
Assignment-2
Assignment-3
For what type of images Histogram Equalization gives good results? Write a one page report
Due Date 1/10/2012
Quiz-3 18/10/2010
Draw histogram plot for the image: 3 1 0 1
1 2 0 0
0 0 3 3
1 1 2 1
(
)
÷
÷
ø
ö
ç
ç
è
æ
-
-
=
=
min
max
min
)
(
r
r
L
r
r
r
T
s
1
0
1
0
£
£
£
£
s
and
r
ò
=
=
®
r
r
d
p
r
T
s
r
0
)
(
)
(
w
w
ò
=
=
®
z
z
dt
t
p
z
G
v
z
0
)
(
)
(
z
s
»
)]
(
[
)
(
1
1
r
T
G
s
G
z
-
-
=
=
.
1
,.....,
2
,
1
,
0
,
)
(
)
(
0
-
=
=
=
=
å
=
L
k
s
z
p
z
G
v
k
k
i
i
z
k
k
.
1
,.....,
2
,
1
,
0
,
)
(
)
(
0
0
-
=
=
=
=
å
å
=
=
L
k
n
n
r
p
r
T
s
k
j
j
k
j
j
r
k
k
.
1
,.....,
2
,
1
,
0
)],
(
[
)
(
1
1
-
=
=
=
-
-
L
k
r
T
G
s
G
z
k
k
k