Date post: | 06-Apr-2018 |
Category: |
Documents |
Upload: | adila-zahid |
View: | 222 times |
Download: | 0 times |
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 1/24
Project report
IMAGE FILTERATION IN SPATIAL DOMAIN
Project supervisor
Sir Zafar Iqbal
Submitted By
Sumera yasmeen213
Adila butt211
The Islamia University of Bahawalpur
1
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 2/24
CERTIFICATE
This is to certify that Adila Butt (Roll no.211) and Sumera Yasmeen (Roll no213) has worked on and completed their software project at Department of Computer Sciences, The Islamia University of Bahawalpur in partial fulfillment of the requirement for the degree of MCS in Computer Sciences under my guidanceand supervision.In my opinion, it is satisfactory and up to mark and therefore fulfills therequirements of MCS in Computer Sciences.
SUPERVISOR/INTERNAL EXAMINER
Mr.Zafar Iqbal
Lecturer,Department of Computer SciencesRahim Yar Khan CampusThe Islamia University of Bahawalpur
(Signature)
Accepted
2
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 3/24
EXORDIUM
In the name of Allah, the Compassionate, theMerciful.
Praise be to Allah, Lord of Creation,The Compassionate, the Merciful,
King of Judgment-day!
You alone we worship, and to you alone we prayFor help,
Guide us to the straight path
The path of those who You have favored,
Not of those who have incurred Your wrath,Nor of those who have gone astray
3
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 4/24
DEDICATION
To: -Allah almighty, who is the Lord of the world.
-My beloved Prophet (PBUH), who is the city of knowledge.
-My loving parents, who made me what I am, whose elevatingremarks Worked as a fountain of encouragement to me,
-At last but not least to my highly respected supervisor, Sir Zafar iqbal, whose inspired guidance laid the foundation of my research.
4
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 5/24
ACKNOWLEDEMENT
I am grateful to almighty Allah, the merciful and the beneficent for Enabling me to accomplish this project successfully.
I am very thankful to SIR ZAFAR IQBAL for supervision andInvaluable guidance throughout the project. I also thanks all our Teachers whom teaches the students with whole-heartedly andHelping us whenever needed help.
5
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 6/24
PREFACE
Digital image processing is an important research area. The techniques
developed in this area so far require to be summarized in an appropriate way. Inthis book, the fundamental theories of these techniques will be introduced.Particularly, their applications in image filtering will be introduced. The entirebook consists of chapters, which will be subsequently introduced.
In Chapter 1, basic concepts in digital image processing are described. Chapter 2 will see the details of image filteration.In chapter 3 spatial domain methods willbe described.
6
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 7/24
PROJECT BRIEF
Project Title
Image Filtration in Spatial Domain
Supervised By
Sir Zafar Iqbal
Submitted By
Adila Butt (211)Sumera Yasmeen (213)
Tools Used
Visual studio.net 2008
Operating System
Windows XP
System Used
1 GB RAM2.8GHZ processor 80 GB Hard Drive
7
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 8/24
TABLE OF CONTENTS
CHAPTERT NO.1 INTRODUCTIO OF IMAGE PROCESSING
1.1 WHAT IS IMAGE PROCESSING?1.2 PURPOSE OF IMAGE PROCESSING.
1.3 BINARY IMAGES.
1.4 GREYSCALE IMAGES.
1.5
8
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 9/24
What is image processing?
Image processing is a method to convert an image into digital form and perform someoperations on it, in order to get an enhanced image or to extract some useful information
from it. It is a type of signal dispensation in which input is image, like video frame or
photograph and output may be image or characteristics associated with that image.
Usually Image Processing system includes treating images as two dimensional signalswhile applying already set signal processing methods to them.
It is among rapidly growing technologies today, with its applications in various aspects of a business. Image Processing forms core research area within engineering and computer
science disciplines too.
Image processing basically includes the following three steps.
· Importing the image with optical scanner or by digital photography.
· Analyzing and manipulating the image which includes data compression and
image enhancement and spotting patterns that are not to human eyes like satellite photographs.
· Output is the last stage in which result can be altered image or report that is basedon image analysis.
Purpose of Image processing:
The purpose of image processing is divided into 5 groups. They are:
1. Visualization - Observe the objects that are not visible.
2. Image sharpening and restoration - To create a better image.
3. Image retrieval - Seek for the image of interest.
4. Measurement of pattern – Measures various objects in an image.
5. Image Recognition – Distinguish the objects in an image.
9
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 10/24
Binary Images
Binary images are images whose pixels have only two possible intensity values. They
are normally displayed as black and white. Numerically, the two values are often 0 for
black, and either 1 or 255 for white.
Binary images are often produced by thresholding a grayscale or color image, inorder to separate an object in the image from the background. The color of the object
(usually white) is referred to as the foreground color . The rest (usually black) is referredto as the background color . However, depending on the image which is to be
thresholded, this polarity might be inverted, in which case the object is displayed with 0and the background is with a non-zero value.
Some morphological operators assume a certain polarity of the binary input image so
that if we process an image with inverse polarity the operator will have the opposite
effect. For example, if we apply a closing operator to a black text on white background,
the text will be opened.
Grayscale Images
10
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 11/24
A grayscale (or graylevel) image is simply one in which the only colors are shades of
gray. The reason for differentiating such images from any other sort of color image is that
less information needs to be provided for each pixel. In fact a `gray' color is one in which
the red, green and blue components all have equal intensity in RGB space, and so it is
only necessary to specify a single intensity value for each pixel, as opposed to the three
intensities needed to specify each pixel in a full color image.Often, the grayscale intensity is stored as an 8-bit integer giving 256 possible different
shades of gray from black to white. If the levels are evenly spaced then the difference
between successive graylevels is significantly better than the graylevel resolving power of the human eye.
Grayscale images are very common, in part because much of today's display and image
capture hardware can only support 8-bit images. In addition, grayscale images areentirely sufficient for many tasks and so there is no need to use more complicated and
harder-to-process color images.
What is image filtration?
A software routine that changes the appearance of an image or part of an imageby altering the shades and colors of the pixels in some manner. Filters are usedto increase brightness and contrast as well as to add a wide variety of textures,tones and special effects to a picture.
Pixels:
In order for any digital computer processing to be carried out on an image, it must first be
stored within the computer in a suitable form that can be manipulated by a computer program. The most practical way of doing this is to divide the image up into a collection
of discrete (and usually small) cells, which are known as pixels. Most commonly, the
image is divided up into a rectangular grid of pixels, so that each pixel is itself a smallrectangle. Once this has been done, each pixel is given a pixel value that represents the
color of that pixel. It is assumed that the whole pixel is the same color, and so any color
11
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 12/24
variation that did exist within the area of the pixel before the image was discretized is
lost. However, if the area of each pixel is very small, then the discrete nature of the image
is often not visible to the human eye.
Filtering an Image
Image filtering is useful for many applications, including smoothing, sharpening,removing noise, and edge detection. A filter is defined by a kernel, which is asmall array applied to each pixel and its neighbors within an image. In mostapplications, the center of the kernel is aligned with the current pixel, and is asquare with an odd number (3, 5, 7, etc.) of elements in each dimension. Theprocess used to apply filters to an image is known as convolution, and may beapplied in either the spatial or frequency domain.
Within the spatial domain, the first part of the convolution process multiplies the
elements of the kernel by the matching pixel values when the kernel is centered over a pixel. The elements of the resulting array (which is the same size as the kernel) are
averaged, and the original pixel value is replaced with this result. The CONVOL function performs this convolution process for an entire image.
Within the frequency domain, convolution can be performed by multiplying the FFT
(Fast Fourier Transform) of the image by the FFT of the kernel, and then transforming
back into the spatial domain. The kernel is padded with zero values to enlarge it to thesame size as the image before the forward FFT is applied. These types of filters are
usually specified within the frequency domain and do not need to be transformed.
Overview of Transforming Between Image Domains:
Some processes performed on an image in the spatial domain may be verycomputationally expensive. These same processes may be significantly easier toperform after transforming an image to a different domain. These transformationsare the basis for many image filters, applied to remove noise, to sharpen, or extract features. Domain transformations also provide additional informationabout an image and can offer compression benefits.
The most common representation of a pixel's value and location is spatial, where it
appears in three dimensions ( x, y, and z ). Pixel value and location in this space is usually
referred to by column ( x), row ( y), and value ( z ), and is known as the spatial domain.However, a pixel's value and location can be represented in other domains.
In the frequency or Fourier domain, the value and location are represented by sinusoidal
relationships that depend upon the frequency of a pixel occurring within an image. In thisdomain, pixel location is represented by its x- and y-frequencies and its value is
represented by an amplitude. Images can be transformed into the frequency domain to
determine which pixels contain more important information and whether repeating
patterns occur.
12
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 13/24
The following examples in this section will focus on some of the basic filtersapplied within the spatial domain using the CONVOL function:
Low Pass Filtering
High Pass FilteringDirectional FilteringLaplacian Filtering
Since filters are the building blocks of many image processing methods, these examples
merely show how to apply filters, as opposed to showing how a specific filter may be
used to enhance a specific image or extract a specific shape. This basic introduction
provides the information necessary to accomplish more advanced image-specific processing.
Low Pass Filtering
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 (seeSmoothingan Image for more information).
Using a low pass filter tends to retain the low frequency information within an imagewhile reducing the high frequency information
Smoothing an Image
Smoothing is often used to reduce noise within an image or to produce a less pixelated
image. Most smoothing methods are based on low pass filters.
Smoothing is also usually based on a single value representing the image, such as the
average value of the image or the middle (median) value. The following examples show
how to smooth using average and middle values:
Smoothing with Average ValuesSmoothing with Median Values
High Pass Filtering
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
13
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 14/24
usually contains a single positive value at its center, which is completely surrounded by
negative values.
Sharpening an Image
Sharpening an image increases the contrast between bright and dark regions to bring outfeatures.
The sharpening process is basically the application of a high pass filter to an image.
Directional Filtering
A directional filter forms the basis for some edge detection methods. An edge within an
image is visible when a large change (a steep gradient) occurs between adjacent pixelvalues. This change in values is measured by the first derivatives (often referred to as
slopes) of an image. Directional filters can be used to compute the first derivatives of an
image
Detecting Edges
Detecting edges is another way to help extract features. Many edge detection methods use
either directional or Laplacian filters.
Laplacian Filtering
A Laplacian filter forms another basis for edge detection methods. A Laplacian filter can
be used to compute the second derivatives of an image, which measure the rate at whichthe first derivatives change. This helps to determine if a change in adjacent pixel values is
an edge or a continuous progression.
Kernels of Laplacian filters usually contain negative values in a cross pattern (similar to a
plus sign), which is centered within the array. The corners are either zero or positive
values. The center value can be either negative or positive
Frequency Domain
The frequency domain is a space in which each image value at image position Frepresents the amount that the intensity values in image I vary over a specific distance
related to F. In the frequency domain, changes in image position correspond to changes in
the spatial frequency.
The spatial frequency domain is interesting because:1) It may make explicit periodic relationships in the spatial domain, and
2) Some image processing operators are more efficient or indeed only practicalwhen applied in the frequency domain.
In most cases, the Fourier Transform is used to convert images from the spatial domaininto the frequency domain and vice-versa.
14
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 15/24
A related term used in this context is spatial frequency , which refers to the (inverse of
the) periodicity with which the image intensity values change. Image features with highspatial frequency (such as edges) are those that change greatly in intensity over short
image distances.
Spatial DomainI=image, s=scene:
The spatial domain is the normal image space, in which a change in position in Idirectly projects to a change in position in S. Distances in I (in pixels) correspond to real
distances (e.g. in meters) in S.
This concept is used most often when discussing the frequency with which image values
change, that is, over how many pixels does a cycle of periodically repeating intensityvariations occur. One would refer to the number of pixels over which a pattern repeats
(its periodicity) in the spatial domain.
In most cases, the Fourier Transform will be used to convert images from the spatialdomain into the frequency domain.
Fourier Transform
The Fourier Transform is an important image processing tool which is used to decompose
an image into its sine and cosine components. The output of the transformation representsthe image in the Fourier or frequency domain, while the input image is the spatialdomain equivalent. In the Fourier domain image, each point represents a particular
frequency contained in the spatial domain image.The Fourier Transform is used in a wide range of applications, such as image analysis,
image filtering, image reconstruction and image compression.
Noise Generation
Real world signals usually contain departures from the ideal signal that would be produced by our model of the signal production process. Such departures are referred to
as noise. Noise arises as a result of unmodelled or unmodellable processes going on in
the production and capture of the real signal. It is not part of the ideal signal and may be
caused by a wide range of sources, e.g. variations in the detector sensitivity,
environmental variations, the discrete nature of radiation, transmission or quantization
errors, etc. It is also possible to treat irrelevant scene details as if they are image noise
(e.g. surface reflectance textures). The characteristics of noise depend on its source, as
does the operator which best reduces its effects.Many image processing packages contain operators to artificially add noise to an image.
Deliberately corrupting an image with noise allows us to test the resistance of an image
processing operator to noise and assess the performance of various noise filters.
Edge DetectorsEdges are places in the image with strong intensity contrast. Since edges often occur at
image locations representing object boundaries, edge detection is extensively used in
15
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 16/24
image segmentation when we want to divide the image into areas corresponding to
different objects. Representing an image by its edges has the further advantage that the
amount of data is reduced significantly while retaining most of the image information.Since edges consist of mainly high frequencies, we can, in theory, detect edges by
applying a highpass frequency filter in the Fourier domain or by convolving the image
with an appropriate kernel in the spatial domain. In practice, edge detection is performedin the spatial domain, because it is computationally less expensive and often yields better
results.
Convolution
Convolution is a simple mathematical operation which is fundamental to many commonimage processing operators. Convolution provides a way of `multiplying together' two
arrays of numbers, generally of different sizes, but of the same dimensionality, to produce
a third array of numbers of the same dimensionality. This can be used in image processing to implement operators whose output pixel values are simple linear
combinations of certain input pixel values.
In an image processing context, one of the input arrays is normally just a graylevel
image. The second array is usually much smaller, and is also two-dimensional (although
it may be just a single pixel thick), and is known as the kernel.
Kernel
A kernel is a (usually) smallish matrix of numbers that is used in image convolutions.
Differently sized kernels containing different patterns of numbers give rise to different
results under convolution. For instance, Figure 1 shows a 3×3 kernel that implements a
mean filter.
Sobel Edge Detector:
Brief Description
The Sobel operator performs a 2-D spatial gradient measurement on an image and so
emphasizes regions of high spatial frequency that correspond to edges. Typically it is
used to find the approximate absolute gradient magnitude at each point in an inputgrayscale image.
How It Works
In theory at least, the operator consists of a pair of 3×3 convolution kernels as shown in
Figure 1. One kernel is simply the other rotated by 90°. This is very similar tothe Roberts Cross operator.
16
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 17/24
Figure 1 Sobel convolution kernels
These kernels are designed to respond maximally to edges running vertically and
horizontally relative to the pixel grid, one kernel for each of the two perpendicular orientations. The kernels can be applied separately to the input image, to produce
separate measurements of the gradient component in each orientation (call
theseGx and Gy ). These can then be combined together to find the absolute magnitude of
the gradient at each point and the orientation of that gradient. The gradient magnitude is
given by:
Typically, an approximate magnitude is computed using:
which is much faster to compute. spatial gradient is given by:
The angle of orientation of the edge (relative to the pixel grid) giving rise to the
Roberts Cross Edge Detector
he Roberts Cross operator performs a simple, quick to compute, 2-D spatialgradient measurement on an image. It thus highlights regions of high spatialfrequencywhich often correspond to edges. In its most common usage, the inputto the operator is a grayscale image, as is the output. Pixel values at each pointin the output represent the estimated absolute magnitude of the spatial gradientof the input image at that point.
17
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 18/24
Guidelines for Use
The Sobel operator is slower to compute than the Roberts Cross operator, but its larger convolution kernel smooths the input image to a greater extent and so makes the operator
less sensitive to noise. The operator also generally produces considerably higher output
values for similar edges, compared with the Roberts Cross.
As with the Roberts Cross operator, output values from the operator can easily overflow
the maximum allowed pixel value for image types that only support smallish integer pixel
values (e.g. 8-bit integer images). When this happens the standard practice is to simply
set overflowing output pixels to the maximum allowed value. The problem can be
avoided by using an image type that supports pixel values with a larger range. Natural edges in images often lead to lines in the output image that are several pixels
wide due to the smoothing effect of the Sobel operator.
Spatial domain methods
The value of a pixel with coordinates ( x, y) in the enhanced image is the
result of performing some operation on the pixels in the neighbourhood of ( x, y)
in the input image, F .
Neighbourhoods can be any shape, but usually they are rectangular.
Grey scale manipulation:
The simplest form of operation is when the operator T only acts on a 1*1 pixelneighbourhood in the input image, that is f(x,y) only depends on the value
of F at ( x, y). This is a grey scale transformation or mapping.
The simplest case is thresholding where the intensity profile is replaced by a
step function, active at a chosen threshold value. In this case any pixel with a
18
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 19/24
grey level below the threshold in the input image gets mapped to 0 in the output
image. Other pixels are mapped to 255.
Other grey scale transformations are outlined in figure 1 below.
Figure 1: Tone-scale adjustments.
2) Histogram Equalization
Histogram equalization is a common technique for enhancing the appearance of
images. Suppose we have an image which is predominantly dark. Then its
histogram would be skewed towards the lower end of the grey scale and all the
image detail is compressed into the dark end of the histogram. If we could
`stretch out' the grey levels at the dark end to produce a more uniformly
distributed histogram then the image would become much clearer.
Histogram equalization involves finding a grey scale transformation function
that creates an output image with a uniform histogram (or nearly so).
How do we determine this grey scale transformation function? Assume our
grey levels are continuous and have been normalized to lie between 0 and 1.
3)Image Smoothing:
19
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 20/24
The aim of image smoothing is to diminish the effects of camera noise,
spurious pixel values, missing pixel values etc. There are many different
techniques for image smoothing; we will consider neighbourhood averaging
and edge-preserving smoothing.
3.1) Neighbourhood Averaging
Each point in the smoothed image, is obtained from the average pixel
value in a neighbourhood of ( x, y) in the input image.
For example, if we use a neighbourhood around each pixel we would use
the mask
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
Each pixel value is multiplied by , summed, and then the result placed in the
output image. This mask is successively moved across the image until every
pixel has been covered. That is, the image is convolved with this smoothingmask (also known as a spatial filter or kernel).
However, one usually expects the value of a pixel to be more closely related to
the values of pixels close to it than to those further away. This is because most
points in an image are spatially coherent with their neighbours; indeed it is
generally only at edge or feature points where this hypothesis is not valid.
Accordingly it is usual to weight the pixels near the centre of the mask more
strongly than those at the edge.
Some common weighting functions include the rectangular weighting functionabove (which just takes the average over the window), a triangular weighting
function, or a Gaussian.
In practice one doesn't notice much difference between different weighting
functions, although Gaussian smoothing is the most commonly used. Gaussian
20
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 21/24
smoothing has the attribute that the frequency components of the image are
modified in a smooth manner.
Smoothing reduces or attenuates the higher frequencies in the image. Mask
shapes other than the Gaussian can do odd things to the frequency spectrum,
but as far as the appearance of the image is concerned we usually don't noticemuch.
3.2)Edge preserving smoothing:
Neighbourhood averaging or Gaussian smoothing will tend to blur edges
because the high frequencies in the image are attenuated. An alternative
approach is to usemedian filtering . Here we set the grey level to be the median
of the pixel values in the neighbourhood of that pixel.
The median m of a set of values is such that half the values in the set are less
than m and half are greater. For example, suppose the pixel values in a
neighbourhood are (10, 20, 20, 15, 20, 20, 20, 25, 100). If we sort the values we
get (10, 15, 20, 20, |20|, 20, 20, 25, 100) and the median here is 20.
The outcome of median filtering is that pixels with outlying values are forced
to become more like their neighbours, but at the same time edges are preserved.
Of course, median filters are non-linear.
Median filtering is in fact a morphological operation. When we erode an image, pixel values are replaced with the smallest value in the neighbourhood. Dilating
an image corresponds to replacing pixel values with the largest value in the
neighbourhood. Median filtering replaces pixels with the median value in the
neighbourhood. It is the rank of the value of the pixel used in the
neighbourhood that determines the type of morphological operation.
Figure 3: Image of Genevieve; with salt and pepper noise; the result of averaging; and the
result of median filtering.
21
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 22/24
4)Image sharpening:
The main aim in image sharpening is to highlight fine detail in the image, or to
enhance detail that has been blurred (perhaps due to noise or other effects, such
as motion). With image sharpening, we want to enhance the high-frequency
components; this implies a spatial filter shape that has a high positive
component at the centre (see figure 4 below).
Figure 4: Frequency domain filters (top) and their corresponding spatial domain
counterparts (bottom).
22
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 23/24
A simple spatial filter that achieves image sharpening is given by
-1/9 -1/9 -1/9
-1/9 8/9 -1/9
-1/9 -1/9 -1/9
Since the sum of all the weights is zero, the resulting signal will have a zero
DC value (that is, the average signal value, or the coefficient of the zero
frequency term in the Fourier expansion). For display purposes, we might want
to add an offset to keep the result in the range.
5) High boost filtering
We can think of high pass filtering in terms of subtracting a low pass image
from the original image, that is,
High pass = Original - Low pass.
However, in many cases where a high pass image is required, we also want to
retain some of the low frequency components to aid in the interpretation of the
image. Thus, if we multiply the original image by an amplificationfactor A before subtracting the low pass image, we will get a high boost or high
frequency emphasis filter. Thus,
23
8/3/2019 Image Filter at Ion
http://slidepdf.com/reader/full/image-filter-at-ion 24/24
Now, if A = 1 we have a simple high pass filter. When A > 1 part of the original
image is retained in the output.
A simple filter for high boost filtering is given by
-1/9 -1/9 -1/9
-1/9 /9 -1/9
-1/9 -1/9 -1/9
where .