0% found this document useful (0 votes)
29 views12 pages

Lesson 09102023

The document provides information about image processing operators. It discusses punctual operators that operate on pixel intensity levels rather than position. Common punctual operators include addition, multiplication, and image complement. The document also discusses contrast enhancement techniques like histogram stretching. Histogram stretching can improve contrast using a piecewise linear operator or nonlinear curves. It provides an example of applying a contrast stretching procedure to an image using a piecewise linear map from intensity levels [0.4, 0.7] to [0, 1].
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views12 pages

Lesson 09102023

The document provides information about image processing operators. It discusses punctual operators that operate on pixel intensity levels rather than position. Common punctual operators include addition, multiplication, and image complement. The document also discusses contrast enhancement techniques like histogram stretching. Histogram stretching can improve contrast using a piecewise linear operator or nonlinear curves. It provides an example of applying a contrast stretching procedure to an image using a piecewise linear map from intensity levels [0.4, 0.7] to [0, 1].
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

LESSON 09/10/2023 – CAP 3 BOOK

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:

- g(x,y)= f(x,y)+b (b> or <0) darkening or brightening


- g(x,y)=f(x,y) · a (a>0) general changing
- g(x,y)=1-f(x,y) IMAGE COMPLEMENT

Image complement means transforming dark regions into bright regions and viceversa.

An example is in Figure 1 (from book).

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.

Different indices can be found for contrast evaluation

- C1= maxk(fk)-mink(fk), the maximum range


- C2=s(f) i.e., the standard deviation of the image
- C3=( maxk(fk)-mink(fk))/( maxk(fk)+mink(fk)) a normalized version of C1
To better understand the difference between a low and a high contrast image, let us consider Figure 2.

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.

A standard way to improve contrast in a given image is to perform HISTOGRAM STRETCHING.

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

Figure 3. An example of piecewise linear operator of histogram stretching

Where th1 and th2 are the two thresholds such that

PIECEWISE LINEAR OPERATOR

{
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

0 th1 th2 0 th1 th2


g g
1 f 1 f

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.

The graphical representation of binarization is shown in figure 6.

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).

An example is shown in figure 7.

Figure 7. Left original image. Right image after binarization

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

Figure 8. Upper the histogram of the


original image. Lower the histogram of the binary image.

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:

Q1. Construct and draw the image histogram using


pixel values [0:0.1:1].
R1. The text says that we should use levels fk = 0,0.1,0.2,…,1 to draw the histogram
DRAWN TOGETHER

128

16 16

0.1 0.3 0.5 0.7

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

So, first of all let’s calculate the pk values:


p0.1=128/169 = 0.76, p0.3=16/169= 0.09, p0..5=16/169= 0.09, p0.7=9/169= 0.05

then, we calculate
m = 0.76*0.1 +0.09*0.3+0.09*0.5+0.05*0.7= 0.183

i2) for the computation of the std, we used the formula

√ √∑
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)

The central position is (169+1)/2=85th that corresponds to 0.1, hence md=0.1

iii) The modal value corresponds to the highest bar in the histogram that is again 0.1

iv) The ECFD is as follows:

DRAWN TOGETHER

0.94

0.85

0.76

0.01

0.1 0.3 0.5 0.7 1

Q3. Calculate C1, C2, and C3 in the original image.


C1=max(fk)-min(fk)=0.7-0.1=0.6, C2=s(f)=0.170, C3=(0.7-0.1)/(0.7+0.1)=0.75
Q4. Apply a contrast stretching procedure using the following piecewise linear map: [0.4 0.7] [0 1].
Discuss about saturation effects.
R4. The map is assumed to be linear in the range [0.4 0.7]. We should write the map explicitly.

g=m*f + q, find m and q such that

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;

Using the equation, we can transform each fk into a gk

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;

The new histogram can be pictured as follows;

144 DRAWN TOGETHER

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

C1=1-0=1, C2=0.22, C3=1/1=1

In total, all the three indices improve after contrast improvement.


CI1=C1after/C1before=1/0.6=1.7
CI2=C2after/C2before=0.22/0.17=1.3
CI3=C3after/C3before=1/0.75=1.3

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

g=0 à h=0, g=0.33 à h=1, g=1 à h=1

DRAWN TOGETHER OVER THE ORIGINAL IMAGE

HOMEWORK EXERCISES:
Ex1.

Given the two images below answer to the following questions:

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

1. Draw the histogram of the image using pixel values [0:0.1:1].


2. Compute average, standard deviation, median, mode of the distribution, and ECDF.
3. Calculate the contrast index C1, C2, C3.
4. Write and draw the contrast stretching map piecewise linear mapping [0.2 0.7] à [0 1] and calculate
again the three indices C1, C2, C3 and compare.
5. Apply the map and discuss about eventual saturation phenomena.
6. Apply a binarization threshold equal to 0.1 and draw the new image.

Ex3.

Consider the following image and answer to the questions below.

0.0

0.25

0.5

0.75

1. Draw the histogram of the image after giving a brief description.


2. Compute the average, standard deviation, median and mode values, and draw the ECDF.
3. Calculate the C1-C3 indices.
4. Write the piecewise histogram stretching map such that [0.25 0.75] à [0 1]
5. Apply the map to the image and comment saturation phenomenon.
6. Calculate again C1-C3 and compare.
7. Apply to the original image a binarization threshold equal to 0.3 and visualize the resulting binary image.
Ex4.

Consider the image below and answer to the questions

0.0

0.2

0.5

0.7

1. Draw the histogram of the image after giving a brief description.


2. Compute the average, standard deviation, median and mode values, and draw the ECDF.
3. Compute C1-C3
4. Write the piecewise histogram stretching map such that [0.5 0.7] à [0 1]
5. Apply the map to the image and comment saturation phenomenon.
6. Compute again C1-C3 and compare.
7. Apply to the original image a binarization threshold equal to 0.3 and visualize the resulting binary
image.

You might also like