Professional Documents
Culture Documents
Lab # 4
Image Enhancement in
The Spatial Domain I
May, 2020
1. Objectives
Performing image enhancement using different type of intensity transformations.
Obtaining the histogram of an image.
2. Theory
Part1: Enhancement
The first part of this experiment will deal with enhancement. The principal objective of
enhancement is to process an image so that the result is more suitable than the original
image for a specific application. The enhancement approaches utilized in this experiment
are used for the sake of general-purpose contrast manipulation. These approaches are
referred to as point processing (because they manipulate still-pixel images).
Image enhancement is a very basic image processing task that defines us to have a better
subjective judgment over the images. And Image Enhancement in spatial domain (that is,
performing operations directly on pixel values) is the very simplistic approach.
Enhanced images provide better contrast of the details that images contain. Image
enhancement is applied in every field where images are ought to be understood and
analyzed, For example, Medical Image Analysis, Analysis of images from satellites, etc.
Image enhancement simply means, transforming an image f into image g using T. Where
T is the transformation. The values of pixels in images f and g are denoted by r and s,
respectively.
The general form of the enhancement approach is:
S = T(r)
where T is a transformation that maps a pixel value (intensity) r into a pixel value s.
The results of this transformation are mapped into the gray scale range as we are dealing
here only with gray scale digital images. So, the results are mapped back into the range
[0, L-1], where L=2k, k being the number of bits in the image being considered. So, for
instance, for an 8-bit image the range of pixel values will be [0, 255].
The transformation map plot shown next depicts various curves that fall into the above
three types of enhancement techniques.
1
Figure A: Plot of various transformation functions
The Identity and Negative curves fall under the category of linear functions. Identity
curve simply indicates that input image is equal to the output image. The Log and
Inverse-Log curves fall under the category of Logarithmic functions, nth root and nth
power transformations fall under the category of Power-Law functions.
S = L-1-r
This expression results in reversing of the gray level intensities of the image
thereby producing a negative like image. The output of this function can be
directly mapped into the gray scale look-up table consisting values from 0 to L-1.
Useful for enhancing white and gray details embedded in black regions.
S = c log(1+r)
The shape of the log curve in fig. A tells that this transformation maps a narrow
range of low-level grey scale intensities into a wider range of output values. And
similarly maps the wide range of high-level grey scale intensities into a narrow
range of high level output values. The opposite of this applies for inverse-log
transform. This transform is used to expand values of dark pixels and compress
values of bright pixels.
S = c rγ
- where c and γ are positive constants
- γ<1 T plays as log transformation.
- γ>1 T plays as inverse log transformation.
- c=γ=1 Identity function
Gamma can take any value between 0 and infinity. If gamma is 1 (the default),
the mapping is linear. If gamma is less than 1, the mapping is weighted toward
higher (brighter) output values. And if gamma is greater than 1, the mapping is
weighted toward lower (darker) output values.
Fig.B illustrates the three transformation curves showing how values are mapped
when gamma is less than, equal to, and greater than 1. In each graph, the x-axis
represents the intensity values in the input image, and the y-axis represents the
intensity values in the output image.
Figure B: Transformation curves for gamma < 1, gamma = 1, and gamma > 1.
Part2: Histogram
The second part of this experiment will deal with the histogram of a digital image. For
a gray-level image in the range [0, L-1], the histogram is a discrete function:
h(rk) = nk
Where rk is the kth gray level and nk is the number of pixels in the image having level r k.
It is a common practice to normalize the histogram by dividing each of its values by the
total number of pixels in the image, denoted by n.
p(rk) = nk/n
imhist(I)
3. Exercises
Exercise1: Image Negatives
%img_neg.m
close all;
clear all;
I=imread('Lab4_1.jpg');
I=im2double(I);
for i=1:size(I,1)
for
j=1:size(I,2)
I1(i,j)=1-I(i,j);
end
end
subplot(121),imshow(I),title('original image')
subplot(122),imshow(I1),title('enhanced image (image negative)')
Output:
Exercise2: Power-Law Transformations
%power_tr.m
close all;
clear all;
clc;
I=imread('Lab4_2.tif');
I=im2double(I);
for i=1:size(I,1)
for j=1:size(I,2)
I3(i,j)=c*I(i,j)^g;
end
end
Output:
Homework
3. Plot the histogram of the original and the enhanced imaged you got in section 1,
use γ=1.0.