unit-II-key (1)
unit-II-key (1)
2. Write brief introduction about Image Enhancement and histogram Equalization. Write the steps to
obtain Histogram Equalization. Perform Histogram Equalization on the 8*8, eight- level grayscale
image described in Table (1).
Image Enhancement:
Definition:
Image enhancement can be done by Histogram equalization.
Histogram equalization is a technique for adjusting image intensities to enhance contrast.
This method usually increases the global contrast of many images, especially when the usable data of
the image is represented by close contrast values.
Needs of Image Enhancement:
Image enhancement refers to the process of highlighting certain information of an image, as well as
weakening or removing any unnecessary information according to specific needs.
For example, eliminating noise, revealing blurred details, and adjusting levels to highlight features of
an image.
Enhancement methods in image processing:
Histogram equalization.
Noise removal using a Wiener filter.
Linear contrast adjustment.
Median filtering.
Unsharp mask filtering.
Advantage of image enhancement:
Enhancements are used to make it easier for visual interpretation and understanding of imagery.
The advantage of digital imagery is that it allows us to manipulate the digital pixel values in an image.
Histogram :
The Histogram of a digital image with intensity levels in the range [0, L-1] is a discrete function
h(rk )=nk , where rk is the k th intensity value nk is the number of pixels in the image with intensity
value rk .
k varies from 0 to L-1. L is the total number of Gray levels.
Normalized Histogram:
Normalized Histogram divide the number of pixels of each gray value (also called as intensity) by the
total number of pixels in the given image.
1/23/2019 3 Normalized histogram ( ) : the number of pixels in the image of size M N with intensity k
kkknprM
Histogram Equalization:
Histogram Equalization is a computer image processing technique used to improve contrast in images .
1
It accomplishes this by effectively spreading out the most frequent intensity values, i.e. stretching out
the intensity range of the image.
Histogram Processing:
Histogram may be viewed graphically as plot of nk versus rk or p(rk ) versus rk
(p(rk )=nk /M*N if the values are normalized
where rk - intensity value k • p(rk ) – probability of intensity value k
M*N – dimension of the input image
k=0,1,2,3,…………..L-1
p(rk ) is an estimate of the probability of occurrences of intensity value rk in an image • Sum of all
components of a normalized Histogram is equal to 1.
Histograms are the basis for numerous spatial domain processing techniques.
Histogram manipulation can be used for
Image Enhancement
Image Compression
Image Segmentation
Histogram Equalization:
Histogram Equalization is an intensity transformation method, which performs image enhancement.
We can develop a transformation function that can automatically achieves high dynamic range, based
only on the information available in the histogram.
The transformation (or mapping) function T(rk ) is called H.E or Histogram linearized transformation.
In Histogram Equalization, the Histogram statistics are used to obtain the high dynamic range of gray
levels in an image.
H.E is a point processing technique.
2
Discrete histogram equalization:
Histogram equalization is a technique for adjusting image intensities to enhance contrast.
Let f be a given image represented as a mr by mc matrix of integer pixel intensities ranging. from 0 to
L − 1. L is the number of possible intensity values, often 256.
Steps in histogram equalization:
Compute the histogram of the image.
Calculate the normalized sum of histogram.
Transform the input image to an output image.
Application of histogram equalization:
Histogram equalization is a straightforward image-processing technique often used to achieve better
quality images in black and white color scales in medical applications such as digital X-rays, MRIs,
and CT scans.
5. Describe in detail the various Spatial Domain filters used for Image Smoothing. (NOTE:
Introduction, Specifying its function, Diagram of Perspective plot, Diagram of filter displayed as an
image, Diagram of Filter radial cross section and also drawbacks of each filter must be present in your
answer) (Page no.152 to 157)
SPATIAL DOMAIN FILTERS USED FOR IMAGE SMOOTHING
Image Smoothing:
Image smoothing is a digital image processing technique that reduces and suppresses image noises.
In the spatial domain, neighborhood averaging can generally be used to achieve the purpose of
smoothing.
Commonly seen smoothing filters include average smoothing, Gaussian smoothing, and adaptive
smoothing.
Methods used in Image Smoothing:
It is used as a method of smoothing images, reducing the amount of intensity variation between one
pixel and the next resulting in reducing noise in images.
Spatial Domain Filter:
3
It refers to image operators that change the gray value at any pixel (x,y) depending on the pixel
values in a square neighborhood centered at (x,y) using a fixed integer matrix of the same size.
The integer matrix is called a filter, mask, kernel or a window.
Smoothing Spatial Filter:
Smoothing filter is used for blurring and noise reduction in the image.
Blurring is pre-processing steps for removal of small details and Noise Reduction is accomplished
by blurring.
Filtering in the spatial domain (Spatial Filtering)
refers to image operators that change the gray value at any pixel (x,y) depending on the pixel values in a
square neighborhood centered at (x,y) using a fixed integer matrix of the same size. The integer matrix is
called a filter , mask, kernel or a window.
The mechanism of spatial filtering, shown below, consists simply of moving the filter mask from
pixel to pixel in an image. At each pixel (x,y), the response of the filter at that pixel is calculated using a
predefined relationship (linear or nonlinear).
Note:
Figure 6.1 Spatial filtering
The size of mask must be odd (i.e. 3×3, 5×5, etc.) to ensure it has a center. The smallest meaningful
size is 3×3.
Linear Spatial Filtering (Convolution)
The process consists of moving the filter mask from pixel to pixel in an image. At each pixel (x,y), the
response is given by a sum of products of the filter coefficients and the corresponding image pixels in the
area spanned by the filter mask.
w(1,1)ƒ(𝑥 + 1, 𝑦 + 1)
In general, linear filtering of an image f of size M×N with a filter mask of size m×n is given by the
𝑎 𝑏
expression:
4
Nonlinear Spatial Filtering
The operation also consists of moving the filter mask from pixel to pixel in an image. The filtering
operation is based conditionally on the values of the pixels in the neighborhood, and they do not explicitly
use coefficients in the sum-of-products manner.
For example, noise reduction can be achieved effectively with a nonlinear filter whose basic
function is to compute the median gray-level value in the neighborhood in which the filter is located.
Computation of the median is a nonlinear operation.
Example:
Use the following 3×3mask to perform the convolution process on the shaded pixels in the 5×5 image
below. Write the filtered image.
0 1/6 0 30 40 50 70 90
1/6 1/3 1/6 40 50 80 60 100
0 1/6 0 35 255 70 0 120
3×3 mask 30 45 80 100 130
40 50 90 125 140
5×5 image
30 40 50 70 90
Filtered image = 40 85 65 61 100
35 118 92 58 120
30 84 77 89 130
40 50 90 125 140
Spatial Filters
Spatial filters can be classified by effect into:
1. Smoothing Spatial Filters: also called lowpass filters. They include:
5
1.1 Averaging linear filters
1.2 Order-statistics nonlinear filters.
2. Sharpening Spatial Filters: also called highpass filters. For example, the Laplacian linear filter.
6. Describe in detail the various Spatial Domain filters used for Image Sharpening. (NOTE:
Introduction, Specifying its function, Diagram of Perspective plot, figure of filter displayed as an image,
figure of Filter radial cross section and also drawbacks of each filter – All these must be present in your
answer) (Page no.157 to 168)
1 1 1 1 2 1
1
1 1 1 1 2 4 2
× ×
1 1 1 1 2 1
9 16
Averaging linear filtering of an image f of size M×N with a filter mask of size m×n is given by the
expression:
6
To generate a complete filtered image this equation must be applied for x = 0,1, 2,..., M-1 and y = 0,1,
2,..., N-1.
(a) (b)
(c) (d)
(e) (f)
Figure 6.2 Effect of averaging filter. (a) Original image. (b)-(f) Results of smoothing with square averaging
filter masks of sizes n = 3,5,9,15, and 35, respectively.
As shown in the figure, the effects of averaging linear filter are:
1. Blurring which is increased whenever the mask size increases.
2. Blending (removing) small objects with the background. The size of the mask establishes the
relative size of the blended objects.
3. Black border because of padding the borders of the original image.
4. Reduced image quality.
Order-statistics filters
are nonlinear spatial filters whose response is based on ordering (ranking) the pixels contained in the
neighborhood, and then replacing the value of the center pixel with the value determined by the ranking
result.
Examples include Max, Min, and Median filters.
Median filter
It replaces the value at the center by the median pixel value in the neighborhood, (i.e. the middle
7
element after they are sorted). Median filters are particularly useful in removing impulse noise (also
known as salt-and-pepper noise). Salt = 255, pepper = 0 gray levels.
In a 3×3 neighborhood the median is the 5th largest value, in a 5×5 neighborhood the 13th largest
value, and so on.
For example, suppose that a 3×3 neighborhood has gray levels (10, 20, 0, 20, 255, 20, 20, 25, 15).
These values are sorted as (0,10,15,20,20,20,20,25,255), which results in a median of 20 that replaces the
original pixel value 255 (salt noise).
Example:
Consider the following 5×5 image:
20 30 50 80 100
30 20 80 100 110
25 255 70 0 120
30 30 80 100 130
40 50 90 125 140
Apply a 3×3 median filter on the shaded pixels, and write the filtered image.
Solution
example of applying the median filter on an image corrupted with salt-and-pepper noise.
the effects of median filter are:
1. Noise reduction
2. Less blurring than averaging linear filter
Sharpening Spatial Filters
Sharpening aims to highlight fine details (e.g. edges) in an image, or enhance detail that has been blurred
through errors or imperfect capturing devices.
Image blurring can be achieved using averaging filters, and hence sharpening can be achieved by operators
that invert averaging operators. In mathematics, averaging is equivalent to the concept of integration, and
differentiation inverts integration. Thus, sharpening spatial filters can be represented by partial derivatives.
8
Partial derivatives of digital functions
We conclude that:
1st derivative detects thick edges while 2nd derivative detects thin edges.
2nd derivative has much stronger response at gray-level step than 1st derivative.
Thus, we can expect a second-order derivative to enhance fine detail (thin lines, edges, including noise)
much more than a first-order derivative.
The Laplacian Filter
A Laplacian filter is an edge detector used to compute the second derivatives of an image, measuring
the rate at which the first derivatives change. This determines if a change in adjacent pixel values is from
an edge or continuous progression.
The Laplacian operator of an image f(x,y) is:
2 ∂2ƒ ∂2ƒ
9
∇ ƒ= +
∂𝑥2 ∂𝑦2
7. Describe in detail the various Frequency Domain filters used for Image Smoothing. (NOTE:
Introduction, Specifying its function, Diagram of Perspective plot, Diagram of filter displayed as an image,
Diagram of Filter radial cross section and also drawbacks of each filter must be present in your answer)
(Page no.269 to 277)
10
Ideal Lowpass Filter (ILPF) is used for image smoothing in the frequency domain. It removes high-
frequency noise from a digital image and preserves low-frequency components. from the origin without
attenuation and cuts off all the frequencies outside the circle
Cuts off all high-frequency components at a distance greater than a certain distance
from origin (cutoff frequency).
H (u,v) = 1, if D(u,v) ≤
D0 0, if D(u,v) ˃
D0
Where D0 is a positive constant and D(u,v) is the distance between a point (u,v) in the
frequency domain and the center of the frequency rectangle; that is
D(u,v) = [(u-P/2)2 + (v-Q/2)2] 1/2
Where as P and Q are the padded sizes from the basic equations
Wraparound error in their circular convolution can be avoided by padding these
functions with zeros,
VISUALIZATION: IDEAL LOW PASS FILTER:
Aa shown in fig.below
Fig: ideal low pass filter 3-D view and 2-D view and line graph.
EFFECT OF DIFFERENT CUT OFF FREQUENCIES:
Fig.below(a) Test pattern of size 688x688 pixels, and (b) its Fourier spectrum. The spectrum is
double the image size due to padding but is shown in half size so that it fits in the page. The
superimposed circles have radii equal to 10, 30, 60, 160 and 460 with respect to the full-size
spectrum image. These radii enclose 87.0, 93.1, 95.7, 97.8 and 99.2% of the padded image
power respectively.
Fig: (a) Test patter of size 688x688 pixels (b) its Fourier spectrum
11
Fig: (a) original image, (b)-(f) Results of filtering using ILPFs with cutoff frequencies
set at radii values 10, 30, 60, 160 and 460, as shown in fig.2.2.2(b). The power removed by
these filters was 13, 6.9, 4.3, 2.2 and 0.8% of the total, respectively.
As the cutoff frequency decreases,
image becomes more blurred
Noise becomes increases
Analogous to larger spatial filter sizes
The severe blurring in this image is a clear indication that most of the sharp detail information
in the picture is contained in the 13% power removed by the filter. As the filter radius is
increases less and less power is removed, resulting in less blurring. Fig. (c ) through (e) are
characterized by “ringing” , which becomes finer in texture as the amount of high frequency
content removed decreases.
WHY IS THERE RINGING?
Ideal low-pass filter function is a rectangular function
The inverse Fourier transform of a rectangular function is a sinc function.
12
Fig. Spatial representation of ILPFs of order 1 and 20 and corresponding intensity profiles through the center
of the filters( the size of all cases is 1000x1000 and the cutoff frequency is 5), observe how ringing increases
Transfer function does not have sharp discontinuity establishing cutoff between passed
and filtered frequencies.
Cut off frequency D0 defines point at which H(u,v) = 0.5
Fig. (a) perspective plot of a Butterworth lowpass-filter transfer function. (b) Filter
displayed as an image. (c)Filter radial cross sections of order 1 through 4.
Unlike the ILPF, the BLPF transfer function does not have a sharp discontinuity that
gives a clear cutoff between passed and filtered frequencies.
BUTTERWORTH LOW-PASS FILTERS OF DIFFEREN T FREQUENCIES:
Fig. (a) Original image.(b)-(f) Results of filtering using BLPFs of order 2, with cutoff
frequencies at the radii
Fig. shows the results of applying the BLPF of eq. to fig.(a), with n=2 and D0 equal to
the five radii in fig.(b) for the ILPF, we note here a smooth transition in blurring as a function
of increasing cutoff frequency. Moreover, no ringing is visible in any of the images processed
with this particular BLPF, a fact attributed to the filter’s smooth transition between low and
13
high frequencies.
A BLPF of order 1 has no ringing in the spatial domain. Ringing generally is
imperceptible in filters of order 2, but can become significant in filters of higher order.
Fig.shows a comparison between the spatial representation of BLPFs of various orders
(using a cutoff frequency of 5 in all cases). Shown also is the intensity profile along a
horizontal scan line through the center of each filter. The filter of order 2 does show mild
ringing and small negative values, but they certainly are less pronounced than in the ILPF. A
butter worth filter of order 20 exhibits characteristics similar to those of the ILPF (in the limit,
both filters are identical).
Fig.2.2.7 (a)-(d) Spatial representation of BLPFs of order 1, 2, 5 and 20 and
corresponding intensity profiles through the center of the filters (the size in all cases is 1000 x
1000 and the cutoff frequency is 5) Observe how ringing increases as a function of filter order.
GAUSSIAN LOWPASS FILTERS:
The form of these filters in two dimensions is given by
14
Fig. (a) Perspective plot of a GLPF transfer function. (b) Filter displayed as an
image. (c). Filter radial cross sections for various values of D0
Fig.(a) Original image. (b)-(f) Results of filtering using GLPFs with cutoff frequencies
at the radii shown in fig.2.2.2. compare with fig.2.2.3 and fig.2.2.6
15
Fig. (a) Original image (784x 732 pixels). (b) Result of filtering using a GLPF with D0 =
100. (c) Result of filtering using a GLPF with D0 = 80. Note the reduction in fine skin lines in
the magnified sections in (b) and (c).
Fig. shows an application of lowpass filtering for producing a smoother, softer-looking
result from a sharp original. For human faces, the typical objective is to reduce the sharpness of
fine skin lines and small blemished.
8. Describe in detail the various Frequency Domain filters used for Image Sharpening. (NOTE:
Introduction, Specifying its function, Diagram of Perspective plot, figure of filter displayed as an image,
figure of Filter radial cross section and also drawbacks of each filter – All these must be present in your
answer) (Page no.280 to 286)
16
Where Hlp (u,v) is the transfer function of the low-pass filter. That is when the low-pass
filter attenuates frequencies, the high-pass filter passed them, and vice-versa.
We consider ideal, Butter-worth, and Gaussian high-pass filters. As in the previous
section, we illustrate the characteristics of these filters in both the frequency and spatial
domains. Fig.. shows typical 3-D plots, image representations and cross sections for these
filters. As before, we see that the Butter-worth filter represents a transition between the
sharpness of the ideal filter and the broad smoothness of the Gaussian filter. Fig.discussed in
the sections the follow, illustrates what these filters look like in the spatial domain. The spatial
filters were obtained and displayed by using the procedure used.
Fig: Top row: Perspective plot, image representation, and cross section of a typical ideal
high-pass filter. Middle and bottom rows: The same sequence for typical butter-worth and
Gaussian high-pass filters.
IDEAL HIGH-PASS FILTER:
A 2-D ideal high-pass filter (IHPF) is defined as
H (u,v) = 0, if D(u,v) ≤
D0 1, if D(u,v) ˃ D0
Where D0 is the cutoff frequency and D(u,v) is given by eq. As intended, the IHPF is
the opposite of the ILPF in the sense that it sets to zero all frequencies inside a circle of radius
D0 while passing, without attenuation, all frequencies outside the circle. As in case of the
ILPF, the IHPF is not physically realizable.
SPATIAL REPRESENTATION OF HIGHPASS FILTERS:
17
Fig.. Spatial representation of typical (a) ideal (b) Butter-worth and (c) Gaussian
frequency domain high-pass filters, and corresponding intensity profiles through their centers.
We can expect IHPFs to have the same ringing properties as ILPFs. This is
demonstrated clearly in Fig.. which consists of various IHPF results using the original image in
Fig.(a) with D0 set to 30, 60,and 160 pixels, respectively. The ringing in Fig. (a) is so severe
that it produced distorted, thickened object boundaries (e.g.,look at the large letter “a” ). Edges
of the top three circles do not show well because they are not as strong as the other edges in the
image (the intensity of these three objects is much closer to the background intensity, giving
discontinuities of smaller magnitude).
FILTERED RESULTS: IHPF:
Fig.. Results of high-pass filtering the image in Fig.(a) using an IHPF with D 0 = 30, 60,
and 160.
The situation improved somewhat with D0 = 60. Edge distortion is quite evident still,
but now we begin to see filtering on the smaller objects. Due to the now familiar inverse
relationship between the frequency and spatial domains, we know that the spot size of this filter
is smaller than the spot of the filter with D0 = 30. The result for D0 = 160 is closer to what a
high-pass filtered image should look like. Here, the edges are much cleaner and less distorted,
and the smaller objects have been filtered properly.
Of course, the constant background in all images is zero in these high-pass filtered
images because highpass filtering is analogous to differentiation in the spatial domain.
BUTTER-WORTH HIGH-PASS FILTERS:
Butterworth Highpass Filter (BHPF) is used for image sharpening in the frequency domain. Image
Sharpening is a technique to enhance the fine details and highlight the edges in a digital image. It removes
low-frequency components from an image and preserves high-frequency components.
A 2-D Butter-worth high-pass filter (BHPF) of order n and cutoff frequency D0 is defined as
Where D(u,v) is given by Eq.(3). This expression follows directly from Eqs.(3) and (6). The
middle row of Fig.2.2.11. shows an image and cross section of the BHPF function.
Butter-worth high-pass filter to behave smoother than IHPFs. Fig.2.2.14.shows the
performance of a BHPF of order 2 and with D0 set to the same values as in Fig.2.2.13. The
boundaries are much less distorted than in Fig.2.2.13. even for the smallest value of cutoff
18
frequency.
FILTERED RESULTS: BHPF:
Fig. Results of high-pass filtering the image in Fig.2.2.2(a) using a BHPF of order 2
with D0 = 30, 60, and 160 corresponding to the circles in Fig.2.2.2(b). These results are much
smoother than those obtained with an IHPF.
GAUSSIAN HIGH-PASS FILTERS:
The transfer function of the Gaussian high-pass filter(GHPF) with cutoff frequency
locus a distance D0 from the center of the frequency rectangle is given by
at
Where D(u,v) is given by Eq.(4). This expression follows directly from Eqs.(2) and (6).
The third row in Fig.2.2.11. shows a perspective plot, image and cross section of the GHPF
function. Following the same format as for the BHPF, we show in Fig.2.2.15. comparable
results using GHPFs. As expected, the results obtained are more gradual than with the previous
two filters.
FILTERED RESULTS:GHPF:
Fig. Results of high-pass filtering the image in fig.(a) using a GHPF with D0 = 30,
60 and 160, corresponding to the circles in Fig.(b).
1. Explain the following
a. Image Negatives
b. Log transformation
c. Power law Transformation
19
d. Piecewise Linear Transformation
i. Contrast stretching
ii. Grey level slicing
iii. Bit plane slicing
i. Contrast Stretching
Low contrast images occur often due to poor or non uniform lighting conditions, or due
to nonlinearity, or small dynamic range of the imaging sensor. In the figure of Example 1 above
you have seen a typical contrast stretching transformation
ii.Grey Level Slicing:
Grey level slicing is equivalent to band pass filtering. It manipulates group of intensity
levels in an image up to specific range by diminishing rest or by leaving them alone
This technique is used to highlight a specific. range of gray levels in a given image.
iii.Bit-Plane Slicing:
Bit plane slicing is a method of representing an image with one or more bits of the byte
used for each pixel. One can use only MSB to represent the pixel, which reduces the original gray
level to a binary image.
--------------------------------------------------------------------------------------------------------------------------
--
20
UNIT-III
1. Describe in detail the Various Important Noise Probability Density Functions used for
mathematical modeling of noises in Image Processing Applications.
(NOTE: Introduction, Specifying its PDF, Graph of each PDF and suitable filter to remove each noise – All
these must be present in your answer) (Page no. 314 to 319 in textbook)
Noise Model:
The principal source of noise in digital images arises during image acquisition and
/or transmission. The performance of imaging sensors is affected by a variety of factors,
such as environmental conditions during image acquisition and by the quality of the
sensing elements themselves.
Images are corrupted during transmission principally due to interference in the
channels used for transmission. Since main sources of noise presented in digital images
are resulted from atmospheric disturbance and image sensor circuitry, following
assumptions can be made i.e. the noise model is spatial invariant (independent of spatial
location). The noise model is uncorrelated with the object function.
Gaussian Noise:
Gaussian noise occurs as a result of sensor limitations during image acquisition under low-
light conditions, which make it difficult for the visible light sensors to efficiently capture details of the scene.
These noise models are used frequently in practices because of its tractability in both
spatial and frequency domain.
The PDF of Gaussian random variable is
Where z represents the gray level, μ= mean of average value of z, σ= standard deviation.
21
Rayleigh Noise:
The Rayleigh distribution is a continuous probability distribution for positive valued random
variables. It is often observed when the magnitude of a vector is related to its directional components
Unlike Gaussian distribution, the Rayleigh distribution is no symmetric. It is given by the
formula.
The mean and variance of this density is
22
Its shape is similar to Rayleigh disruption. This equation is referred to as gamma density
it is correct only when the denominator is the gamma function.
(iv) Exponential Noise:
Exponential distribution has an exponential shape. The PDF of exponential noise is given as
Where a>0. The mean and variance of this density are given by
23
(vi) Impulse (salt & pepper) Noise:
Salt and pepper noise refers to a wide variety of processes that result in the same basic image
degradation
Salt-and-pepper noise, also known as impulse noise, is a form of noise sometimes seen on digital
images. This noise can be caused by sharp and sudden disturbances in the image signal.
It presents itself as sparsely occurring white and black pixels.
In this case, the noise is signal dependent, and is multiplied to the
image. The PDF of bipolar (impulse) noise is given by
If b>a, gray level b will appear as a light dot in image. Level a will appear like a dark dot.
2. Describe the various spatial filters used for restoration of images in the presence of noise only.
(Page no.322 to 330) (OR) Write in detail about the Mean filters and various Order Static Filters for
‘order’ and ‘statistic’, Specify 𝑓 for each filter, draw graph of each PDF and mention one
removing noise to restore images. (NOTE: Introduction, Mention the reason for calling it as
application of each filter - All these must be present in your answer) (Page no.322 to 330)
i) Mean Filter:
(a)Arithmetic Mean filter:
It is the simplest mean filter. Let Sxy represents the set of coordinates in the sub image of size m*n centered at
point (x,y). The arithmetic mean filter computes the average value of the corrupted image g(x,y) in the area
24
defined by Sxy. The value of the restored image f at any point (x,y) is the arithmetic mean computed using the
pixels in the region defined by Sxy.
This operation can be using a convolution mask in which all coefficients have value
1/mn A mean filter smoothes local variations in image Noise is reduced as a result of
blurring. For every pixel in the image, the pixel value is replaced by the mean value of its
neighboring pixels with a weight .This will resulted in a smoothing effect in the image
. (b)Geometric Mean filter:
An image restored using a geometric mean filter is given by the expression
Here, each restored pixel is given by the product of the pixel in the sub image window,
raised to the power 1/mn. A geometric mean filters but it to loose image details in the
process.
(c) Harmonic Mean filter:
The harmonic mean filtering operation is given by the expression
The harmonic mean filter works well for salt noise but fails for pepper noise. It does well
with Gaussian noise also.
(d) Order statistics filter:
Order statistics filters are spatial filters whose response is based on ordering the pixel
contained in the image area encompassed by the filter. The response of the filter at any
point is determined by the ranking result.
(e) Median filter:
It is the best order statistic filter; it replaces the value of a pixel by the median of gray
levels in the Neighborhood of the pixel.
The original of the pixel is included in the computation of the median of the filter are
quite possible because for certain types of random noise, the provide excellent noise
reduction capabilities with considerably less blurring then smoothing filters of similar
size. These are effective for bipolar and unipolor impulse noise.
(e) Max and Min filter:
Using the l00th percentile of ranked set of numbers is called the max filter and is given by
the equation
It is used for finding the brightest point in an image. Pepper noise in the image has very
low values, it is reduced by max filter using the max selection process in the sublimated
25
area sky. The 0th percentile filter is min filter.
This filter is useful for flinging the darkest point in image. Also, it reduces salt noise of
the min operation.
(f) Midpoint filter:
The midpoint filter simply computes the midpoint between the maximum and minimum
values in the area encompassed by
It comeliness the order statistics and averaging .This filter works best for
3. Discuss in detail about Adaptive filters (Adaptive, local noise reduction filter and
Adaptive median filter. Mention their advantages. (Page no.330 to 334)
4. Explain Band Reject Filters and Band Pass Filters for periodic noise reduction for image
restoration. (Page no.335 to 337)
Periodic Noise by Frequency domain filtering:
These types of filters are used for this purpose-
Band Reject Filters:
It removes a band of frequencies about the origin of the Fourier transformer.
Ideal Band reject Filter:
An ideal band reject filter is given by the expression
26
D(u,v)- the distance from the origin of the centered frequency
rectangle. W- the width of the band
Do- the radial center of the frequency rectangle.
Butterworth Band reject Filter:
These filters are mostly used when the location of noise component in the frequency
domain is known. Sinusoidal noise can be easily removed by using these kinds of filters
because it shows two impulses that are mirror images of each other about the origin. Of
the frequency transform.
These filters cannot be applied directly on an image because it may remove too much details of an image but
these are effective in isolating the effect of an image of selected frequency bands.
Notch Filters:
Definition:
Uses:
It is used to remove repetitive "Spectral" noise from an image. are like a narrow
highpass filter, but they "notch" out frequencies other than the dc component. attenuate a
27
selected frequency (and some of its neighbors) and leave other frequencies of the Fourier
transform relatively unchanged.
A notch filter rejects (or passes) frequencies in predefined neighborhoods about a
center frequency.
Due to the symmetry of the Fourier transform notch filters must appear in
symmetric pairs about the origin.
The transfer function of an ideal notch reject filter of radius D0 with centers a (u0 , v0)
and by symmetry at (-u0 , v0) is
29
30
DeMerits of Invisible filter:
Inverse filter is a high pass filter, it does not perform well in the presence of noise.
7. Explain Weiner filtering in detail. (NOTE: All the formulae must be present in your answer)
Weiner Filter:
The Wiener filter is the MSE-optimal stationary linear filter for images degraded by
additive noise and blurring. Calculation of the Wiener filter requires the assumption that the signal
and noise processes are second-order stationary.
Use of Wiener filter:
It removes the additive noise and inverts the blurring simultaneously. The Wiener filtering
is optimal in terms of the mean square error. In other words, it minimizes the overall mean square error
in the process of inverse filtering and noise smoothing. The Wiener filtering is a linear estimation of
the original image.
31
Wiener filter is used mainly in the signal processing devices,to produce a estimated or target
random process by the linear time-invariant filtering methods of any bserved noisy procedures. That's
why it is far more energy efficient and productive than the inverse filter.
Disadvantage of Wiener Filter:
❖ It is difficult to estimate the power spectra.
❖ It is very difficult to obtain a perfect restoration for the random nature of the noise.
❖ Wiener filters are comparatively slow to apply since they require working in the frequency domain.
Applications of Wiener filtering:
The Wiener filter has a variety of applications in signal processing, image processing, control
systems, and digital communications
32
33
UNIT-4
1. Compare lossy and lossless compression techniques with an example.
IMAGE COMPRESSION:
Image compression deals with reducing the amount of data required to represent a digital image by
removing of redundant data.
COMPRESSION METHODS OF IMAGES:
Compression methods can be lossy, when a tolerable degree of deterioration in the visual quality of the
resulting image is acceptable, or lossless, when the image is encoded in its full quality.
The overall results of the compression process, both in terms of storage savings – usually expressed
numerically in terms of compression ratio (CR) or bits per pixel (bpp) – as well as resulting quality loss (for
the case of lossy techniques) may vary depending on the technique, format, options (such as the quality setting
for JPEG), and the image contents.
As a general guideline, lossy compression should be used for general purpose photographic images.
whereas lossless compression should be preferred when dealing with line art, technical drawings, cartoons,
etc. or images in which no loss of detail may be tolerable (most notably, space images and medical images).
IMAGE COMPRESSION:
Image compression is a process which on implementation gives output which is often smaller in size
but looks similar to the original. The block diagram of image coding system is shown in below:
35
As shown in Fig.3, this prediction – transformation – decomposition process is completely reversible. There is
loss of information due to process of quantization. The entropy coding after the quantizing, is lossless. When
decoder has input data, entropy decoding is applied to compressed signal values to get the quantized signal
values. Then, de-quantization is used on it and the image is recovered which resembles to the original [5].
Lossy compression methods include some basic consideration (performance wise):
1. Speed of encoding and decoding
2. Compression ratio
3. SNR ratio.
Lossy compression includes following methods:
1. Block truncation coding
2. Code Vector quantization
3. Fractal coding
4. Transform coding
5. Sub-band coding
Lossy Techniques:
Block Truncation Coding
In this, image is divided into blocks like we have in fractals. The window of N by N of an image is
considered as a block. The mean value of all values of that window consisting a certain number of pixel. The
threshold is normally the mean value of the pixel values in the vector. Then a bitmap of that vector is
generated by replacing all pixels having values are greater than or equal to the threshold by a 1. Then for each
segment in the bitmap, a value is determined which is the average of the values of the corresponding pixels in
the original code vector.
Code Vector Quantization
The basic idea in Vector Quantization is to create a dictionary of vectors of constant size, called code
vectors. Values of pixels composed the blocks called as code vector. A given image is then parted into non-
recurring vectors called image vectors. Dictionary is made out this information and it is indexed. Further, it is
used for encoding the original image. Thus, every image is then entropy coded with the help of these indices.
Fractal Compression
The basic thing behind this coding is to divide image into segments by using standard points like color
difference, edges, frequency and texture. It is obvious that parts of an image and other parts of the same image
are usually resembling. Here, there is a dictionary which is used as a look up table called as fractal segments.
The library contains codes which are compact sets of numbers. Doing an algorithm operation, fractals are
operated and image is encoded. This scheme is far more effective for compressing images that are natural and
textured.
Transform Coding
In this coding, transforms like Discrete Fourier Transform (DFT) and Discrete Cosine Transform
(DCT), Discrete Sine Transform are used to alter the pixel specifications from spatial domain into frequency
domain. One is the energy compaction property, some few coefficients only have the energy of original image
signal that can be used to reproduce itself. Only those few significant coefficients are considered and the
36
remaining is discarded. These coefficients are given for quantization and encoding. DCT coding has been the
most commonly used in transformation of image data.
Subband Coding
In this scheme, quantization and coding is applied to each of the analyzed sub-bands from the
frequency components bands. This coding is very useful because quantization and coding is more accurately
applied to the sub-bands.
Lossless Compression Techniques
It is also known as entropy coding as it uses decomposition techniques to minimize loopholes. The
original image can be perfectly recovered from the compressed image, in lossless compression techniques.
These do not add noise to the signal. It is also known as entropy coding as it uses decomposition techniques to
minimize redundancy. Following techniques are included in lossless compression [6]:
1. Huffman encoding
2. Run length encoding
3. LZW coding
4. Area coding
37
38
2. (i) Given a four-symbol source {a, b, c, d} with source probabilities {0.1, 0.4, 0.3, 0.2}, encode the
sequence
‘bab’ using Arithmetic Encoding.
39
(ii) The Arithmetic Decoding process is the reverse process of the encoding procedure. Decode the
message
0.23355 given the coding model below.
Symbol Probabilit
y
a 0.2
e 0.3
i 0.1
o 0.2
u 0.1
! 0.1
Explain in detail LZW Coding. Use LZW to encode the message ABBABAS.
LZW CODING:
The technique, called Lempel-Ziv-Welch (LZW) coding, assigns fixedlength code words to variable
length sequences of source symbols but requires no a priori knowledge of the probability of occurrence of the
symbols to be encoded.
LZW compression has been integrated into a variety of mainstream imaging file formats, including
the graphic interchange format (GIF), tagged image file format (TIFF), and the portable document format
(PDF).
LZW coding is conceptually very simple (Welch [1984]). At the onset of the coding process, a
codebook or "dictionary" containing the source symbols to be coded is constructed. For 8-bit monochrome
images, the first 256 words of the dictionary are assigned to the gray values 0, 1, 2..., and 255.
As the encoder sequentially examines the image's pixels, graylevel sequences that are not in the
dictionary are placed in algorithmically determined (e.g., the next unused) locations. If the first two pixels of
the image are white, for instance, sequence “255- 255” might be assigned to location 256, the address
following the locations reserved for gray levels 0 through 255.
The next time that two consecutive white pixels are encountered, code word 256, the address of the
location containing sequence 255-255, is used to represent them.
If a 9-bit, 512- word dictionary is employed in the coding process, the original (8 + 8) bits that were
used to represent the two pixels are replaced by a single 9-bit code word.
Cleary, the size of thedictionary is an important system parameter. If it is too small, the detection of
matching gray-level equences will be less likely; if it is too large, the size of the code words will adversely
affect compression performance. Consider the following 4 x 4, 8-bit image of a vertical edge:
40
Main applications of LZW coding:
For the ILZW algorithm, three methods are used to improve compression effect: increasing the
capacity of dictionary, storage with variable length code and using the Hash function to find strings.
41
The 15A code generated to represent the character string is called an RLE packet. Here, the first byte, 15, is
the run count and contains the number of repetitions. The second byte, A, is the run value and contains the
actual repeated value in the run.
A new packet is generated each time the run character changes, or each time the number of characters in the
run exceeds the maximum count. Assume that our 15-character string now contains four different character
runs:
AAAAAAbbbXXXXXt
Using run-length encoding this could be compressed into four 2-byte packets:
6A3b5X1t
Variants on Run-Length Encoding:
JPEG uses a variant of run-length encoding in a diagonal pattern over the data produced by
quantization. The variant is that only the length of runs of zero values are encoded -- all other values are
encoded as themselves.
Some examples of well-known variable-length coding strategies are Huffman coding, Lempel–Ziv
coding, arithmetic coding, and context-adaptive variable-length coding.
42
Bit-Level RLE SCHEME:
A typical bit-level RLE scheme encodes runs of one to 128 bits in length in a single-byte packet. The seven
least significant bits contain the run count minus one, and the most significant bit contains the value of
the bit run, either 0 or 1
Byte-Level RLE Scheme:
Byte-level RLE schemes encode runs of identical byte values, ignoring individual bits and word
boundaries within a scan line. The most common byte-level RLE scheme encodes runs of bytes into 2-
byte packets. The first byte contains the run count of 0 to 255, and the second byte contains the value
of the byte run.
Pixel-Level RLE Scheme:
43
Pixel-level RLE schemes are used when two or more consecutive bytes of image data are used to
store single pixel values. At the pixel level, bits are ignored, and bytes are counted only to identify each
pixel value. Encoded packet sizes vary depending upon the size of the pixel values being encoded.
5. Write the steps to obtain Huffman code. Is it Lossy or losseless technique? Is it uniquely
decodable or not?
Huffman Code:
Huffman coding is a method of data compression that is independent of the data type, that is, the
data could represent an image, audio or spreadsheet. This compression scheme is used in JPEG and
MPEG-2. Huffman coding works by looking at the data stream that makes up the file to be compressed.
Steps to obtain in Huffman Code:
Step 1 :. If the Image is in .bmp format, then the Image can be read into the 2D array, by using this
code given in this...
Step 2. Define a struct which will contain the pixel intensity values ( pix ), their corresponding
probabilities ( freq...
Step 3. Define another Struct which will contain the pixel intensity values ( pix ), their
corresponding probabilities (...
Step 4. Declaring an array of structs. Each element of the array corresponds to a node in the
Huffman Tree.
Initialize the two arrays pix_freq and huffcodes with information of the leaf nodes.
44
Sorting the huffcodes array according to the probability of occurrence of the pixel intensity
values
Building the Huffman Tree
Backtrack from the root to the leaf nodes to assign code words
Encode the Image
Huffman coding is lossless data compression algorithm. In this algorithm a variable-length code is
assigned to input different characters. The code length is related with how frequently characters are used.
Most frequent characters have smallest codes, and longer codes for least frequent characters.
There are mainly two parts. First one to create Huffman tree, and another one to traverse the tree to
find codes.
For an example, consider some strings “YYYZXXYYX”, the frequency of character Y is larger than X
and the character Z has least frequency. So the length of code for Y is smaller than X, and code for X will be
smaller than Z.
Complexity for assigning code for each character according to their frequency is O(n log n)
Input − A string with different characters, say “ACCEBFFFFAAXXBLKE”
Output − Code for different characters:
Data: K, Frequency: 1, Code: 0000
Data: L, Frequency: 1, Code: 0001
Data: E, Frequency: 2, Code: 001
Data: F, Frequency: 4, Code: 01
Data: B, Frequency: 2, Code: 100
Data: C, Frequency: 2, Code: 101
Data: X, Frequency: 2, Code: 110
Data: A, Frequency: 3, Code: 111
Consider the simple 4*8, 8-bit image(online)
Bit-Plane Encoding:
BIT-PLANE CODING: An effective technique for reducing an image's interpixel redundancies is to process
the image's bit planes individually. The technique, called bitplane coding, is based on the concept of
decomposing a multilevel (monochrome or color) image into a series of binary images and compressing each
binary image via one of several well-known binary compression methods
45
correspond to 127 and 128 are 11000000 and 01000000, respectively.
46
Use of bit plane coding:
We used the bit-plane encoding [22] to encode the image into two layers: high-priority and low-
priority. The bit-plane slicing is a technique used in image processing to slice the images into different
planes.
images.
Steps involved :
⚫ Image converted to Y,Cb,Cr format
⚫ Divided into 8x8 blocks
⚫ Each 8x8 block subject to DCT followed by quantization
⚫ Zig-zag scan
⚫ DC coefficients stored using DPCM
⚫ RLE used for AC coefficients
⚫ Huffman encoding
⚫ Frame generation
48
Functional block diagram of JPEG standard
Block preparation
49
Quantization
50
Statistical output encoding
JPEG uses Huffman encoding for this purpose.
It often produces a 20:1 compression or better.
For decoding we have to run the algorithm backward.
JPEG is roughly symmetric: Decoding takes as long as encoding.
Advantages Disadvantages
24-bits per pixel can be used Doesn’t work well with sharp
leading to better accuracy. edges.
51
JPEG 2000 STANDARD:-
Wavelet based image compression standard
Encoding
⚫ Decompose source image into components
⚫ Decompose image and its components into rectangular tiles
⚫ Apply wavelet transform on each tile
⚫ Quantize and collect subbands of coefficients into rectangular arrays of “code-
blocks”
⚫ Encode so that certain ROI’s can be coded in a higher quality
⚫ Add markers in the bitstream to allow error resilience
Advantages:
Lossless and lossy compression.
Progressive transmission by pixel accuracy and resolution.
Region-of-Interest Coding.
Random codestream access and processing.
Robustness to bit-errors.
Content-based description.
Side channel spatial information (transparency).
(i) Given a four-symbol source {a, b, c, d} with source probabilities {0.1, 0.4, 0.3, 0.2}, encode the sequence
‘bab’ using Arithmetic Encoding.
52
53
54
Write the steps to obtain Huffman code. Is it Lossy or losseless technique? Is it uniquely decodable or not?
Consider the simple 4*8, 8-bit image:
55
56
10. For the sub-image given below, compute the compression ratio that can be achieved using (i) Huffman coding
of pixel values (ii) Run-Length coding, assuming 2-bits to represent the pixel values and 2-bits to represent the
run length.
57
58