Professional Documents
Culture Documents
Lecture-4
The
2
of
Basic of Intensity Transformation &
36
Spatial Filtering
The spatial domain processes we discuss in this chapter are
based on the expression g(x, y) = T[f(x, y)]
where f (x, y) is an input image, g (x, y) is the output image, and T is
an operator on f defined over a neighborhood of point (x, y).
The operator can be applied to the
pixels of a single image or to the pixels
of a set of images, such as performing
the elementwise sum of a sequence
of images for noise reduction.
The point (x0 , y0) shown is an arbitrary
location in the image, and the small region
shown is a neighborhood of (x0 , y0).
The
3
of
Basic of Intensity Transformation &
36
Spatial Filtering
The smallest possible neighborhood is of size 1 × 1 . In this case, g depends only on
the value of f at a single point (x, y) and T becomes an intensity (also called a gray-
level, or mapping) transformation function of the form: s = T(r)
(a) Fourier spectrum displayed as a grayscale image. (b) Result of applying the log transformation with c = 1. Both
images are scaled to the range [0, 255].
10
of
Some Basic Intensity Transformation
36
Functions
Inverse Log Transformations:
Do opposite to the log transformations
Used to expand the values of high pixels in an image while
compressing the darker-level values.
11
of
Some Basic Intensity Transformation
36
Functions
Power-law (Gamma) Transformations:
The general form of the power-law transformations has the for s = crᵧ
Where c and are positive constants.
Plots of the gamma equation
s = cr for various values of
(c = 1 in all cases). Each
curve was scaled
independently so that all
curves would fit in the
same graph. Our interest
here is on the shapes of
the curves, not on their
relative values.
The process used to correct
these power-law response
phenomena is called gamma correction or gamma encoding.
12
of
Some Basic Intensity Transformation
36
Functions
Power-law (Gamma) Transformations:
(a) Intensity ramp image.
(b) Image as viewed on a
simulated monitor with a
gamma of 2.5. (c) Gamma
corrected image.
(d) Corrected image as
viewed on the same monitor.
Compare (d) and (a).
13
of
Some Basic Intensity Transformation
36
Functions
Power-law (Gamma)
Transformations:
(a) Magnetic resonance
image (MRI) of a fractured
human spine (the region
of the fracture is enclosed by
the circle).
(b)–(d) Results of applying the
transformation with c = 1 and
= 0.6, 0.4, and 0.3,
respectively.
14
of
Some Basic Intensity Transformation
36
Functions
Power-law (Gamma) Transformations:
Map a narrow range of dark input values into a wider
range of output
values or vice versa
If <1 :the mapping is weighted toward brighter
output values.
If =1 (default):the mapping is linear.
If >1 :the mapping is weighted toward darker
output values.
15
of
Some Basic Intensity Transformation
36
Functions
Power-law Example:
(a) Aerial image.
(b)–(d) Results
of applying the
transformation
with = 3.0, 4.0,
and 5.0, respectively.
16
of
36
Function imadjust
Function imadjust is the basic IPT tool for intensity
transformations of gray-scale images. It has the
syntax:
(a = rmin b = rmax)
This is called contrast stretching, which means that the bright pixels in the
a m b
image will become brighter and the dark pixels will become darker, this
means : higher contrast image.
24
of
Some Basic Intensity Transformation
36
Functions
Thresholding: Is a limited case of contrast stretching, it produces a
two-level (binary) image. Pixels above 150
Assume that
a = rmin
b = rmax
K = intensity
if r > 150; s = 1
T=
if r < 150; s =0
Pixels less than 150
25
of
Some Basic Intensity Transformation
36
Functions
Thresholding:
Pixels above threshold is considered bright and below it is considered dark, and this
process is called thresholding.
26
of
Some Basic Intensity Transformation
36
Functions
Exercise:
The following matrix represents the pixels values of an 8-bit
image (r) , apply thresholding transform assuming that the
threshold m=95, find the resulting image pixel values.
Solution:
27
of
Some Basic Intensity Transformation
36
Functions
Intensity-Level Slicing (Grey-Level Slicing:
There are applications in which it is of interest to highlight a specific range of intensities in an image.
Some of these applications include enhancing features in satellite imagery, such as masses of water, and
enhancing flaws in X-ray images.
(a) This transformation function highlights range [A , B] and reduces all other intensities to a lower level. (b) This function
highlights range [A , B] and leaves other intensities unchanged.
28
of
Some Basic Intensity Transformation
36
Functions
Intensity-Level Slicing:
(a) Aortic angiogram. (b) Result of using a slicing transformation of the type illustrated in Fig. slide 11(a), with the range of
intensities of interest selected in the upper end of the gray scale. (c) Result of using the transformation in Fig. slide 11(b), with
the selected range set near black, so that the grays in the area of the blood vessels and kidneys were preserved.
29
of
Some Basic Intensity Transformation
36
Functions
Example: Apply intensity level slicing to read cameraman image , then If
the pixel intensity in the old image is between (100 200) convert it in the
new image into 255 (white). Otherwise convert it to 0 (black).
30
of
Some Basic Intensity Transformation
36
Functions
Example: Apply intensity level slicing to read cameraman image , then If
the pixel intensity in the old image is between (100 200) convert it in the
new image into 255 (white). Otherwise convert it to 0 (black).
Solution (Matlab):
x=imread('cameraman.tif');
y=x;
[w h]=size(x);
for i=1:w
for j=1:h
if x(i,j)>=100 && x(i,j)<=200 y(i,j)=255;
else y(i,j)=0;
end
end
end
figure, imshow(x);
figure, imshow(y);
31
of
Some Basic Intensity Transformation
36
Functions
Bit-Plane Slicing:
Pixel values are integers composed of bits. For example, values in a 256-
level grayscale image are composed of 8 bits (one byte).
As Fig. illustrates, an 8-bit image may be considered as being composed
of eight one-bit planes, with plane 1 containing the lowest-order bit of all
pixels in the image, and plane 8 all the highest-order bits.
32
of
Some Basic Intensity Transformation
36
Functions
Bit-Plane Slicing:
(a) An 8-bit gray-scale image of size 550 × 1192 pixels. (b) through (i) Bit
planes 8 through 1, with bit plane 1 corresponding to the least significant
bit. Each bit plane is a binary image.
33
of
Some Basic Intensity Transformation
36
Functions
Bit-Plane Slicing:
(a) An 8-bit gray-scale image of size 550 × 1192 pixels. (b) through (i) Bit
planes 8 through 1, with bit plane 1 corresponding to the least significant
bit. Each bit plane is a binary image.
34
of
Some Basic Intensity Transformation
36
Functions
Example:
We have to use bit get and bit set to extract 8 images;
01100100
35
of
Some Basic Intensity Transformation
36
Functions
Example: Apply bit-plane slicing in Matlab to read cameraman
image , then extract the image of bit 6.
Solution:
x=imread('cameraman.tif');
y=x*0;
[w h]=size(x);
for i=1:w
for j=1:h
b=bitget(x(i,j),6);
y(i,j)=bitset(y(i,j),6,b);
end
end
figure, imshow(x);
figure, imshow(y);