1
Chapter 4 Image Processing Point Processing Lecture Digital Image Processing, Oct. 18th, 2010
Dr. Volker Krüger Institute for Production
Copenhagen Inst. Of Technology
2
Topics: Point Processing 1. What is point processing? 2. Grey level mapping 3. Histograms 4. Segmentation using thresholding
3
What is Point Processing Under the term Point Processing we summarize
all processing that can be done based on a single image pixel. The output of the process is a single value. Usually, this output value replaces the input pixel in the image. The process is carried out pixel-wise.
Examples: A number of examples are given in this lecture. Grey level mapping, histograms, segmentation using thresholding.
4
Images can be Added • Image computation, like the mapping, is
pixel-wise. • Also possible: -, , , AND, OR
… … … … a4 a3 … a2 a1
… … … … b4 b3 … b2 b1
a4 +b4
a3 +b3
a2 +b2
a1 +b1
+ =
× ÷
5
AND-, OR-Operations
1 0 1 0 0 0 1 0 AND
1 1 1 1 0 0 1 0 OR
AND =
OR =
6
Example: Image Subtraction, Background Subtraction
7
Caution!! • Undesired effects may happen, when
computing with images: Overflow / Underflow
Example: Two Gray value images , , Pixel range: 0..255! Their Pixel sum (multipl.) may be larger than 255!! Subtraction results may be smaller than 0!!
1I 2I
8
Gray Level Ehancement? • Process one pixel at a time independent of all
other pixels • For example used to correct Brightness and
Contrast (remote control)
Too low contrast Correct
Too high contrast
Too high brightness
Too low brightness
9
Brightness • The brightness is the intensity • Change brightness: • To each pixel is added the value b
• f(x,y) is the input image • g(x,y) is the (enhanced) output
image • If b>0 => brighter image • If b<0 => less bright image
g(x,y) = f(x,y) + b
10
Example Program Code for Brightness Change
Int x,y,helpVal; int a=10; for (y=1; y<height; y++) %run the loop. To run the y-loop
for (x=1; x<width; x++) %first is faster!!
helpVal=pixel(x,y)+a; %compute the new val
if (helpVal>255) %check for overflow
pixel(x,y)=255 %if overflow, save max value 255
else %if not overflow, save helpVal pixel(x,y)=helpVal;
end end
end
11
Contrast • The contrast describes the level of details we can
see • Change contrast: • Each pixel is multiplied by a • f(x,y) is the input image • g(x,y) is the (enhanced) output image • If a>1 => more contrast • If a<1 => less contrast
g(x,y) = a * f(x,y)
12
Combining brightness and contrast
• Both: • Greylevel mapping • X-Axis: Input Value • Y-Axis: Output Value • This plot: Identity
– Output equals Input • Apply to each pixel! • To save time the greylevel
mapping can be written as a Lookup-Table:
g(x,y) = a * f(x,y) + b
255 … 2 0 Output 255 … 2 0 Input
Input image: f(x,y) Out
put i
mag
e: g
(x,y
)
13
Histogram
14
How to set the greylevel mapping
A Histogram is a discrete function , • is the number of pixels with the k-th gray level • is the total number of pixels • Histogram entry gives the probability of gray value k of appearing in the image.
knn
nnkp k /)( =
)(kp
k
)(kp
• Histogram processing – a powerfull tool!
15
Histogram Types
Low Contrast
High Contrast
Dark Image Bright Image
16
Histogram processing
• Different types of mapping • Piecewise linear
17
Histogram processing
• Non-linear, e.g., Logarithmic • Arbitrary
18
Histogram Equalization
19
In Statistical Terms • The Histogram is given by
the probabilistic density function (pdf) of the pixel gray values p(x).
• The mapping g for a gray value k is defined by the probability distribution of the pdf p(x):
∑=
⋅=k
iipkg
1
)(255)(
20
Improving contrast • Humans cannot tell the difference
between greylevel values that are too close to each other
• So: spread out the greylevel values • This is called histogram stretching
21
Histogram stretching • Algorithm: 1. Find maximum:
2. Find minimum… 3. Shift values so that minimum
is 0:
4. Scale values so that maximum is 255 and write into output image g(x,y):
max=0; //Check each pixel: if f(x,y)>max
max=f(x,y);
//For each pixel: g(x,y)=f(x,y)-min;
c=255/(max-min); //For each pixel: g(x,y)=round(g(x,y)*c);
22
Something really different…
23
Segmentation • Until now: Image processing
(manipulation) • Image analysis: segmentation • The task:
– Information versus noise – Foreground (object) versus background
24
Segmentation • Use greylevel mapping and the histogram • When two peaks (modes) of a histogram
correspond to object and noise • Find a THRESHOLD value, T, that separates the
two peaks. This process is called THRESHOLDING
• Algorithm: – If f(x,y) > T then g(x,y) = 1, else g(x,y) = 0 – If f(x,y) < T then g(x,y) = 1, else g(x,y) = 0
• Result: a binary image where object pixels = 1 and noise = 0
25
What to remember • Point processing • Brightness and contrast • Greylevel mapping • Histogram • Thresholding (segmentation)
26
Amazing Computer Vision
Play Automatic Movie Summary
27
Exercises • Questions to the lecture? • What was good about the lecture and what could have been better? • Discuss the questions • Generate a simple c-program for changing the image contrast and/or the image
brightness. For this: Load “Lenna” into the memory and show her on the screen. Then, apply the today's techniques and generate a new image.
• Write a program to Histogram-Equalize the image!! • Finish the exercises from last time Questions • What does Point Processing mean? • Describe Brightness and Contrast • Describe greylevel mapping and how it relates to Brightness and Contrast • What is a histogram? • How can a histogram be used to choose the greylevel mapping? • What is histogram stretching? • What is thresholding and how is it related to a histogram and to segmentation?