Implementation of Image Sharpening and Smoothing Using Filters

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016

ISSN: 2395-3470
www.ijseas.com

IMPLEMENTATION OF IMAGE SHARPENING AND


SMOOTHING USING FILTERS
K. Siva Praveen1, G.Hamarnath2, K. Prasad Babu3, M. Sreenivasulu4, K.Sudhakar5
1
M.tech Student 13G31D0604, DSCE branch, SJCET Yemmiganur, Andhra pradesh, India
2
Assistant Professor, Department of ECE, SJCET Yemmiganur, Andhra pradesh, India
2
Assistant Professor, Department of ECE, SJCET Yemmiganur, Andhra pradesh, India
4
Associate Professor, Department of ECE, SJCET Yemmiganur, Andhra pradesh, India
5
H.O.D & Associate Professor, Department of ECE, SJCET Yemmiganur, Andhra pradesh, India

Abstract 2. Image preprocessing: to improve the image in


In this project implementation of image sharpening ways that increase the chances for success of the
and smoothing on image is done by using filters. The other processes.
objective of image filtering is to process the image so 3. Image segmentation: to partitions an input image
that the result is more suitable than the original image into its constituent parts or objects.
for a specific application. Image filtering refers to a 4. Image representation: to convert the input data to
process that removes the noise, improves the digital a form suitable for computer processing.
image for varied application. A gradient filter 5. Image description: to extract features that result in
highlights diagonal edges. A gradient convolution some quantitative information of interest or features
filter is a first-order derivative filter with kernel that are basic for differentiating one class of objects
values. The input image is sharpened by using from another.
weighted kernel of different values. By using matlab 6. Image recognition: to assign a label to an object
we implement the smoothening of an image with based on the information provided by its descriptors.
Gaussian noise, salt and pepper noise with the 7. Image interpretation: to assign meaning to an
median filter. Mean square error and peak signal to ensemble of recognized objects.
noise ratio are compared for the input image and Knowledge about a problem domain is coded into an
obtained output image. image processing system in the form of a knowledge
Keywords: Sharpening, Smoothening, Filters, MSE, database.
PSNR, Matlab.

1. Introduction
A digital image is an image f(x,y) that has been
discretized both in spatial coordinates and brightness.
The elements of such a digital array are called image
elements or pixels. A simple image model: To be
suitable for computer processing, an image f(x,y)
must be digitalized both spatially and in amplitude.
Digitization of the spatial coordinates (x,y) is called Figure 1: Fundamental steps in Digital image
image sampling. Amplitude digitization is called processing
gray-level quantization.

Fundamental steps in image processing:


1. Image acquisition: to acquire a digital image

7
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016
ISSN: 2395-3470
www.ijseas.com

Example 1

Figure 2: Basic Fundamental elements of an image


processing

Define a center point (x; y) Perform an operation that


involves only the pixels in a predefined Example 2
neighborhood Result of the operation response of the
process at that point Repeat the process for every
pixel in the image.

The most common neighbourhood operation is to


multiply each of the pixels in the neighbourhood by a
weight and add them together. The local weights are
sometimes called a mask or kernel

Figure 3: Basic representation of an image in terms


of pixels
Convolution - the same as correlation except that
filter kernel W is rotated for 180 degrees
Output is a function of a pixel value and its neighbors
Possible operations are: sum, weighted sum, average,
weighted average, min, max, median,
Example: 3x 3 neighbourhood Convolution (*) g = W* f
For spatial filtering using correlation or convolution
is a matter of preferences

8
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016
ISSN: 2395-3470
www.ijseas.com

Pixels in the neighbourhood are correlated


Rectangular neighbourhoods are often used with an The formula for the 1st derivative of a function is as
odd number of pixels in rows and columns, enabling follows:
specification of the central pixel of the ∂f
= f ( x + 1) − f ( x )
neighbourhood ∂x
Different neighbourhood sizes: 3_3, 5_5,
1_3,...,2n+1_2m+1 It’s just the difference between subsequent values
The choice of size and shape (rectangular, circular,...) and measures the rate of change of the function
of the neighbourhood depends on the size of the
objects in the image 8
7
6
5
4
3
2
1

2. Smoothening and Sharpening Filters 0

Smoothing filters are those which remove fine detail


0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0
in an image. Whereas the Sharpening spatial filters
seek to highlight fine detail, Remove blurring from 8
6
images, Highlight edges 4
2
Sharpening filters are based on spatial differentiation 0

Differentiation measures the rate of change of a -2


-4

function -6
-8
.
Let’s consider a simple 1 dimensional example
Figure6: 1st derivate

The formula for the 2nd derivative of a function is as


follows:
∂2 f
= f ( x + 1) + f ( x − 1) − 2 f ( x)
∂2x
Simply takes into account the values both before and
after the current value

Figure 4: One dimensional figure

Figure 5: Selection of for derivative

9
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016
ISSN: 2395-3470
www.ijseas.com

8
7 We can easily build a filter based on this
6
5
4
3
2
1
0

0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 Applying the Laplacian to an image we get a new


8
image that highlights edges and other discontinuities
6
4
2
0
-2
-4
-6
-8

Figure7: 2nd derivate


The 2nd derivative is more useful for image The result of a Laplacian filtering is not an enhanced
enhancement than the 1st derivative image. We have to do more work in order to get our
Stronger response to fine detail final image Subtract the Laplacian result from the
Simpler implementation original image to generate our y ) = f sharpened
g ( x, final ( x, y ) − ∇ 2 f
We will come back to the 1st order derivative later enhanced image
on
The first sharpening filter we will look at is the
Laplacian Isotropic One of the simplest sharpening
filters We will look at a digital implementation

The Laplacian is defined as follows:


∂2 f ∂2 f
∇2 f = +
∂2x ∂2 y In the final sharpened image edges and fine detail are
much more obvious
where the partial 1st order derivative in the x
direction is defined as follows:

∂2 f
= f ( x + 1, y) + f ( x − 1, y) − 2 f ( x, y)
∂2x
Original - Laplacian =
and in the y direction as follows:
Sharpened image
∂2 f
= f ( x, y + 1) + f ( x, y − 1) − 2 f ( x, y)
∂2 y The key point in the effective sharpening process lies
in the choice of the high-pass filtering operation.
Traditionally, linear filters have been used to
So, the Laplacian can be given as follows:
implement the high-pass filter, however, linear
∇ 2 f = [ f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1) + f ( x, y − 1)]− 4 f ( x, y ) techniques can lead to unacceptable results if the
original image is corrupted with noise. A tradeoff

10
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016
ISSN: 2395-3470
www.ijseas.com

between noise attenuation and edge highlighting can vectors. Thus the process described here can be
be obtained if a weighted median filter with applied to either gray-scale or color images, with the
appropriated weights is used. To illustrate this, only difference being that vector filters have to be
consider a WM filter applied to a gray-scale image used in sharpening color images whereas single-
where the following filter mask is used. component filters are used with gray-scale images.
Human perception is highly sensitive to edges and
fine details of an image, and since they are composed
primarily by high frequency components, the visual
quality of an image can be enormously degraded if
the high frequencies are attenuated or completed
removed. In contrast, enhancing the high-frequency
components of an image leads to an improvement in
the visual quality. Image sharpening refers to any
enhancement technique that highlights edges and fine
details in an image. Image sharpening is widely used
in printing and photographic industries for increasing
the local contrast and sharpening the images.

In principle, image sharpening consists of adding to


Figure 8: Image sharpening block diagram
the original image a signal that is proportional to a
representation
high-pass filtered version of the original image.
Figure (8) illustrates this procedure, often referred to Because of the weight coefficients in Eq. 1, for each
an unsharp masking on a one-dimensional signal. As position of the moving window, the output is
shown in Fig (8), the original image is first filtered proportional to the difference between the center
by a high-pass filter that extracts the high-frequency pixel and the smallest pixel around the center pixel.
components, and then a scaled version of the high- Thus, the filter output takes relatively large values for
pass filter output is added to the original image, thus prominent edges in an image, and small values in
producing a sharpened image of the original. Note regions that are fairly smooth, being zero only in
that the homogeneous regions of the signal, i.e., regions that have a constant gray level.
where the signal is constant, remain unchanged. The
sharpening operation can be represented by Although this filter can effectively extract the edges
contained in an image, the effect that this filtering
operation has over negative-slope is different from
equation-- 1 that obtained for positive-Slope edges .A change
from a gray level to a lower gray level is referred to
where is the original pixel value at the as a negative-slope edge, whereas a change from a
gray level to a higher gray level is referred to as a
coordinate is the high-pass filter, is a positive-slop edge
tuning parameter greater that or equal zero, and S i,j is
Since the filer output is proportional to the difference
the sharpened pixel at the coordinate . The
between the center pixel and the small pixel around
value taken by depends on the grade of sharpness the center, for negative-slope edges, the center pixel
desired. Increasing yields a more sharpened small values producing small values at the filter
image. output. Moreover, the filter output is zero if the
smallest pixel around the center pixel and the center
pixel have the same values.
If color images are used and are three-
component vectors, whereas if gray-scale images are This implies that negative-slope edges are not
extracted in the same way as positive-slope edges. To
used and are single-component overcome this limitation the basic image sharpening

11
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016
ISSN: 2395-3470
www.ijseas.com

structure shown in Figure 8 must be modified such image are filtered by the same WM filter, the
that positive-slope edges as well as negative-slope positive-slope edges and negative-slopes edges are
edges are highlighted in the same proportion. sharpened in the same way.

A simple way to accomplish that is:

(a) extract the positive-slope edges, and then filter the


preprocessed image with the filter described above;
(c) combine appropriately the original image, the
filtered version of the original image, and the filtered
version of the preprocessed image to form the
sharpened image.
Figure 10
A powerful technique for sharpening images in the
presence of low noise levels is via an adaptive
filtering algorithm. Here we look at a method of re-
defining a highpass filter (such as the one shown in
Figure 8) as the sum of a collection of edge
directional kernels.
Figure 9: Block diagram representation
Thus both positive-slope edges and negative-slope
are equally highlighted. This procedure is illustrated
in Figure 9, where the top branch extracts the
positive-slope edges and the middle branch extracts
the negative-slope edges. In order to understand the
effects of edge sharpening, a row of a test image is
plotted in Figure 10 together with a row of the
sharpened image when only the positive-slope edges Figure 11: Sharpening filter.
are highlighted, Figure 10, only the negative-slope
edges are highlighted, Figure 10, and both positive-
slope and negative-slope edges are jointly
highlighted, Figure 10
This filter can be re-written as times the sum of
In Figure (9). and are tuning parameters that the eight edge sensitive kernels shown in Figure 9.
control the amount of sharpness desired in the
positive-slope direction and in the negative-slope
direction, respectively. The values of and are
generally selected to be equal. The output of the
prefiltering operation is defined as

equation -----2
With M equal to the maximum pixel value of the
original image. This prefiltering operation can be Figure 12: Sharpening filter re-defined as eight edge
thought of as a flipping and a shifting operation of directional kernels
the values of the original image such that the
negative-slope edges are converted in positive-slope
edges. Since the original image and the pre-filtered

12
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016
ISSN: 2395-3470
www.ijseas.com

Successful image enhancement is typically not


achieved using a single operation, rather we combine
a range of techniques in order to achieve a final result

RESULTS

Figure 15: Original image , obtained sharpened


images with two kernel values
Mean square Error of obtained image is
mes = 5.1584e+004
Figure 13: Original image , Gaussian image, salt and
Peak Signal to Noise Ratio
pepper noise image
PSNR = 2.3156

4. Conclusions

From the results we come to conclusion that


weighted kernel will have give more sharpened
image along with the boundary edge information.
The median filtered output image is more
smoothened for salt and pepper noise than compared
to Gaussian noise.
Figure 14: Median filtered image for Gaussian image, References
and salt and pepper noise image [1] R. Kimmel A. Spira and N. Sochen, “A short time
beltrami kernel for smoothing images
Mean square Error of obtained image is mes = and manifolds,” IEEE Trans. Image Processing, vol.
335.6794 16, no. 6, pp. 1628–1636, 2007.
[2]. Gonzales R., Woods R., and Eddins S.,
Peak Signal to Noise Ratio Digital Image Processing Using Matlab, 2nd
PSNR = 52.6637 Edition, Prentice Hall, USA, 2003.
[3] Geman, S., Geman, D., “Stochastic relaxation,
Gibbs distribution, and the Bayesian
restoration of images,” IEEE Trans. Pattern Anal.
Machine Intell. Vol.6 (6), 721-741, 1984.

13
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-2, Issue-1, January 2016
ISSN: 2395-3470
www.ijseas.com

[4] Buades, A., Coll, B., Morel, J, “ A non-local


algorithm for image denoising,” IEEE
CVPR, vol. II, pp. 60–65, 2005.
[5] Umbaugh Scot E, Computer Vision and
Image Processing, Prentice Hall, NJ, 1988,
ISBN 0-13-264599-8
[6]. R.C.Gonzales, R.E.Woods, Digital Image
Processing, 2-nd Edition, Prentice Hall, 2002
[7]. R.A. Haddad and A.N. Akansu, “A Class of
Fast Gaussian Binomial Filters for Speech
and Image Processing,” IEEE Transactions on
Acoustics, Speech and Signal Processing, vol. 39, pp
723-727, March 1991.
[8]. Shapiro, L. G. & Stockman, G. C: “Computer
Vision”, page 137, 150. Prentence Hall, 2001
[9]. Mark S. Nixon and Alberto S. Aguado. Feature
Extraction and Image Processing. Academic
Press, 2008, p. 88.
[10]. Yusuf, Nijad, Sara Tedmory “Exploiting hybrid
methods for enhancing digital X-ray images”.
The International Arab Journal of Information
Technology, Vol. 10, No.1, January 2013

14

You might also like