Chapter III - Image Enhancement
Chapter III - Image Enhancement
Chapter III - Image Enhancement
Enhancing an image provides better contrast and a more detailed image as compare to
non-enhanced image. Image enhancement has very applications. It is used to enhance medical
images, images captured in remote sensing, images from satellite e.t.c
Spatial Domain Techniques
These techniques are based on gray level mappings, where the type of mapping used depends
on the criterion chosen for enhancement. As an eg. consider the problem of enhancing the
contrast of an image. Let r and s denote any gray level in the original and enhanced image
respectively. Suppose that for every pixel with level r in original image we create a pixel in the
enhanced image with level . If has the form as shown
where r is the pixels of the input image and s is the pixels of the output image. T is a transformation function
that maps each value of r to each value of s. Image enhancement can be done through gray level
transformations which are discussed below.
Linear
Logarithmic
Power – law
The overall graph of these transitions has been shown in figure 2.
1. Linear transformation
First we will look at the linear transformation. Linear transformation includes simple identity and negative
transformation.
Identity transformation
Identity transition is shown by a straight line. In this transition, each value of the input image is directly
mapped to each other value of output image. In this there is no difference in input image and output image.
And hence is called identity transformation. It has been shown below
Negative transformation
This is linear transformation. In negative transformation, each value of the input image is subtracted from the
L-1 and mapped onto the output image.
s = (L – 1) – r
since the input image of Einstein is an 8 bpp image , so the number of levels in this image are 256. Putting
256 in the equation, we get this
s = 255 – r
So each value is subtracted by 255 and the result image has been shown above. So what happens is that , the
lighter pixels become dark and the darker picture becomes light. And it results in image negative.
2. Logarithmic transformations:
Logarithmic transformation further contains two type of transformation. Log transformation and inverse log
transformation.
Log transformation
Where s and r are the pixel values of the output and the input image and c is a constant. The value 1 is added
to each of the pixel value of the input image because if there is a pixel intensity of 0 in the image, then log (0)
is equal to infinity. So 1 is added , to make the minimum value at least 1.
During log transformation, the dark pixels in an image are expanded as compare to the higher pixel values.
The higher pixel values are kind of compressed in log transformation. This result in following image
enhancement. The value of c in the log transform adjust the kind of enhancement you are looking for.
There are further two transformation is power law transformations, that include nth power and nth root
transformation. These transformations can be given by the expression:
s=cr
This symbol γ is called gamma, due to which this transformation is also known as gamma transformation.
Variation in the value of γ varies the enhancement of the images. Different display devices / monitors have
their own gamma correction, that’s why they display their image at different intensity.
This type of transformation is used for enhancing images for different type of display devices. The gamma of
different display devices is different. For example Gamma of CRT lies in between of 1.8 to 2.5 , that means
the image displayed on CRT is dark.
CORRECTING GAMMA.
s=cr
s=cr(1/2.5)
The same image but with different gamma values has been shown here.
Figure 7: Example of power law transform
Figure 8: Power law transforms are used to darken the image. Different curves highlight different detail
3.1.2 Thresholding
Image thresholding is a simple, yet effective, way of partitioning an image into a foreground and background..
From a grayscale image, thresholding can be used to create binary images.
Purpose
The purpose of thresholding is to extract those pixels from some image which represent
an object (either text or other line image data such as graphs, maps). Though the information is binary
the pixels represent a range of intensities. Thus the objective of binarization is to mark pixels that belong
to true foreground regions with a single intensity and background regions with different intensities.
In many vision applications, it is useful to be able to separate out the regions of the image
corresponding to objects in which we are interested, from the regions of the image that
correspond to background. Thresholding often provides an easy and convenient way to perform
this segmentation on the basis of the different intensities or colors in the foreground and
background regions of an image.
The input to a thresholding operation is typically a grayscale or color image. In the simplest
implementation, the output is a binary image representing the segmentation. Black pixels
correspond to background and white pixels correspond to foreground (or vice versa). In simple
implementations, the segmentation is determined by a single parameter known as the intensity
threshold. In a single pass, each pixel in the image is compared with this threshold. If the pixel's
intensity is higher than the threshold, the pixel is set to, say, white in the output. If it is less than
the threshold, it is set to black.
1. Contrast stretching
One of the simplest pricewise linear functions is a contrast stretching. Low contrast images can
result from poor illumination and wrong setting of lens aperture during image acquisition.
Contrast stretching is a process that expands the range of intensity levels in an image.
The contrast of an image is a measure of its dynamic range, or the "spread" of its histogram.
Contrast stretching is a simple image enhancement technique that attempts to improve the
contrast in an image by `stretching' the range of intensity values it contains to span a desired
range of values, e.g. the the full range of pixel values that the image type concerned allows.
Figure 9 shows typical transformation used for contrast stretching.
S= ɻ . r a ≤r ≤ a
¿ m ( r – a ) + v a ≤ r ≤b
How It Works
Before the stretching can be performed it is necessary to specify the upper and lower pixel
value limits over which the image is to be normalized. Often these limits will just be the
minimum and maximum pixel values that the image type concerned allows. For example for 8-
bit graylevel images the lower and upper limits might be 0 and 255. Call the lower and the
upper limits a and b respectively.
The simplest sort of normalization then scans the image to find the lowest and highest pixel
values currently present in the image.
FOR EXAMPLE.
=0
Contrast stretching the image in Figure 11a produces what is shown in Figure 12a. The image
now takes on the full 8-bit range, and correspondingly the new histogram is spread out over the
range 0-255, resulting in an image that subjectively looks far better to the human eye. However,
the drawback to modifying the histogram of an image in such a manner comes at the expense
of greater "graininess." If the original image is of rather low-contrast and does not contain
much information, stretching the contrast can only accomplish so much.
Figure 12:. X-ray image courtesy of SRS-X, http://www.radiology.co.uk/srs-x. (a) Low contrast
chest x-ray image, (b) Low contrast histogram.
Figure 13. (a) Contrast-stretched chest x-ray image, (b) Modified histogram.
2. Gray-level slicing
Another application is enhancing flaws in x-ray. There are two main different
approaches:
The fig.13 illustrates the intensity level slicing process. The left figures show a
transformation function that highlights a range [A,B] while diminishing all the others.
The right figures highlights a range [A,B] but preserves all the others.
Instead of highlighting gray level images, highlighting the contribution made to total image
appearance by specific bits might be desired. Suppose that each pixel in an image is represented by
8 bits. Imagine the image is composed of 8, 1-bit planes ranging from bit plane1-0 (LSB)to bit plane
7 (MSB).
In terms of 8-bits bytes, plane 0 contains all lowest order bits in the bytes comprising the pixels in
the image and plane 7 contains all high order bits.
Separating a digital image into its bit planes is useful for analyzing the relative importance played by
each bit of the image, implying, it determines the adequacy of numbers of bits used to quantize
each pixel , useful for image compression.
In terms of bit-plane extraction for a 8-bit image, it is seen that binary image for bit plane 7 is
obtained by proceeding the input image with a thresholding gray-level transformation function that
maps all levels between 0 and 127 to one level (e.g 0)and maps all levels from 129 to 253 to
another (eg. 255).
Example :
Digitally, an image is represented in terms of pixels. These pixels can be expressed further in
terms of bits. Consider the image ‘coins.png’ and the pixel representation of the image.
Figure 16: Example of bit plane slicing
Consider the pixels that are bounded within the yellow line. The binary formats
for those values are (8-bit representation)
And plane 8 contains the highest order bit of all the pixels in the image.
Figure 17: The 8 bit-planes of a gray-scale image (the one on left). There are eight because the
original image uses eight bits per pixel.
For an image having 256 grey levels i.e. from 0 to 255 each level can be represented by 8 bits
where 00000000 represents black and 11111111 represents white.
2 4 0
1 7 6
3 5 3
Solution → maximum grey level = 7, hence image can be sup resented by three bits.
Example 2: Obtain digital negative of following image. Image contains 256 grey levels.
61 110 255 60 98
S =255 – x
134 50 38 99 104
134 45 99 84 150
Example 3: For given image find.
7 5 2 0
3 4 6 5
2 3 6 1
S=7–x
3 2 1 0
0 2 5 7
4 3 2 1
5 4 0 6
r2 = 5, r1 = 3,S2 =6, S1 =2
4 3 2 1
3 1 2 4
f(x, y) = 5 1 6 2
2 3 5 6
Solution:
r1 = 3,r2 =5 , s1 =2, s2 =6
s1 2
ɻ= = =0.66
r1 3
s2−s 6−2
m= = 1
=2
r 2−r 1 5−3
L−s 7−6
n= 2
= =0.5
L−r 2 7−5
S= ɻ . r 0≤ r ≤3
¿ m . ( r – a ) +v 3 ≤r ≤ 5
¿ n . ( r – b ) + w 5≤ r ≤7
a= r1 =3 , b = r2 =5 , v =2, w=6
r s
0 ɻ r = 0.66 x 0 =0
1 ɻ r = 0.66 x 1 =0.66
2 ɻ r = 0.66 x 2 =1.32
3 m (r –a) +v = 2(3-3)+2=2
4 m (r –a) +v = 2(4-3)+2=4
5 n (r –b) +w = 0.5(5-5)+6=6
6 n(r –b) +w = 0.5(6-5)+6=6.5
7 n (r –b) +w= 0.5(7-5)+6=7
4 2 1 1
2 1 1 1
6 1 7 1
1 2 6 7
Example 5: Performs intensity level (grey level) slicing on 3 BPP image. Z ofr 1=3 and r 2=5
Draw modified image using background and without background transformation.
2 1 2 2 1
2 3 4 5 2
6 2 7 6 0
2 6 6 5 1
0 3 2 2 1
Solution:
Without background. (Clipping)
0 0 0 0 0
0 7 7 7 0
7 0 0 0 0
0 0 0 7 0
0 7 0 0 0
2 1 2 2 1
2 7 7 7 2
6 2 7 6 0
2 6 6 7 1
0 7 2 2 1
Example 6: For the 3-bit 4x4 sige image perform the following operations.
1) Negation
2) Thresholding with T=4
3) Intensity level slicing with r1 =2 and r2 =5
4) Bit plan slicing for MSB & MSB planes
5) Clipping with r1 =2 and r2 =5
1 2 3 0
2 4 6 7
5 2 4 3
3 2 6 1
Solution. 1) Negation
S=(L-1)-r
= (8-1)-r
=7-r
6 5 4 7
5 3 1 0
G(x,y) =
2 5 3 4
4 5 1 6
1) Thresholding.
g ( x , y )= o if f ( x , y ) ≤ 4
{7 if f ( x , y )≥ 4 }
7 7 7 7
7 0 0 0
0 7 0 7
7 7 0 7
2) Intensity level slicing
0 7 7 0
7 7 0 0
7 7 7 7
7 7 0 0
1 2 7 0
2 7 6 0
7 7 7 7
7 7 6 1
0 0 0 0 1 0 1 0
0 1 1 1 0 0 0 1
1 0 1 0 1 0 0 1
0 0 1 0 1 0 0 1
When filtering an image, each pixel is affected by its neighbors, and the net effect of filtering is
moving information around the image.
A low pass filter is the basis for most smoothing methods. An image is smoothed by decreasing
the disparity between pixel values by averaging nearby pixels . Using a low pass filter tends to
retain the low frequency information within an image while reducing the high frequency
information. An example is an array of ones divided by the number of elements within the
kernel, such as the following 3 by 3 kernel:
1. Averaging ( Mean) Filter
The idea of mean filtering is simply to replace each pixel value in an image with the mean
(`average') value of its neighbors, including itself. This has the effect of eliminating pixel values
which are unrepresentative of their surroundings. Mean filtering is usually thought of as a
convolution filter. Like other convolutions it is based around a kernel, which represents the
shape and size of the neighborhood to be sampled when calculating the mean.
Figure 18 : Original image on left and it’s low pass filtered image on right
We can see the filtered image (right) has been blurred a little bit compared to the original input
(left). As mentioned earlier, the low pass filter can be used for denoising. Let's test it. First, to
make the input a little bit dirty, spray some pepper and salt on the image, and then apply the
mean filter. You can observe that after applying averaging filter salt and paper noise is
minimized
Figure 19 : Image with salt and pepper noise on left and it’s low pass filtered image on right
1 1 1
1
x 1 1 1
9
1 1 1
1 1 1 1
1 1 1 1 1
25 1 1 1 1
1 1 1 1
Example 1 : Filter following image using 3 x 3 neighborhood averaging without zero padding
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
Solution: Place 3 x 3 mask on image. Start from left top corner. Keep borders as they are perform
convolution. Change value of Centre pixel. Shift mask towards right and then downwards
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
23.3 23.3 23.3 23.3 23.3 23.3 23.3 23.3
36..6 36..6 36..6 36..6 36..6 36..6 36..6 36..6
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
We can see that, low frog, regions have remained unchanged, but the sharp edge between 10 and 50
has become blurred. These kind of averaging filter are good for removing Gaussian noise. It achieves
filtering by blurring the noise some other low pass averaging measles are.
0 1 0
1 2 1
0 1 0
1
6
0 1 0
1/10 1 2 1
0 1 0
Example2: Filter the following image using 3 x 3 neighbourhood averaging by assuming i) giro padding
ii) pixel rapt cation
1 2 3 2
4 2 5 1
1 2 6 3
2 4 6 7
0 1 0
1 1 2 1
9
0 1 0
i) Zero padding.
0 0 0 0 0 0
0 0 0 0 0 0
Round off
ii)Pixel Replication
1 1 2 3 2 2
1 1 2 3 2 2
4 4 2 5 1 1
1 1 2 6 3 3
2 2 4 6 7 7
2 2 4 6 7 7
1 1 2 3 2 2
2 2 4 6 7 7
Figure 20 : Mean filter has some effect on the salt and pepper noise but not much. It just
made them blurred.
Median filter
Much better. Unlike the previous filter which is just using mean value, this time let us use
median. Median filtering is a nonlinear operation often used in image processing to reduce "salt
and pepper" noise.
6) Move mask in a similar fashion from left to right and top to bottom.
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 250 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
10 10 10 -- ---- 10
10 10 --- -- ---- 10
10 10 -- -- ---- 10
10 10 -- -- ---- 10
50 50 -- -- ---- 50
50 50 -- -- ---- 50
50 50 -- -- ---- 50
50 50 -- - - - - - - 50
We can see that salt & pepper noise is removed.
Example 2:. Given an image what is output using 3 x 3 averaging filter and median filter.
3 3 3 3 3 3
3 3 3 3 3 3
3 3 10 10 3 3
3 10 3 3 3 3
3 3 3 3 8 3
3 3 3 3 3 3
3 3 3 3 3 3
A high pass filter is the basis for most sharpening methods. An image is sharpened when
contrast is enhanced between adjoining areas with little variation in brightness or darkness
A high pass filter tends to retain the high frequency information within an image while reducing
the low frequency information. The kernel of the high pass filter is designed to increase the
brightness of the center pixel relative to neighboring pixels. The kernel array usually contains a
single positive value at its center, which is completely surrounded by negative values. The
following array is an example of a 3 by 3 kernel for a high pass filter:
-1 -1 -1
-1 8 -1
-1 -1 -1
1
9
Example 2: Apply low pass and high pass spatial marks on following image.
Prove that HP=original image-Low Pass image using zero padding
Solution.
1
Low pass mas is
9
Output is
-1 -1 -1
-1 8 -1
HP mask is -1 -1 -1 1
9
Output image is =
3.2.3 The High-Boost Filter
It is often desirable to emphasize high frequency components representing the image details
without eliminating low frequency components representing the basic form of the signal. In this
case, the high-boost filter can be used to enhance high frequency component while still keeping
the low frequency components:
• The high-boost filter can be used to enhance high frequency component while still
keeping the low frequency components.
• High boost filter is composed by an all pass filter and a edge detection filter (Laplacian
filter). Thus, it emphasizes edges and results in image sharpener.
• The high-boost filter is a simple sharpening operator in signal and image processing.
• It is used for amplifying high frequency components of signals and images. The
amplification is achieved via a procedure which subtracts a smoothed version of the
media data from the original one.
• In image processing, we can sharpen edges of a image through the amplification and
obtain a more clear image.
• The high boost filtering is expressed in equation form as follows:
F HB =( A−1 ) f ( x , y ) + F HP (x , y)
3.3 Histograms
Histograms are graphs of a distribution of data designed to show centering, dispersion (spread), and
shape (relative frequency) of the data. Histograms can provide a visual display of large amounts of data
that are difficult to understand in a tabular, or spreadsheet form. Usually histogram have bars that
represent frequency of occurring of data in the whole data set.
Histogram of an image, like other histograms also shows frequency. But an image histogram, shows
frequency of pixels intensity values. In an image histogram, the x axis shows the gray level intensities
and the y axis shows the frequency of these intensities.
The x axis of the histogram shows the range of pixel values. Since it’s an 8 bpp image that
means it has 256 levels of gray or shades of gray in it. That’s why the range of x axis starts from
0 and end at 255 with a gap of 50. Whereas on the y axis, is the count of these intensities.
As you can see from the graph, that most of the bars that have high frequency lies in the first
half portion which is the darker portion. That means that the image we have got is darker. And
this can be proved from the image too.
Applications of Histograms
Histograms has many uses in image processing. The first use as it has also been discussed above
is the analysis of the image. We can predict about an image by just looking at its histogram. It’s
like looking an x ray of a bone of a body.
The second use of histogram is for brightness purposes. The histograms has wide application in
image brightness. Not only in brightness, but histograms are also used in adjusting contrast of
an image.
And last but not the least, histogram has wide use in thresholding. This is mostly used in
computer vision.
3.3.1 Linear stretching of histograms
Linear stretching the image in 23a produces what is shown in figure 24. The image now takes on
the full 8-bit range, and correspondingly the new histogram is spread out over the range 0-255,
resulting in an image that subjectively looks far better to the human eye. If the original image is
of low-contrast and does not contain much information, stretching the contrast can only
accomplish so much.
Figure 23. : (a) Low contrast Prutah image, (b) Low contrast histogram.
In this method we do not alter basic shape of histogram, but we spread it so as to cover entire
range. We do this by using straight line equation having slope (S max-Smin) /(rmax-rmin).
Where
Smax−Smin
S=T ( r )= ( r−rmin ) + Smin
rmax−rmin
This transformation function shifts and structures the grey level range of input image to occupy the
entire dynamic range (Smax , Smin)
Example.1:
Perform histogram stretching on following image so that the new image has a dynamic image of (0,7)
Grey level 0 1 2 3 4 5 6 7
No. of pixels 0 0 50 60 50 20 10 0
Solution:
Smax−Smin
S= ( r −rmin ) + Smin
rmax−rmin
7−0
¿ ( r−2 )+ 0
6−2
7
S= ( r −2 )
4
∴ for r =2 r =0
r =3 r =1.75≈ 2
r =4 r =3.5≈ 4
r =5 r =5.2≈ 5
r =6 r =7
r =2 0
r =3 2
r =4 4
r =5 5
r =6 7
Modified histogram is
Grey level 0 1 2 3 4 5 6 7
No. of pixels 50 0 60 0 50 20 0 10
Example 2:
Grey level 0 1 2 3 4 5 6 7
No. of pixel 100 90 85 70 0 0 0 0
Perform histogram stretching so that new image has a dynamic range of(0,7)
Solution :
Smax−Smin
S= ( π −πmin )+ Smin
πmax−πmin
7
¿ ( r −0 ) +0
3
∴ for r =0 s=0
r =1 s=2.3≈ 2
r =2 s=4.67 ≈ 5
r =3 s=7
r =0 S=0
r =1 S=2
r =2 S=5
r =3 S=7
Grey level 0 1 2 3 4 5 6 7
No. of pixel 100 0 90 0 0 85 0 70
Example 3:
Given the frequency table.
Grey level 0 1 2 3 4 5 6 7
No. of pixel 0 0 a b c d e 0
Perform linear stretching
Solution:
rmin=2 , rmax=5
Smin=0 smax=7
7
∴ s= ( r−2 )+ 0
( 5−2 )
7
¿ ( r −2 )
3
7
r =1 s= x ( 2.2 )=0
3
r =3 s=2.33≈ 2
r =4 s=4.66 ≈ 5
r =5 s=7
The resultant mapping will be, s=0 corresponding to r =2 there fore. The pixels that have grey level r = 2
in original image have to be mapped to level S=0 in output image.
Modified histogram is
Grey level(rk) 0 1 2 3 4 5 6 7
No. of pixels(pk) 5 0 20 0 0 20 0 19
This technique is similar to is similar to histogram stretch. It tries to flatten the histogram to
create a better quality image. A good image is that which has equal number of pixels in all its
very levels. Histogram equalization method treads image as a probability distribution.
As it name suggest, it gives the probability of each number in the data set or you can say that it
basically gives the count or frequency of each element.
We will calculate PDF from two different ways. First from a matrix , , we have to calculate the
PDF from a matrix , and an image is nothing more then a two dimensional matrix. Then we will
take another example in which we will calculate PDFfrom the histogram.
1 2 7 5 6
Now if we were to calculate the PDF of this matrix, here
7 2 3 4 5 how we are going to do it. At first, we will take the first
value in the matrix , and then we will count , how much
0 1 5 7 3 time this value appears in the whole matrix. After count
they can either be represented in a histogram, or in a
table like this below.
1 2 5 6 7
6 1 0 3 4
0 2 2/25
1 4 4/25
2 3 3/25
3 3 3/25
4 2 2/25
5 4 4/25
6 3 3/25
7 4 4/25
The above histogram shows frequency of gray level values for an 8 bits per pixel image.
Now if we have to calculate its PDF, we will simple look at the count of each bar from vertical
axis and then divide it by total count.
Another important thing to note in the above histogram is that it is not monotonically
increasing. So in order to increase it monotonically, we will calculate its CDF.
CDF is function that calculates the cumulative sum of all the values that are calculated by PDF. It
basically sums the previous one.
HOW IT IS CALCULATED?
We will calculate CDF using a histogram. Here how it is done. Consider the histogram shown
above which shows PMF.
Since this histogram is not increasing monotonically , so will make it grow monotonically.
We will simply keep the first value as it is , and then in the 2nd value , we will add the first one
and so on.
Now as you can see from the graph above , that the first value of PDF remain as it is. The
second value of PDF is added in the first value and placed over 128. The third value of PDF is
added in the second value of CDF , that gives 110/110 which is equal to 1. And also now , the
function is growing monotonically which is necessary condition for histogram equalization.
1) Calculate PDF pk
2) Form the cumulative histogram sk =∑ p r c r
3) Normalize the value by dividing it by total number of pixels.
4) Multiply these values by maximum grey level value and round off the values.
5) Map the original value to the result of step 3 by a one to one corresponds
nk
1) PDF → p r (rk )=
n
Where
4 4 4 4 4
3 4 5 4 3
3 5 5 5 3
3 4 5 4 3
4 4 4 4 4
Gray level 0 1 2 3 4 5 6 7
No. of pixel 0 0 0 6 14 9 0 0
nk
4 4 4 4 4 6 6 6 6 6
[ 3 4
3 5
3 4
4 4
5
5
5
4
4
5
4
4
3
3
3
4
] Histogram
Equalization
[ ]
2
2
2
6
6
7
6
6
7
7
7
6
6
7
6
6
2
2
2
6
New image
Gray level 0 1 2 3 4 5 6 7
No. of pixels 0 0 6 0 0 0 14 5
Gray level. 0 1 2 3 4 5 6 7
= 0 to 7
1200
1023
1000
850
790
800
656
600
400
229 245
200 122 81
0
0 1 2 3 4 5 6 7
600
448
400
200
0
1 2 3 4 5 6 7
Gray level. 0 1 2 3 4 5 6 7
Solution:
120 Gray nk PDF CDF Round off. Modified nk
100
100 level nk 90 S k 7 x sk New gray
Pr =
80 N Level
60
0 100 0.384 0.384 2.688 3 100
50
1 90 0.346 0.73 5.11 5 90
40
2 50 0.1923 0.9223 20 6.456 6 50
20 3 20 0.0769 1 7 7 20
0 4 0 0 1 7 7 20
51 20 3 04 5 16 7 7 7 20
6 0 0 1 7 7 20
7 0 0 1 7 7 20
N=260
Gray level. 0 1 2 3 4 5 6 7
(rk)
No. of 8 10 10 2 12 16 4 2
pixels (pk)
Solution: L =8
Original histogram
18
16
16
14
12
12
10 10
10
8
8
6
4
4
2 2
2
0
0 1 2 3 4 5 6 7
Old Gray Old no. New grey level New no. Of pixels.
level Of
pixels.
0 8 1 0→ 0
1 10 2 1→ 8
2 → 10
2 10 3
3 → 10+2=12
3 2 3
4 → 12
4 12 4
5 → 0
5 16 6
6→ 16
6 4 7
7 → 4+2=6
7 2 7
New Histogram
18
16
14
12
10
8
6
4
2
0
0 1 2 3 4 5 6 7
Gray level. 0 1 2 3
nk 70 20 7 3
Solution:
100
Gray level. 0 1 2 3
nk 0 0 70 30
Gray No. of pixel PDF CDF Sk x 3 Round off Modified
level rk pk grey level
0 0 0 0 0 0
1 0 0 0 0 0
2 70 0.7 0.7 2.1 2 70
3 30 0.3 1 3 3 30
100
Now equalize again
nk 0 0 70 30
Hence, equalizing twice gives us same result i.e.it causes no change in the histogram.
The user has no control over the histogram normalization process. It gives us histogram which
is an approximation to an uniform histogram. Hence it is desirable to have a method in which
certain grey levels are specified. Histogram specification method allows us to exercise control
over the process through the target histogram specification.
Example 1: Given histogram (a) & (b) modify histogram (a) as given by histogram (b)
(a)
Gray level. 0 1 2 3 4 5 6 7
(b)
Gray level. 0 1 2 3 4 5 6 7
4096
Now equalize histogram (b).
No. of pixels
1200
1000
800
600
400
200
0
0 1 2 3 4 5 6 7
Gray level. 0 1 2 3 4 5 6 7
No. of 8 10 10 2 12 16 4 2
pixels
Gray level. 0 1 2 3 4 5 6 7
No. of pixels 0 0 0 0 20 20 16 8
64
4−2 10
[ ]
5−4
6−6
7−7
12
16
6
Mapping
Gray level. 0 1 2 3 4 5 6 7
No. of pixels 0 0 10 0 12 0 16 6
25
20 20
20
15
10
6 7
5
0
0 1 2 3 4 5 6 7
18
16
16
14
12
12
10
10
8
6
6
4
2
0
0 1 2 3 4 5 6 7
Figure 27:
• We can directly design a transfer function H(u,v) and implement the enhancement in the
frequency domain as follows:
Figure 28: Basic steps for filtering in frequency domain
1. The image must be transformed from the spatial domain into the frequency domain using the Fast
Fourier transform.
2. The resulting complex image must be multiplied by a filter (that usually has only real values).
Frequency Bands
Image Fourier Spectrum
g(x,y) G(u,v)
1 D (u , v ) ≤ D0
D ( u , v )=
{
0 D ( u , v ) > D0
D ( u , v )=√ u2 +v 2
D0 = cut-off frequency
H(u,v)
H(u,v)
1
v
u 0 D0 D(u,v)
Convolution Theorm
-1 sinc(x)
H(u,v) h(x,y)
1
H ( u , v )= 2n
D (u , v )
1+ (D0 )
D ( u , v )=√ u2 +v 2
No clear cutoff between passed and filtered frequencies
0.15
1
0.1 0.8
0.6
0.05 0.4
0.2
0 0
0 50 100 -50 0 50
The inverse Fourier transform of a GLPF is also a Gaussian A spatial Gaussian _lter will have no
ringing.
Let σ: measure of the spread of the Gaussian curve. Let σ = D0, then:
Figure 32 : Plot of Gaussian Low pass filter transfer function
D0 = cut-off frequency
D(u; v): distance from a point (u; v) to the origin
H(u,v)
H(u,v)
v 1
u
0 D0
D(u,v)
H(u,v)
H(u,v)
1
0.5
v
u 0 D0 D(u,v)
The inverse Fourier transform of a GLPF is also a Gaussian A spatial Gaussian _lter will have no
ringing.
Figure 37 : Gaussian Highpass Filters: Example