Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
27 views17 pages

DIP Lecture4

Uploaded by

Disha Bhadoriya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views17 pages

DIP Lecture4

Uploaded by

Disha Bhadoriya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Image Processing Lecture 4

Image Enhancement
Image enhancement aims to process an image so that the output image is
“more suitable” than the original. Suitability is application-dependent,
and the success of enhancement may be evaluated subjectively by
viewers or according to defined criterion. Image enhancement either
helps solve some computer imaging problems, or is used to improve
“image quality”.
Image enhancement techniques include sharpening, smoothing,
highlighting features, or normalizing illumination for display and/or
analysis. Enhancement methods are either used as a preprocessing step to
other imaging tasks, or as post-processing to create a more visually
desirable image.

Image Enhancement Approaches


Image enhancement approaches are classified into two categories:
• Spatial domain methods: are based on direct manipulation of pixels
in an image.
• Frequency domain methods: are based on modifying the Fourier
transform of an image.

Image Enhancement in the Spatial Domain


The term spatial domain refers to the image plane itself, i.e. the total
number of pixels composing an image. Enhancing an image in the spatial
domain could be achieved by image operators that transform an image by
changing pixel values or move them around. A spatial domain process is
denoted by the expression:

Ass. Lec. Wasseem Nahy Ibrahem Page 1


Image Processing Lecture 4

where f(x,y) is the input image, g(x, y) is the processed image, and T is an
operator on f . The operator T is applied at each location (x, y) to yield the
output, g, at that location.
For simplicity in notation, we rewrite the previous expression as follows:

where r and s are variables denoting, respectively, the gray level of f(x, y)
and g(x, y) at any point (x, y).

Enhancement using basic gray level transformations


Basic gray level transformation functions can be divided into:
• Linear: e.g. image negatives and piecewise-linear transformation
• Non-linear: e.g. logarithm and power-law transformations

Image negatives
The negative of an image with gray levels in the range [0, L-1] is
obtained by using the following expression

This type of processing is useful for enhancing white or gray detail


embedded in dark regions of an image, especially when the black areas
are dominant in size. An example of using negative transformation is
analyzing digital mammograms as shown in the figure below.
Note how much easier it is to analyze the breast tissue in the negative
image.

Ass. Lec. Wasseem Nahy Ibrahem Page 2


Image Processing Lecture 4

(a) (b)
Figure 4.1 (a) Original digital mammogram. (b) Negative image obtained by negative
transformation

Piecewise-linear transformation
The form of piecewise linear functions can be arbitrarily complex. Some
important transformations can be formulated only as piecewise functions,
for example thresholding:
For any 0 < t < 255 the threshold transform can be defined as:

Thresholding Transform
255
Output Gray Level, s

204
153
102
51
0
0 51 102 153 204 255
Input Gray Level, r

Figure 4.2 Form of thresholding transform

Ass. Lec. Wasseem Nahy Ibrahem Page 3


Image Processing Lecture 4

The figure below shows an example of thresholding an image by 80.

(a) Original image (b) Result of thresholding


Figure 4.3 Thresholding by 80

Thresholding has another form used to generate binary images from the
gray-scale images, i.e.:

Thresholding Transform
255
Output Gray Level, s

204
153
102
51
0
0 51 102 153 204 255
Input Gray Level, r

Figure 4.4 Form of thresholding transform to produce binary images

The figure below shows a gray-scale image and its binary image resulted
from thresholding the original by 120:

Ass. Lec. Wasseem Nahy Ibrahem Page 4


Image Processing Lecture 4

(a) (b)
Figure 4.5 Thresholding. (a) Gray-scale image. (b) Result of thresholding (a) by 120

Another more complex piecewise linear function can be defined as:

Piecewise Linear Transform


255
240
225
210
Output Gray Level, s

195
180
165
150
135
120
105
90
75
60
45
30
15
0
15
30
45
60
75
90
105
120
135
150
165
180
195
210
225
240
255
0

Input Gray Level, r

Figure 4.6 Form of previous piecewise linear transform

Ass. Lec. Wasseem Nahy Ibrahem Page 5


Image Processing Lecture 4

By applying this transform on the original image in Figure 4.3(a) we get


the following output image:

Figure 4.7 Result of thresholding

Piecewise linear functions are commonly used for contrast enhancement


and gray-level slicing as we will see in this lecture.

Log transformation
The general form of the log transformation is

where c is a constant, and it is assumed that . This transformation is


used to expand the values of dark pixels in an image while compressing
the higher-level values as shown in the figure below.

Ass. Lec. Wasseem Nahy Ibrahem Page 6


Image Processing Lecture 4

Log Transform
10
9
Output Gray Level, s
8
7
6
5
4
3
2
1
0
15
30
45
60
75
90
105
120
135
150
165
180
195
210
225
240
255
0

Input Gray Level, r

Figure 4.8 Form of Log transform

The figure below shows an example of applying Log transform.

(a) Original image (b) Result of Log transform


with c = 1
Figure 4.9 Applying log transformation

Note the wealth of detail visible in transformed image in comparison with


the original.

Ass. Lec. Wasseem Nahy Ibrahem Page 7


Image Processing Lecture 4

Power-law transformation
Power-law transformations have the basic form:

where c and y are positive constants. The power y is known as gamma,


hence this transform is also called Gamma transformation. The figure
below shows the form of a power-law transform with different gamma (y)
values.

Figure 4.10 Form of power-law transform with


various gamma values (c = 1 in all cases)

Power-law transformations are useful for contrast enhancement. The next


figure shows the use of power-law transform with gamma values less
than 1 to enhance a dark image.

Ass. Lec. Wasseem Nahy Ibrahem Page 8


Image Processing Lecture 4

(a) (b)

(c) (d)
Figure 4.11 (a) Original MRI image of a human spine. (b)-(d) Results of applying power-law
transformation with c = 1 and y = 0.6,0.4, and 0.3, respectively.

We note that, as gamma decreased from 0.6 to 0.4, more detail became
visible. A further decrease of gamma to 0.3 enhanced a little more detail
in the background, but began to reduce contrast ("washed-out" image).

The next figure shows another example of power-law transform with


gamma values greater than 1, used to enhance a bright image.

Ass. Lec. Wasseem Nahy Ibrahem Page 9


Image Processing Lecture 4

(a) (b)

(c) (d)
Figure 4.12 (a) Original bright image. (b)-(d) Results of applying power-law transformation
with c = 1 and y = 3, 4, and 5, respectively.

We note that, suitable results were obtained with gamma values of 3.0
and 4.0. The result obtained with y = 5.0 has areas that are too dark, in
which some detail is lost.

From the two examples, we note that:


• Dark areas become brighter and very bright areas become slightly
darker.
• Faint (bright) images can be improved with y >1, and dark images
benefit from using y <1.
Ass. Lec. Wasseem Nahy Ibrahem Page 10
Image Processing Lecture 4

Image Dynamic range, Brightness and Contrast


The dynamic range of an image is the exact subset of gray values
{0,1,…,L-1} that are present in the image. The image histogram gives a
clear indication on its dynamic range.

• When the dynamic range of an image is concentrated on the low


(dark) side of the gray scale, the image will be a dark image.

• When the dynamic range of an image is biased toward the high


side of the gray scale, the image will be a bright (light) image.

• An image with low contrast has a dynamic range that will be


narrow and will be centered toward the middle of the gray scale.
Low-contrast images tend to have a dull, washed-out gray look,
and they can result from 1) poor illumination, 2) lack of dynamic
range in the imaging sensor, or 3) wrong setting of lens aperture at
the image capturing stage.

• When the dynamic range of an image contains a significant


proportion (i.e. cover a broad range) of the gray scale, the image is
said to have a high dynamic range, and the image will have a high
contrast. In high-contrast images, the distribution of pixels is not
too far from uniform, with very few vertical lines being much
higher than the others.

The figure below illustrates a gray image shown in four basic gray-level
characteristics: dark, light, low-contrast, and high-contrast. The right side
of the figure shows the histograms corresponding to these images.

Ass. Lec. Wasseem Nahy Ibrahem Page 11


Image Processing Lecture 4

Dark
image

Light
image

Low-
contrast
image

High-
contrast
image

Figure 4.13 Four basic image types: dark, light, low-contrast, high-contrast, and their
corresponding histograms.

Ass. Lec. Wasseem Nahy Ibrahem Page 12


Image Processing Lecture 4

Contrast stretching
aims to increase (expand) the dynamic range of an image. It transforms
the gray levels in the range {0,1,…, L-1} by a piecewise linear function.
The figure below shows a typical transformation used for contrast
stretching.
The locations of points
(r1, s1) and (r2, s2)
control the shape of the
transformation function.

Figure 4.14 Form of transformation function

For example the following piecewise linear function

Contrast Stretching
255
240
225
Output Gray Level, s

210
195
180
165
150
135
120
105
90
75
60
45
30
15
0
0
15
30
45
60
75
90
105
120
135
150
165
180
195
210
225
240
255

Input Gray Level, r

Figure 4.15 Plot of above piecewise linear function

Ass. Lec. Wasseem Nahy Ibrahem Page 13


Image Processing Lecture 4

will be used to increase the contrast of the image shown in the figure
below:

(a) (b)

(c) (d)
Figure 4.16 Contrast stretching. (a) Original image. (b) Histogram of (a). (c) Result of
contrast stretching. (d) Histogram of (c).

For a given plot, we use the equation of a straight line to compute the
piecewise linear function for each line:

Ass. Lec. Wasseem Nahy Ibrahem Page 14


Image Processing Lecture 4

For example the plot in Figure 4.15, for the input gray values in the
interval [28 to 75] we get:

Similarly, we compute the equations of the other lines.

Another form of contrast stretching is with clipping at both ends as shown


in the example below:

255
Output Gray Level, s

204

153

102

51

0
15
30
45
60
75
90
105
120
135
150
165
180
195
210
225
240
255
0

Input Gray Level, r

Figure 4.17 Contrast-stretching with clipping at both ends

This transform produces a high-contrast image from the low-contrast


image shown in the next figure.

Ass. Lec. Wasseem Nahy Ibrahem Page 15


Image Processing Lecture 4

(a) (b)
Figure 4.18 (a) Low-contrast image. (b) High-contrast image resulted from applying contrast-
stretching in Figure 4.17 on (a)

Gray-level slicing
Gray-level slicing aims to highlight a specific range [A…B] of gray
levels. It simply maps all gray levels in the chosen range to a high value.
Other gray levels are either mapped to a low value (Figure 4.19(a)) or left
unchanged (Figure 4.19(b)). Gray-level slicing is used for enhancing
features such as masses of water in satellite imagery and enhancing flaws
in X-ray images.

(a) (b)
Figure 4.19 Gray-level slicing

The next figure shows an example of gray level slicing:

Ass. Lec. Wasseem Nahy Ibrahem Page 16


Image Processing Lecture 4

(a) Original image

(b) Operation intensifies desired gray level (c) Result of applying (b) on (a)
range, while preserving other values (background unchanged)

(d) Operation intensifies desired gray level (e) Result of applying (d) on (a) (background
range, while changing other values to black changed to black)

Figure 4.20 Example of gray level slicing

Ass. Lec. Wasseem Nahy Ibrahem Page 17

You might also like