Lesson 09102023
Lesson 09102023
PUNCTUAL OPERATORS
The first simple operators we see are the so called “punctual operators”. The name is related to the fact
that the operator only works on intensity level and not on the position. Therefore, two distinct pixels p(x,y)
and q(t,s) that are in different position but have the same intensity level, i.e., p==q, will be treated in the
same way.
This kind of operators is usually indicated with letter T, i.e., g(x,y)=T(f(x,y)) indicates that all the pixel
intensities f will be transformed through T into a novel image g(x,y).
Standard very easy punctual operators, already seen in the previous lessons are:
Image complement means transforming dark regions into bright regions and viceversa.
Figure 1. To the left the original mammographic image of the breast. To the right the complement image.
Image complement is useful for better visibility purposes or because the image processing algorithms have
been already tuned to work with bright objects on a dark background.
CONTRAST ENHANCEMENT
Contrast in a given image is a very important concept related to the human capability to discriminate
details and objects in a given image due to differences in the gray levels.
More formally, contrast is related to the maximum intensity range used in a given image and it is related to
the dispersion (spreading or width) of the intensity values in the image histogram.
Figure 2. Left. Two examples of histograms of a dark and a bright image. The histogram move towards left
and right respectively. Right. Two examples of a low (upper) and high (lower) contrast images. The
histogram becomes narrower or wider respectively.
Histogram stretching can be implemented through a so called piecewise linear operator as that depicted in
Figure 3. Tots els valors sota el th1 i els valors superiors a th2 no són importants. Els valors significants son
entre th1 I th2.
0
0 th1 th2 1 f
Where th1 and th2 are the two thresholds such that
{
0 , f ( x , y ) <th1
g ( x , y )= 1 , f ( x , y ) >th2
f ( x , y ) −th 1
, th1 ≤ f (x , y)≤ th2
th 2−th 1
In the following, in the exercise, we will also indicate such map as [th1,th2] à [0 1].
Of course, the map can be extended using a nonlinearity in the central part of the operator as indicated in
Figure 4.
1
<1
=1
>1
0
0 th1 th2 1 f
Figure 4. A general histogram stretching operator with different nonlinearities, g < 1 or g > 1.
In formula, we have
{(
0 , f ( x , y ) <th 1
1 , f ( x , y ) >th 2
g ( x , y )=
)
γ
f ( x , y )−th 1
, th1 ≤ f (x , y)≤ th2
th2−th 1
Curves with g < 1 are usually called logarithmic curves and are suitable to increase contrast in dark image
while curves with g > 1 are usually called power law curves and are suitable to increase contrast in bright
images. The situation in depicted in Figure 5.
Logarithmic law is suitable for dark image Power law is suitable for bright image
1 1
<1
>1
1 1
0 0
bright image f
dark image f
Figure 5. Left. An example of histogram stretching for a dark image using a logarithmic law. Right. An
example of histogram stretching for a bright image using a power law.
Of course saturation phenomena can occur in all the histogram stretching procedures when th1 >0 and th2
< 1.
BINARIZATION (th1=th2)
A very famous operator that falls within the category of punctual operator is binarization operator also
called thresholding function.
g
1
0
0 th 1 f
Figure 6. A possible binarization operator. The threshold value th is indicated. In formula, we have that g=0
for f < th and g= 1 for f >= th. (the equal can be arbitrarily assigned to one of the two conditions).
1000
500
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
6000
4000
2000
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Binary images are good to locate objects (white over a black background) and hence to extract the shape of
the objects and related information as it will be shown in next chapters.
EXAMPLE EXERCISE
Consider the following image with pixel intensities indicated in the legend. Please answer to the following
questions:
128
16 16
Q2. Compute average value, standard deviation, median and modal values, and draw the empirical
cumulative distribution function (ECDF).
R2.
L L
nk
i1) m=∑ f k pk =∑ f k
k =0 k=0 T
then, we calculate
m = 0.76*0.1 +0.09*0.3+0.09*0.5+0.05*0.7= 0.183
√ √∑
L L
1
σ= ∑
T k=0
nk (f k −m)2= pk (f k −m)2=¿ ¿
k=0
Hence we have
s2=0.76*(0.1-0.183)2+0.09*(0.3-0.183)2+0.09*(0.5-0.183)2+0.05*(0.7-0.183)2=
= 0.76*0.007+0.09*0.014+0.09*0.10+0.05*0.267=0.005+0.00126+0.009+0.01=0.0286
and σ =0.170
ii) For the median md we should sort the values in the image
0.1 …. 0.1 (128 times), 0.3…0.3 (16 times), 0.5 … 0.5 (16 times), 0.7… 0.7 (9 times)
iii) The modal value corresponds to the highest bar in the histogram that is again 0.1
DRAWN TOGETHER
0.94
0.85
0.76
0.01
0 = m * 0.4 + q
1 = m * 0.7 + q
Solving the linear system, for example by subtracting the two equations we have
1 = m*(0.7-0.4)=m*0.3
Hence m = 10/3
And q = -10/3*4/10=-4/3
So g = 10/3 * f – 4/3
But remember that g=0 for f <0.4 and g=1 for f>0.7;
Therefore,
g0.1=0, g0.3=0, g0.5=10/3*0.5-4/3=10/3*5/10-4/3=1/3=0.33, g0.7=1;
16
0.0 0.33 1
Now we can calculate again the C1-C2 indices.
First we need to evaluate again the m and the s.
Then we have
m=144/169*0+16/169*0.33+9/169*1=0.03+0.05=0.08
s=sqrt( 16/169*(0.33-0.08)2+9/169*(1-0.08)2)=sqrt(16/169*0.0625+9/169*0.846)=sqrt(0.006+0.045)=0.22
Q4. Apply a binarization threshold equal to 0.2 and draw the final resulting image.
R4: By choosing the threshold equal to 0.2 we should map all the values below 0.2 to 0 and all the values
higher than 0.2 to 1.
Actual values are 0, 0.33,1 hence the final results of binarization, i.e., h=T(g) will be
HOMEWORK EXERCISES:
Ex1.
1. Under the assumption that white is 0 and that gray level is 0.5 then draw the histograms of the two
images and discuss the comparative result. What do the two images have in common?
2. Binarize the two images with a threshold equal to 0.25 and then with a threshold equal to 0.75 and
discuss about the two results obtained.
Ex2.
Consider the following image with pixel intensities indicated in the legend. Please answer to the following
questions:
0.0
0.2
0.5
0.7
Ex3.
0.0
0.25
0.5
0.75
0.0
0.2
0.5
0.7