- Dr. Iyad Jafar
Digital Image Analysis and Processing CPE 0907544 Image Enhancement - - PowerPoint PPT Presentation
Digital Image Analysis and Processing CPE 0907544 Image Enhancement - - PowerPoint PPT Presentation
Digital Image Analysis and Processing CPE 0907544 Image Enhancement Part I Intensity Transformation Chapter 3 Sections: 3.1 3.3 Dr. Iyad Jafar Outline What is Image Enhancement ? Background Intensity Transformation
Outline
What is Image Enhancement ? Background Intensity Transformation Functions
Negatives Log and Inverse Log Power-Law Piecewise Transformation Graylevel and Bit Slicing
Histogram Processing
Equalization Specification Local Processing
2
What is Image Enhancement?
The purpose of image enhancement is to process an
image such that it is more suitable than the original image for a specific application
The word specific is important, because algorithms
developed for some images may not work for others
There is no general theory for enhancement and the
evaluation of its outcome is highly subjective
Enhancement can be performed in
Spatial domain: direct operation on the pixel values Frequency
domain: modify the image frequency components (Ch. 4)
3
Background
Spatial domain of the image is the set of
pixels composing the image
Enhancement in the spatial domain involves direct
- peration on the pixel intensities
This can be expressed mathematically as
g(x,y) = T[f(x,y)]
f(x,y) is the input image g(x,y) is the output image T[ ] is an operator defined over some neighborhood of (x,y)
Important Keep in mind that g(x,y) may take any value from the set of available gray levels only. Thus, when mapping we should assign the mapped value to the closest level
4
Background
Defining the neighborhood around (x,y)
Use a square/rectangular subimage that is centered at (x,y)
Operation
Move the center of the subimage from pixel to pixel and apply the
- peratorT at each location (x,y) to compute the output g(x,y)
5
Background
The simplest form of the operator T is when the
neighborhood size is 1x1 pixel.
Accordingly, g(x,y) is only dependent on the value of f
at (x,y)
In this case, T is called the gray-level or intensity
transformation function that can be represented as s = T(r)
s is a variable denoting g(x,y) r is a variable denoting f(x,y)
This is kind of processing is referred as point
processing
6
Background
Intensity transformation function examples
7
T(r) performs contrast stretching by mapping levels less than k to narrow range while those above k are mapped to wider range T(r) reduces the number of levels in the image to two
Point Processing Example Thresholding
Thresholding transformations are particularly useful
for segmentation in which we want to isolate an
- bject of interest from a background
s = 1.0 0.0 r <= threshold r > threshold
8
Basic Gray Level Transformations
Mapping
can be performed by mathematical substitution or lookup tables
Some common functions are
Linear (negative/identity) Logarithmic (log/inverse log) Power law (nth power/nth root)
9
Basic Gray Level Transformations
Image Negatives
Can be performed by using
s = L – 1 – r
where L-1 is the maximum intensity value
10
Basic Gray Level Transformations
Log and inverse Log Transformations
The general form of the log transformation b is the base Maps narrow range of low intensity levels to wider range
and wide range of high intensity levels to narrower range
Usually used to expand the values of dark pixels and
compress the higher level values
The general form of the inverse log Its operation is the opposite of the log transformation
11
b
s = clog (1+r) 1
cr
s = b
Basic Gray Level Transformations
Log Transformation Example
It is very important in mapping wide dynamic ranges into
narrow ones
Fourier spectrum values in the range [0,1.5x106] transformed
to [0,255] using log transformation
12
s = log(1 + r)
Basic Gray Level Transformations
Inverse Log Transformation Example
13
ecr -1
Basic Gray Level Transformations
Power-Law transformations
The general form
Power law is similar to log
when gamma < 1 and similar to inverse log when gamma > 1
14
γ
s = cr
Basic Gray Level Transformations
Power-Law transformations
Gamma-correction
Display devices have intensity-to-voltage response that is a power functions. Thus, images tend to be darker when displayed.
Correction is needed using nth root before feeding the image to the monitor
15
Basic Gray Level Transformations
Power-Law Transformation
The images to the
right shows a magnetic resonance (MR) image of a fractured human spine
Different curves
highlight different detail
s = r 0.6 s = r 0.4 s = r 0.3
16
Piecewise-Linear Transformations
Can represent arbitrarily complex functions to achieve
different results
Contrast stretching
r1 ≤ r2 and s1 ≤ s2
to preserve the order
- f gray levels
The result depends
- n the values of r1, r2,
s1, and s2
17
Piecewise-Linear Transformations
Gray-level Slicing
Used to highlight specific range of gray levels Two approaches
18
Piecewise-Linear Transformations
Bit-plane Slicing
Highlight
the contribution
- f
specific bits to the appearance of the image
Each pixel value is represented by a set of bits Lower bits correspond to fine details while higher bits
correspond to the global visual content
Useful in image compression !
19
Piecewise-Linear Transformations
Bit-plane Slicing - example
20 Plane 0 Plane 1 Plane 2 Plane 3 Plane 4 Plane 5 Plane 6 Plane 7
Bit-plane Slicing - example
Piecewise-Linear Transformations
21 Planes 7 & 6 Planes 7,6,5 Planes 7,6,5,4
Bit-plane Slicing - example
Piecewise-Linear Transformations
22 Plane 7 Plane 6 Plane 5 Plane 4 Plane 3 Plane 2 Plane 1 Plane 0
Histogram Processing
For an image with gray levels in [0,L-1] and MxN
pixels, the histogram is a discrete function given by where rk is the kth intensity value and nk is the number
- f pixels in the image with intensity rk
It is a common practice to normalize the histogram
function by the number of pixels in the image by
The normalized histogram can be used as an estimate
- f the probability density function of the image
Histograms are widely used in image processing:
enhancement, compression, segmentation …
23
k k
h( r ) n
k k
n p( r ) MN
Histogram Processing
For enhancement, histograms can be used to infer the
type of image quality: dark, bright, low or high contrast
24 Dark Image Bright Image Low Contrast High Contrast
Histogram Equalization
It is quite acceptable that high contrast images have
flat histograms (uniform distribution)
Histogram equalization attempts to transform the
- riginal histogram into a flat one for the goal of better
contrast
In the following, we derive the transformation function
that achieves this task
25
Histogram Equalization
Let r be a continuous variable that represents the
intensity values in the range [0,L-1]
A valid transformation function for enhancement
purposes s = T(r) should satisfy
T(r) is monotonically increasing in the interval 0 ≤ r ≤
L-1
T(r) is bounded by [0,L-1] for all values of r
The inverse transformation function that maps s back
to r requires that T(r) to be strictly monotonically increasing
26
1
r T ( s )
Histogram Equalization
Examples of transformation functions
Monotonically Increasing Strictly monotonically increasing
27
Histogram Equalization
Consider the gray level intensity represented by r as a
random variable in the interval [0,L-1]
We can use the normalized histogram pr(r) as the
probability density function for r
If a transformation function s = T(r) is used to map
the pixels into s in the range [0,L-1], then the following relation holds where ps(s) is the normalized histogram of the output image
28
1 s r r T ( s )
dr p ( s ) p ( r ) ds
Histogram Equalization
Now, if we know that the output image has a flat
histogram, i.e. we can substitute in the equation in the previous slide and solve for s by integrating both sides
This gives the desired transformation function s=T(r) that
performs histogram equalization
For digital images, the transformation function is simply
29
1 1
s
p ( s ) , s [0,L-1] L 1
r r
s T( r ) ( L ) p ( w )dw
r r k k k r w w w w
(L-1) s T( r ) (L-1) p ( r ) n MN
Histogram Equalization
The function given before maps the image histogram
into a flat histogram regardless of its original shape
Example 3.1:
consider an image with intensity distribution given by show that applying the histogram equalization function transforms this histogram into a flat one.
30
2
2 1
r
r p ( r ) , r [0,L-1] ( L )
Histogram Equalization
Example 3.1:
31 2
2 1
r
r p ( r ) , r [0,L-1] ( L )
1 s r r T ( s )
dr p ( s ) p ( r ) ds
Histogram Equalization
Example 3.2. A 10x10 3-bit image has the following
intensity counts. Determine the histogram of the image after applying histogram equalization.
32
r r k k k r w w w w
(L-1) s T( r ) (L-1) p ( r ) n MN
rk 1 2 3 4 5 6 7 h(rk) 10 20 20 35 10 5 p(rk) 0.1 0.2 0.2 0.35 0.1 0.05 ∑p(rk) 0.1 0.3 0.5 0.85 0.95 1.0 1.0 1.0 T(rk) 0.7 2.1 3.5 5.95 6.65 7 7 7 s 1 2 4 6 7 7 7 7
Histogram Equalization
Example 3.3
33 Original Equalized Output Histogram Transformation for the processed images 1 2 3 4
r s
Histogram Equalization
Notes
The number of output levels in the equalized image is
usually less than the original image due to the finite number of available levels
Histogram equalization always produces an image whose
mean intensity value is in the middle
- f
[0,L-1], irrespective of the original mean. This might not be acceptable in some situations
If the inverse mapping for histogram equalization is
needed, it is required that there are no empty bins in the
- riginal histogram
34
Histogram Equalization
The Constrained
Variational Histogram Equalization (CVHE)
Performs equalization under the constraint that the
- utput image mean is as close as possible to the original
mean
35 Original CVHE Image HE Image
Histogram Specification
Histogram equalization might not be useful in all
cases
Another
approach is to specify the desired histogram of the output image (based on some knowledge) and then perform the transformation
We can use the method used in deriving the
transformation function of histogram equalization to find transformation function for the desired histogram, however
This requires the availability of ps(s) in mathematical
form and the ability to express s in terms of r
Example !
36
Histogram Specification
Alternatively
Let pr(r) and pz(z) denote the original and desired
histograms and assume that there exist two transformation functions This implies that we can find the mapping from r to z by knowing the inverse of G(z)
This is a simple operation if G-1(s) can be obtained !!!!
37
s T( r ) and s = G(z)
1 1
z G ( s ) G (T( r ))
rk sk r T(r) zq sq z G(z) sk = sq G-1(s)
Histogram Specification
In discrete images, the situation is simpler since we
- nly have finite set of values, i.e. for each sq we know
the corresponding zq
The algorithm
Compute sk = T(rk) using Compute sq = G(zq) using For each rk find zq such that minimizes
for all i in [0,L-1].
38
zk q q z j j
s G( z ) (L-1) p ( z )
rk k k r i i
s T( r ) = (L-1) p ( r )
k i
T( r ) G( z )
Illustration
Histogram Specification
39
rk sk r T(r) zq z G(z) Which value in G(zq) is closer to sk ? From G(z), we know which zq maps to this sq
Histogram Specification
Example 3.4. Transform the histogram of to pz(z) =
[0.5 0.2 0.1 0.05 0.05 0.1 0 0]
40
rk 1 2 3 4 5 6 7 p(rk) 0.1 0.2 0.2 0.35 0.1 0.05 sk 1 2 4 6 7 7 7 7 zq 1 2 3 4 5 6 7 p(zq) 0.5 0.2 0.1 0.05 0.05 0.1 sq 4 5 6 6 6 7 7 7 zq rk 1 2 3 4 5 6 7 3 7 7 7 7
Histogram Specification
41
Histogram Equalization Histogram Specification Desired Histogram Original Image
Local Histogram Processing
Both histogram equalization and specification methods
discussed earlier are considered global
In
- ther
words, pixels are modified using a transformation function that is defined using all pixels in the image
Such methods are suitable for overall enhancement
and may not be suitable in situations where we want to enhance small areas in the image whose pixel count contributes less to the global transformation function
42
Local Histogram Processing
Solution Consider local processing such that for each pixel
(x,y) in the image
Define a small neighborhood of size mxn that is centered
around the pixel
Use
pixels inside the neighborhood to construct the transformation function
Use the computed function map the pixel at (x,y) Repeat for all pixels
43
Local Histogram Processing
Example 3.5
44
Local histogram processing using 3x3 neighborhood Global Histogram Equalization
Related Matlab Functions
Check Matlab help for the following
functions
imadjust imhist hist bar histeq
45
Readings
Read subsection 3.3.4 titled “Using
Histogram Statistics for Image Enhancement”
46