Image Enhancement Spatial
Transcript of Image Enhancement Spatial
-
8/3/2019 Image Enhancement Spatial
1/74
CIS 601
Image ENHANCEMENTin the
SPATIAL DOMAIN
Dr. Rolf Lakaemper
-
8/3/2019 Image Enhancement Spatial
2/74
Most of these slides base on thebook
Digital Image Processingby Gonzales/Woods
Chapter 3
-
8/3/2019 Image Enhancement Spatial
3/74
Introduction
Image Enhancement ?
enhance otherwise hidden information Filter important image features Discard unimportant image features
Spatial Domain ? Refers to the image plane (the natural
image)
Direct image manipulation
-
8/3/2019 Image Enhancement Spatial
4/74
Remember ?
A 2D grayvalue - image is a 2D -> 1Dfunction,
v = f(x,y)
-
8/3/2019 Image Enhancement Spatial
5/74
Remember ?
As we have a function, we can applyoperators to this function, e.g.
T(f(x,y)) = f(x,y) / 2
Operator Image (= function !)
-
8/3/2019 Image Enhancement Spatial
6/74
Remember ?
T transforms the given image f(x,y)into another image g(x,y)
f(x,y) g(x,y)
-
8/3/2019 Image Enhancement Spatial
7/74
Spatial Domain
The operator T can be defined over
The set of pixels (x,y) of the image The set of neighborhoods N(x,y) of
each pixel
A set of images f1,f2,f3,
-
8/3/2019 Image Enhancement Spatial
8/74
Operation on the set of image-pixels
6 8 2 0
12 200 20 10
3 4 1 0
6 100 10 5
Spatial Domain
(Operator: Div. by 2)
-
8/3/2019 Image Enhancement Spatial
9/74
Operation on the set of neighborhoodsN(x,y) of each pixel
6 8 2 0
12 200 20 10
226
Spatial Domain
6 8
12 200
(Operator: sum)
-
8/3/2019 Image Enhancement Spatial
10/74
Operation on a set of images f1,f2,
6 8 2 0
12 200 20 10
Spatial Domain
5 5 1 0
2 20 3 4
11 13 3 0
14 220 23 14
(Operator: sum)
-
8/3/2019 Image Enhancement Spatial
11/74
Operation on the set of image-pixelsRemark: these operations can also be seen as operations on the
neighborhood of a pixel (x,y), by defining the neighborhood as the
pixel itself.
The simplest case of operators g(x,y) = T(f(x,y)) depends only on the value
of f at (x,y)
T is called a
gray-level or intensity transformation
function
Spatial Domain
-
8/3/2019 Image Enhancement Spatial
12/74
Basic Gray Level Transformations
Image Negatives Log Transformations Power Law Transformations Piecewise-Linear Transformation
Functions
For the following slides L denotes the max. possible gray value of the
image, i.e. f(x,y) [0,L]
Transformations
-
8/3/2019 Image Enhancement Spatial
13/74
Image Negatives: T(f)= L-f
Transformations
Input gray level
O
utputgray
level
T(f)=L-f
-
8/3/2019 Image Enhancement Spatial
14/74
Log Transformations:T(f) = c * log (1+ f)
Transformations
-
8/3/2019 Image Enhancement Spatial
15/74
Log Transformations
Transformations
InvLog Log
-
8/3/2019 Image Enhancement Spatial
16/74
Log Transformations
Transformations
-
8/3/2019 Image Enhancement Spatial
17/74
Power Law TransformationsT(f) = c*fK
Transformations
-
8/3/2019 Image Enhancement Spatial
18/74
varying gamma (K) obtains familyof possible transformation curves K > 0
Compresses dark values Expands bright values
K t,
0 else
t = threshold level
Piecewise Linear Transformations
Input gray level
Outputgr
ay
level
-
8/3/2019 Image Enhancement Spatial
23/74
Gray Level Slicing
Purpose: Highlight a specific range of grayvalues
Two approaches:
1. Display high value for range of interest, low valueelse (discard background)
2. Display high value for range of interest, originalvalue else (preserve background)
Piecewise Linear Transformations
-
8/3/2019 Image Enhancement Spatial
24/74
Gray Level Slicing
Piecewise Linear Transformations
-
8/3/2019 Image Enhancement Spatial
25/74
Bitplane Slicing
Extracts the information of asingle bitplane
Piecewise Linear Transformations
-
8/3/2019 Image Enhancement Spatial
26/74
Piecewise Linear Transformations
BP 7
BP5
BP0
-
8/3/2019 Image Enhancement Spatial
27/74
Exercise:
How does thetransformation function lookfor bitplanes 0,1, ?
What is the easiest way to filter a single bitplane(e.g. in MATLAB) ?
Piecewise Linear Transformations
-
8/3/2019 Image Enhancement Spatial
28/74
Histograms
Histogram Processing
gray level
Numbero
fPixels
1 4 5 0
3 1 5 1
-
8/3/2019 Image Enhancement Spatial
29/74
Histograms
Histogram Equalization:
Preprocessing technique to
enhance contrast in naturalimages
Target: find gray level
transformation function T totransform image f such that the
histogram of T(f) is equalized
-
8/3/2019 Image Enhancement Spatial
30/74
Histogram Equalization
Equalized Histogram:
The image consists of an equal
number of pixels for every gray-value, the histogram is constant !
-
8/3/2019 Image Enhancement Spatial
31/74
Histogram Equalization
Example:
We are looking for
this transformation !
T
-
8/3/2019 Image Enhancement Spatial
32/74
Histogram Equalization
Target:Find a transformation T to transform the
grayvalues g1[0..1] of an image I tograyvalues g2 = T(g1) such that the
histogram is equalized, i.e. theres an equalamount of pixels for each grayvalue.
Observation (continous model !):Assumption: Total image area = 1 (normalized). Then:
The area(!) of pixels of the transformed
image in the gray-value range 0..g2 equals
the gray-value g2.
-
8/3/2019 Image Enhancement Spatial
33/74
Histogram Equalization
The area(!) of pixels of the transformed image in the gray-
value range 0..g2 equals the gray-value g2.
Every g1 is transformed to a grayvaluethat equals the area (discrete: number of
pixels) in the image covered by pixelshaving gray-values from 0 to g1.
The transformation T function t is the
area- integral: T: g2 = 0..g1 I da
-
8/3/2019 Image Enhancement Spatial
34/74
Histogram Equalization
Discrete:
g1 is mapped to the (normalized)number of pixels having
grayvalues 0..g1 .
-
8/3/2019 Image Enhancement Spatial
35/74
Histogram Equalization
Mathematically the transformation
is deducted by theorems in
continous (not discrete) spaces.
The results achieved do NOT hold
for discrete spaces !
(Why ?)
However, its visually close.
-
8/3/2019 Image Enhancement Spatial
36/74
Histogram Equalization
Conclusion:
The transformation function that yields an imagehaving an equalized histogram is the integral of
the histogram of the source-image The discrete integral is given by the cumulative sum,
MATLAB function: cumsum() The function transforms an image into an image,
NOT a histogram into a histogram ! The
histogram is just a control tool !
In general the transformation does not create an
image with an equalized histogram in the
discrete case !
-
8/3/2019 Image Enhancement Spatial
37/74
Operations on a set of images
Operation on a set of images f1,f2,
6 8 2 0
12 200 20 10
5 5 1 0
2 20 3 4
11 13 3 0
14 220 23 14
(Operator: sum)
-
8/3/2019 Image Enhancement Spatial
38/74
Operations on a set of images
Logic (Bitwise) Operations
AND
OR
NOT
-
8/3/2019 Image Enhancement Spatial
39/74
Operations on a set of images
The operators AND,OR,NOT arefunctionally complete:
Any logic operator can be implementedusing only these 3 operators
-
8/3/2019 Image Enhancement Spatial
40/74
Operations on a set of images
Any logic operator can be implementedusing only these 3 operators:
A B Op
0 0 1
0 1 1
1 0 0
1 1 0
Op=
NOT(A)AND NOT(B)
OR
NOT(A)AND B
-
8/3/2019 Image Enhancement Spatial
41/74
Operations on a set of images
Image 1 AND Image 2
1 2 3 9
7 3 6 4
1 1 1 1
2 2 2 2
1 0 1 1
2 2 2 0
(Operator: AND)
-
8/3/2019 Image Enhancement Spatial
42/74
Operations on a set of images
Image 1 AND Image 2:Used forBitplane-Slicing and
Masking
-
8/3/2019 Image Enhancement Spatial
43/74
Operations on a set of images
Exercise: Define the mask-image, thattransforms image1 into image2 using
the OR operand
1 2 3 9
7 3 6 4
255 2 7 255
255 3 7 255
(Operator: OR)
-
8/3/2019 Image Enhancement Spatial
44/74
Operations
Arithmetic Operations on a set of images
1 2 3 9
7 3 6 4
1 1 1 1
2 2 2 2
2 3 4 10
9 5 8 6
(Operator: +)
-
8/3/2019 Image Enhancement Spatial
45/74
Operations
Exercise:
What could the operators +and be used for ?
-
8/3/2019 Image Enhancement Spatial
46/74
Operations
(MATLAB) Example: Operator Foreground-Extraction
-
8/3/2019 Image Enhancement Spatial
47/74
Operations
(MATLAB)Example: Operator +
Image Averaging
-
8/3/2019 Image Enhancement Spatial
48/74
Part 2
CIS 601
Image ENHANCEMENTin the
SPATIAL DOMAIN
-
8/3/2019 Image Enhancement Spatial
49/74
Histograms
So far (part 1) :
Histogram definition Histogram equalization
Now:
Histogram statistics
-
8/3/2019 Image Enhancement Spatial
50/74
Histograms
Remember:The histogram shows the number of
pixels having a certain gray-value
numberofpixels
grayvalue (0..1)
-
8/3/2019 Image Enhancement Spatial
51/74
Histograms
The NORMALIZED histogram is thehistogram divided by the total number
of pixels in the source image.
The sum of all values in the normalizedhistogram is 1.
The value given by the normalizedhistogram for a certain gray value can
be read as the probability of randomly
picking a pixel having that gray value
-
8/3/2019 Image Enhancement Spatial
52/74
Histograms
What can the (normalized)
histogram tell about the
image ?
-
8/3/2019 Image Enhancement Spatial
53/74
Histograms
1.The MEAN VALUE (or average gray level)
M =7g g h(g)
1*0.3+2*0.1+3*0.2+4*0.1+5*0.2+6*0.1=
2.60.3
0.2
0.1
0.0
1 2 3 4 5 6
-
8/3/2019 Image Enhancement Spatial
54/74
Histograms
The MEAN value is the average gray
value of the image, the overallbrightness appearance.
-
8/3/2019 Image Enhancement Spatial
55/74
Histograms
2. The VARIANCE
V = 7g (g-M)2 h(g)
(with M = mean)
or similar:
The STANDARD DEVIATION
D = sqrt(V)
-
8/3/2019 Image Enhancement Spatial
56/74
Histograms
VARIANCE gives a measure about the
distribution of the histogram values
around the mean.
0.3
0.2
0.1
0.0
0.3
0.2
0.1
0.0
V1 > V2
-
8/3/2019 Image Enhancement Spatial
57/74
Histograms
The STANDARD DEVIATION is a value
on the gray level axis, showing the
average distance of all pixels to the
mean
0.3
0.2
0.1
0.0
0.3
0.2
0.1
0.0
D1 > D2
-
8/3/2019 Image Enhancement Spatial
58/74
Histograms
VARIANCE and STANDARD DEVIATION
of the histogram tell us about the
average contrast of the image !
The higher the VARIANCE (=the higherthe STANDARD DEVIATION), the
higher the images contrast !
-
8/3/2019 Image Enhancement Spatial
59/74
Histograms
Example:
Image and blurred version
-
8/3/2019 Image Enhancement Spatial
60/74
Histograms
Histograms with MEAN andSTANDARD DEVIATION
M=
0.7
3D=
0.32 M=
0.7
1D=
0.27
-
8/3/2019 Image Enhancement Spatial
61/74
Histograms
Exercise:
Design an autofocus system for a digital
camera !
The system should analyse an area in the middle of the picture and
automatically adjust the lens such that this area is sharp.
-
8/3/2019 Image Enhancement Spatial
62/74
Histograms
In between the basics
histograms can give us a first hinthow to create image databases:
-
8/3/2019 Image Enhancement Spatial
63/74
Feature Based Coding
Feature Based Coding
Determine a feature-vector for a given image
Compare images by their feature-vectors
Two operations need to be defined: a mapping of shape
into the feature space and a similarity of feature vectors.
Where are the histograms ?
Representation Feature Extraction Vector Comparison
-
8/3/2019 Image Enhancement Spatial
64/74
Feature Based Coding
Feature Based Coding Determine a feature-vector for a given image
Compare images by their feature-vectors
Two operations need to be defined: a mapping of shape
into the feature space and a similarity of feature vectors.
HERE !
Question: how can we compare histograms (vectors) ?
Representation HISTOGRAM Histogram Comp.
-
8/3/2019 Image Enhancement Spatial
65/74
Vector Comparison
Vector Comparison
,
V t C i
-
8/3/2019 Image Enhancement Spatial
66/74
Vector Comparison
V t C i
-
8/3/2019 Image Enhancement Spatial
67/74
Vector Comparison
V t C i
-
8/3/2019 Image Enhancement Spatial
68/74
Vector Comparison
Whats the meaning of the Cosine Distance with
respect to histograms ?
i.e.: whats the consequence of eliminating the vectors length information ?
V t C i
-
8/3/2019 Image Enhancement Spatial
69/74
Vector Comparison
More Vector Distances:
Quadratic Form Distance Earth Movers Distance
Proportional Transportation Distance
V t C i
-
8/3/2019 Image Enhancement Spatial
70/74
Vector Comparison
Histogram Intersection
(non symmetric):
d(h1,h2) = 1 - min(h1,h2 ) / h1
Ex.: What could be a huge drawback of image
comparison using histogram intersection ?
i i i ii
Hi t
-
8/3/2019 Image Enhancement Spatial
71/74
Histograms
Exercise:
Outline an image database system,using statistical (histogram)
information
Histograms
-
8/3/2019 Image Enhancement Spatial
72/74
Histograms
Discussion:
Which problems could occur if thedatabase consists of the following
images ?
Histograms
-
8/3/2019 Image Enhancement Spatial
73/74
Histograms
Spatial Filtering
-
8/3/2019 Image Enhancement Spatial
74/74
Spatial Filtering
End of histograms.
And now to something completelydifferent