2. Noise Reduction In images Using Filters
MOUNT CARMEL COLLEGE, AUTONOMOUS
BENGALURU-560052
CERTIFICATION
This is to certify that the project entitled………………………………………has been carried
out by…………………………………………………………in Computer Science under our
supervision and guidance, in partial fulfillment of the requirement for the award of
BACHELOR DEGREE IN SCIENCE for III B.Sc. (VI semester) MOUNT CARMEL
COLLEGE, Autonomous, Bengaluru-52 during the academic year 2015-2016.
Reg. No.:- 1.MS133406 2.MS133407
3. MS133408 4.MS133414
Date of Examination:-
Signature of the ProjectGuide
Examiner Head of the Department
1)
2)
4. Noise Reduction In images Using Filters
ABOUT MATLAB
MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment
and fourth-generation programming language. A proprietary programming language developed
by Math Works, MATLAB allows matrix manipulations, plotting of functions and data,
implementation of algorithms, creation of user interfaces, and interfacing with programs
written in other languages, including C, C++, Java, Fortran and Python. The MATLAB
application is built around the MATLAB scripting language. Common usage of the MATLAB
application involves using the Command Window as an interactive mathematical shell or
executing text files containing MATLAB code.
MATLAB was first adopted by researchers and practitioners in control engineering, Little's
specialty, but quickly spread to many other domains. It is now also used in education, in
particular the teaching of linear algebra, numerical analysis, and is popular amongst scientists
involved in image processing.
6. Noise Reduction In images Using Filters
“The pleasure that follows the successful completion of an assignment would remain
incomplete without a gratitude for the people and without whose cooperation the achievement
would remain a distant dream. It is not mere formality to place a record the tireless efforts,
ceaseless cooperation, constant guidance and encouragement of the people closely associated
with the assignment but a distinct necessity for facilities the authenticity and readability of the
project.”
The software languages learnt in all these years are brought into practice. We have tried to
make best use of their opportunity. The work hears bears the imprint of many persons under
whom we did this project.
We are thankful to Mrs. Regina, for her scholarly guidance, advice and encouragement and
also for providing necessary facilities to carry out the desertion in prescribed period.
Finally, we are indebted to our family, friends and those people who had helped us in
completing this project.
9. Noise Reduction In images Using Filters
1.1 PROBLEM STATEMENT
Image noise is random (not present in the object imaged) variation of brightness or color
information in images, and is usually an aspect of electronic noise. Noise is the result of errors
in the image acquisition process that results in pixel values that do not reflect the true intensities
of the real scene. Generally images are degraded with the noise when they are transmitted or
during image acquisition process.
Noise reduction is the process of reducing noise from a digital image. The main purpose of
reducing noise is to enhance the quality of an image. All the noise reduction techniques are
equivalent in a conceptual manner, no matter what image is being processed, however the
approach for implementing these methods may vary with the pre knowledge of the properties
of the images taken into account.
Noises are of different types, and hence it is necessary to provide different techniques according
to the type of noise.
1.2 OBJECTIVE OF THE PROJECT
To study about different types of noise and noise reduction techniques to remove the noise
present in images in digital image processing.
2
11. Noise Reduction In images Using Filters
2.1 HARDWARE REQUIREMENTS:
Processor: Intel® Core™2 Duo CPU E7500 @ 2.93GHz 2.93GHz
Installed Memory (RAM): 2.00 GB
System Type: 64-bit Operating System
2.2 SOFTWARE REQUIREMENTS:
Windows edition: Windows 7 professional
Developing environment used: Mat lab 2013
4
13. Noise Reduction In images Using Filters
3.1 Image Processing
Image processing involves changing the nature of an image in order to eitherto improve its
pictorial information for human interpretation,or render it more suitable for autonomous
machine perception. Digital image processing, which involves using a computer to change the
nature of a digital image. An image can be considered as a two dimensional function, where
the function values give the brightness of the image at any given point. The image brightness
values can be any real numbers in the range 0(black) to 1.0(white). A digital image differs from
a photo in that the x, y and f(x,y)values are all discrete. Usuallythey take on only integer values,
will have x and y ranging from 1 to 256 each, and the brightness values also ranging from 0
(black) to 255 (white). A digital image, can be considered as a large array of sampled points
from the continuous image, each of which has a particular quantized brightness; these points
are the pixels which constitute the digital image. The pixels surrounding a given pixel constitute
its neighborhood. The procedures which makes an image look better are:
Enhancing the edges of an image to make it appear sharper.
Removing noise from an image; noise being random errors in the image.
Removing motion blur from an image.
Obtaining the edges of an image. This may be necessary for the measurement of objects
in an image.
3.1.2An image processing task
Acquiring the image.First we need to produce a digital image from a paper envelope.
This can be done using either a CCD camera, or a scanner.
Preprocessing. This is the step taken before the _major_ image processing task. The
problem here is to perform some basic tasks in order to render the resulting image more
suitable for the job to follow. In this case it may involve enhancing the contrast,
removing noise, or identifying regions likely to contain the postcode.
6
14. Noise Reduction In images Using Filters
Segmentation. Here is where we actually _get_ the postcode; in other words we
extract from the image that part of it which contains just the postcode.
Representation and description. These terms refer to extracting the particular
features which allow us to differentiate between objects. Here we will be looking for
curves, holes and corners which allow us to distinguish the different digits which
constitute a postcode.
Recognitionandinterpretation.This means assigning labels to objects based on
their descriptors (from the previous step), and assigning meanings to those labels. So
we identify particular digits, and we interpret a string of four digits at the end of the
address as the postcode.
3.1.3 Aspectsof image processing
Image enhancement: This refers to processing an image so that the result is more suitable for
A particular application. Example includes:
Sharpening or de-blurring an out of focus image.
Highlighting edges.
Improving image contrast, or brightening an image.
Image restoration. This may be considered as reversing the damage done to an image by a
Known cause, for example:
Removing of blur caused by linear motion.
Removal of optical distortions.
Removing periodic interference.
Image segmentation. This involves subdividing an image into constituent parts, or isolating
Certain aspects of an image:
Finding lines, circles, or particular shapes in an image,
In an aerial photograph, identifying cars, trees, buildings, or roads.
3.1.4 Applications
1. Medicine
Inspection and interpretation of images obtained from X-rays, MRI or CAT scans.
Analysis of cell images, of chromosome karyotypes.
7
15. Noise Reduction In images Using Filters
2. Agriculture
Satellite/aerial views of land, for example to determine how much land is being used
for different purposes, or to investigate the suitability of different regions for different
crops.
Inspection of fruit and vegetables-distinguishing good and fresh produce from old.
3. Industry
Automatic inspection of items on a production line,
Inspection of paper samples.
4. Law enforcement
Fingerprint analysis.
Sharpening or de-blurring of speed-camera images.
3.2 Types of digital Images
Binary:
Each pixel is just black or white. Since there are only two possible values for each pixel,
We only need one bit per pixel. Such images can therefore be very efficient in terms of
Storage. Images for which a binary representation may be suitable include text (printed or
Handwriting), fingerprints, or architectural plans.
Greyscale:
Each pixel is a shade of grey, normally from 0(black) to 255 (white). This rangemeans that
each pixel can be represented by eight bits, or exactly one byte. This is a verynatural range for
image file handling. Other greyscale ranges are used, but generally they area power of 2. Such
images arise in medicine (X-rays), images of printed works, and indeed 256different grey levels
are sufficient for the recognition of most natural objects.
True color or RGB:
Here each pixel has a particular colour; that colour being described by theamount of red, green
and blue in it. If each of these components has a range 0-255, this givesa total
of different possible colours in the image. This is enough coloursfor any
8
16. Noise Reduction In images Using Filters
image. Since the total number of bits required for each pixel is 24, such images arealso called
24-bit colour images.
Indexed:
Most colour images only have a small subset of the more than sixteen million possible
Colours. For convenience of storage and file handling, the image has an associated colour
map, or colour palette, which is simply a list of all the colours used in that image. Each pixel
hasa value which does not give its colour (as for an RGB image), but an index to the colour
inthe map.
3.2.2Histograms
Given a greyscale image, its histogram consists of the histogram of its grey levels; that is, a
graph indicating the number of times each grey level occurs in the image. We can infer a great
deal aboutthe appearance of an image from its histogram, as it indicates
In a dark image, the grey levels (and hence the histogram) would be clustered at the
lower end
In a uniformly bright image, the grey levels would be clustered at the upper end:
In a well contrasted image, the grey levels would be well spread out over much of the
range.
We can view the histogram of an image in Mat lab by using the imhist function:
>> p=imread('pout.tif');
>> imshow(p),figure,imhist(p),axis tight
9
17. Noise Reduction In images Using Filters
3.2.3COLOUR MODEL
A colour model is a method for specifying colours in some standard way. It generally consists
of a three dimensional coordinate system and a subspace of that system in which each colour
is represented by a single point.
RGB:
In this model, each colour is represented as three values R, G and Bindicating the amounts of
red,green and blue which make up the colour. This model is used for displays on computer
screens; amonitor has three independent electron “guns”for the red, green and blue component
of each colour.These coloursare not realizable on a computer monitor or TV set, on which only
positive values are possible.The colours corresponding to positive values form the RGB gamut;
in general a colour ”gamut”consists of all the colours realizable with a particular colour model.
HSV:
HSV stands for Hue, Saturation, and Value. These terms have the following meanings:
Hue: The “true colour” attributes (red, green, blue, orange, yellow, and so on).
The image pout.If andits histogram
10
18. Noise Reduction In images Using Filters
Saturation: The amount by which the colour has been diluted with white. The more
white in the colour, the lower the saturation. So a deep red has high saturation, and a
light red (a pinkish colour) has low saturation.
Value: The degree of brightness: a well-lit colour has high intensity; a dark colour has
low intensity.
YIQ:
This colour space is used for TV/video in America and other countries where NTSC is the
video standard (Australia uses PAL). In this scheme Y is the ”luminance” (this corresponds
roughly with intensity), and I and Q carry the colour information.
3.3COMPRESSION
The image files can be very large. It is thus important for reasons both of storage and file
transfer to make these file sizes smaller. The different types of compression methods are:
Lossless compression and lossy compression. Lossless compression is preferred for images of
legal, scientific or political significance, whereloss of data, even of apparent insignificance,
could have considerable consequences. Unfortunatelythis style tends not to lead to high
compression ratios. However, lossless compression is used aspart of many standard image
formats. In lossy compression information in the images will be lost.
3.4IMAGE REPRSENTATION
In computing, all data is logically represented in binary. This is true of images as well as
numbers and text. However, an important distinction needs to be made between how image
data is displayed and how it is stored. Displaying involves bitmap representation, whereas
storing as a file involves many image formats, such as jpeg and png. Images data can be saved
or stored in many different formats. The most common are bitmap, jpeg, gif and png.
11
19. Noise Reduction In images Using Filters
Bitmap
A bitmap image has the file extension bmp. Image data is saved to file in an uncompressed
format at a particular bit depth. This is usually 24 bit. This enables millions of colours to be
displayed. Because image data is not compressed when saved to file, file sizes can be very big.
This makes them unsuitable to be used on web pages, even though web browsers will render
them. Bitmaps are the native file format for images made with the MS Paint program.
Jpeg
Jpeg stands for Joint Photographic Experts Group. It is a 24 bit format invented specifically for
storing photographs. Being 24 bit millions of colours can be displayed. It is also a lossy
compressed format. This means image data is stored in a compressed form, and some of the
original image data is discarded when it is saved. When saving, a quality setting can be chosen.
Maximum quality is 100. Images will still look good on a web page saved at a quality of 60. A
lower quality setting results in a smaller file size. Jpegs are the predominant format for images
on web pages. Also, most digital cameras save images in this format for reasons of space
efficiency.
Gif
Gif is a lossless format that uses a colour palette of 256 colours (or less). This means it is best
suited for images that do not contain complex colour gradations like photographs do.
Images with blocks of plain colours suit this format. The colours in the colour palette changes
according to the colours in the image, but can never be more than 256 A type of Gif image
format allows for animation.
Png
Png or Portable Network graphics is the native format for the Adobe Fireworks program. It has
a lot in common with the Gif format because it can support transparency and is a lossless saving
format. It comes in two versions, 8 bit and 24 bit. The 24 bit version can support many more
colours than Gif - about 16 million. The 8 bit version uses many fewer, so like Gif it is suitable
for plain colours rather than tonal gradations. File sizes compared to jpegs are large when
saving photos in this format, even though compression is an option when saving.
12
20. Noise Reduction In images Using Filters
3.5 SPATIAL FILTERING
A spatial filter is an image operation where each pixel value I(u, v) is changed by a function of
the intensities of pixels in a neighborhood of (u, v).The filter is actually a mask of weights
arranged in a rectangular pattern, see next Figure . The process is one of sliding the mask along
the image and performing a multiply and accumulate operation on the pixels covered by the
mask.
3 x 3 Spatial Mask
3.6 FREQUENCYFILETRING
The commonest form of filtering is to remove unwanted frequency components from the data
by band pass frequency filtering. This may be to remove frequencies above the NY Quist before
re-sampling or to remove noise types e.g. low frequency swell noise from the data. Most
commonly band pass filters are applied post-migration to improve the clarity of the display.
While filters can be applied in several domains they are usually designed in the frequency
domain for clarity. They may be applied in the time domain by convolution or in the frequency
domain by multiplication; however this is usually transparent to the user. The user has to decide
whether to apply a minimum phase or zero-phase filter and must input sufficient parameters to
specify the pass or reject bandwidth.
3.7 NOISE
Noise usually quantified by the percentage of pixels which arecorrupted. Corrupted pixels are
either set to the maximum value or have single bits. There are several ways that noise can be
introduced into an image, depending on how the image has been created. For instance:
• If the image is scanned from a photograph made on film, the film grain is a source of noise.
Noise may also be the result of damage to the film, or be introduced by the scanner itself.
13
21. Noise Reduction In images Using Filters
• If the image is acquired directly in a digital format, the mechanism for gathering the data
(such as a CCD detector) can introduce noise.
• Electronic transmission of image data can make noise.
3.7.2TypesofNoise
Noise to be any degradation in the image signal caused by external disturbance. If an image is
being sent electronically from one place to another via satellite or wireless transmission or
through networked cables, we may expect errors to occur in the image signal. These errors will
appear on the image output in different ways depending on the type of disturbance in the signal.
Usually we know what type of errors to expect and the type of noise on the image, hence we
investigate some of the standard noise for eliminating or reducing noise in color image .Image
Noise is classified as Amplifier noise (Gaussian noise), Salt-and-pepper noise (Impulse
noise),Speckle noise (Multiplicative noise) and Periodic noise.
1.GaussianNoise
In Gaussian noise, the value of each pixel gets changes by a small amount from its original
value. A histogram is a graphical representation of the data distribution. It represents the
frequencies shown by the rectangles, having an area equal to the frequency of observations
.The total area of the histogram is equal to the number of observations. The histogram shows a
normal noise distribution. The Gaussian model is a good model because of the central limit
theorem which states that the sum of all different noises represents Gaussian distribution.
2.Saltand PepperNoise
The salt and pepper noise is a type of impulse noise. It is a noise which is seen mostly in images.
It contains black pixels on white background and white pixels on black background. One
important feature of this noise is the weight or value of the noisy pixel has no connection or
relation with the color of the neighbor pixels. This type of noise generally affects a little range
of image pixels. When this type of pixel is viewed, it looks like black and white dots. Sources
of this type of noise are dust in the camera andoverheated or defective elements. There are only
twopossible values exists that is a and b and the probability of each is less than 0.2
Reasons for Salt and Pepper Noise:
By memory cell failure.
14
22. Noise Reduction In images Using Filters
By malfunctioning of camera’s sensor cells.
By synchronization errors in image digitizing or transmission.
3.SpeckleNoise(Multiplicative Noise)
While Gaussian noise can be modeled by random values added to an image, speckle noise can
be modeled by random values multiplied by pixel values hence it is also called multiplicative
noise. Speckle noise is a major problem in some radar applications. It results from random
fluctuations in the return signal from an object that is no bigger than a single image-processing
element.
4.Shot Noise(Poisson Noise)
The dominant noise in the lighter parts of an image from an image sensor is typically that
caused by statistical quantum fluctuations, that is, variation in the number of photons sensed at
a given exposure level; this noise is known as photon shot noise. Shot noise has a root-mean-
square value proportional to the square root of the image intensity, and the noises at different
pixels are independent of one another. Shot noise follows a Poisson distribution, which is
usually not very different from Gaussian. In addition to photon shot noise, there can be
additional shot noise from the dark leakage current in the image sensor; this noise is otherwise
known as "dark shot noise" or "dark-current shot noise".
3.8NOISE REDUCTION
Image noise is an unavoidable side-effect occurring as a result of image capture, more simply
understood as inaudible, yet inevitable fluctuations. In a digital camera, if the light which enters
the lens misaligns with the sensors, it will create image noise. Even if noise is not so obviously
visible in a picture, some kind of image noise is bound to exist. Every type of electronic device
receives and transmits some noise and sends it on to what it is creating.
When the images are transmitted over channels, they are corrupted with impulse noise due to
noisy channels. This impulse noise consists of large positive and negative spikes. The positive
spikes have values much larger than the background and thus they appear as bright spots, while
15
23. Noise Reduction In images Using Filters
the negative spikes have values smaller than the background and they appear as darker spots.
Both the spots for the positive and negative spikes are visible to the human eye. Also, Gaussian
type of noise affects the image. Thus, filters are required for removing noises before processing.
There are lots of filters in the paper to remove noise. They are of many kinds as linear
smoothing filter, median filter, wiener filter and Fuzzy filter.
3.8.2 Linear Filters
Linear filter used to remove certain types of noise. Averaging or Gaussian filters are
appropriate for this purpose. Linear filters also tend to blur sharp edges, destroy lines and other
fine image details, and perform poorly in the presence of signal-dependent noise.
1.Average Filter(Mean Filter)
Average or mean filter is the most simple and the easiest method to implement the smoothing
of images i.e. minimizing the extent of intensity variation among neighboring pixels. It is also
used to minimize noise in images frequently. In this method the filtering concept is to replace
the processing pixel element value in an image matrix with the average value of its neighbors
including itself. Repeatedly it removes those pixel values which are not representing their
surroundings.
Average filter is somewhat equivalent to the convolution filter. This filter also relies on kernel
to represent the shape and size of the vicinity to be sampled while mean is calculated. 3X3
square kernel is frequent in practice ,however in the cases where the demand of high smoothing
comes one can use larger kernels like 5X5, 7X7 etc.Average Filter reads the input image and
sets the image header information for the output image. It applies the smoothing algorithm and
sets the output image as input for the next iteration if it’s not the last iteration and writes the
output image after completion of all the iterations.The mean algorithm works by adding all the
surrounding orneighbor pixel values and takes the mean or average of thosevalues. The
resulting value is placed in the central pixel.
Computing the straightforward convolution of an image with this kernel carries out the mean
filtering process .
5 + 3 + 6 + 2 + 1 + 9 + 8+ 4 + 7 = 45.
45 / 9 = 5.
16
15
15
24. Noise Reduction In images Using Filters
Center value (previously 1) is replaced by the mean of all ninevalues (5).
2.Adaptive Filter(Wiener Filter)
The wiener function applies a Wiener filter (a type of linear filter) to an image adaptively,
tailoring itself to the local image variance. If the variance is large, wiener performs little
smoothing. If it is small,wiener performs more smoothing. This approach often produces better
results than linear filtering. The adaptive filter is more selective than a comparable linear filter,
preserving edges and other high-frequency parts of an image. In addition, there are no design
tasks; the wiener2 function handles all preliminary computations and implements the filter for
an input image. wiener2, however, does require more computation time than linear filtering.
Wiener works best when the noise is constant-power ("white") additive noise, such as Gaussian
noise. Another method for removing noise is to evolve the image under a smoothing partial
differential equation similar to the heat equation which is called anisotropic diffusion.
The Fourier domain of the Wiener filter is where :
H*(u, v) = Complex conjugate of degradation function
Pn (u, v) = Power Spectral Density of Noise
Ps (u, v) = Power Spectral Density of non-degraded image
H (u, v) = Degradation function
3.MedianFilter
The median filter is normally used to reduce noise in an image, somewhat like the mean filter.
However, median filter is much better than mean filter as it preserves the important details of
the image such as edges. The median filter works like a mean filter only. It considers each pixel
17
25. Noise Reduction In images Using Filters
of the image and checks whether that particular pixel is the representative of its nearby
neighbors or not.
Instead of replacing the value of the pixel with the mean of its neighbor pixel values. It replaces
by the median of the neighbor pixel values.
The median is calculated by first sorting all the pixel values from the surrounding neighborhood
into numerical order and then replacing the pixel being considered with the middle pixel value.
If the neighbors of the center pixel are in even number then the mean of the two middle pixel
values are used.
Neighbor values-115,119,120,123,124,125,126,127,150
Average value-124
The median filter is normally used to reduce salt and pepper noise in an image, somewhat like
the mean filter. However, it often does a better job than the mean filter of preserving useful
detail in the image.
4. Geometric MeanFilter
In the geometric mean method, the color value of each pixel is replaced with the geometric
mean of color values of the pixels in a surrounding region. A larger region (filter size) yields a
stronger filter effect with the drawback of some blurring.
The geometric mean is defined as:
The geometric mean filter is better at
removing Gaussian type noise and preserving edge features than the arithmetic mean filter.
The geometric mean filter is very susceptible to negative outliers.
16
18
26. Noise Reduction In images Using Filters
5.Harmonic MeanFilter
In the harmonic mean method, the color value of each pixel is replaced with the harmonic mean
of color values of the pixels in a surrounding region. The harmonic mean is defined as:
A larger region (filter size) yields a stronger filter effect with the drawback of some blurring.
The harmonic mean filter is better at removing Gaussian type noise and preserving edge
features than the arithmetic mean filter. The harmonic mean filter is very good at removing
positive outliers.
3.9PerformanceParameters:
For comparing original image and filtered image, we calculate following parameters:
Mean Square Error (MSE):The MSE is the cumulative square error between the encoded
and the original image defined by:
Where, f is the original image and g is the filtered image. The dimension of the images is m x
n. Thus MSE should be as low as possible for effective filtering.
19
27. Noise Reduction In images Using Filters
Signal to Noise Ratiois defined by the power ratio between a signal and the background noise.
WhereP is average power. Both noise and power must be measured at the same points in a
system, and within system with same bandwidth.
Peak signal to Noise ratio (PSNR):
It is defined by:
PSNR = 10 log (255^2/mse)
20
28. Noise Reduction In images Using Filters
DESIGN
4.1 Flow Chart:
Input the Image .
Convert to grey scale Image
21
29. Noise Reduction In images Using Filters
4.2 Program Component
Load
Apply noise
Display the image with noise
Histogram of the image with
noise
Apply filter
Display the filtered Image
Histogram of Filtered Image
Evaluate the PSNR value
22
30. Noise Reduction In images Using Filters
This feature enables the user to select a picture from the various folders in the
system and once the picture has been selected by the user this feature converts
the selected image into a greyscale image and loads both the original and the
converted image on the workspace in the editor.
Noise
This feature group enables the user to select one noise at a time and displays the
image with noise and its respective histogram.
Filter
This feature group enables the user to select one filter at a time and displays the
filtered image with its histogram.
Close
This feature enables the user to close all the figure windows.
23
31. Noise Reduction In images Using Filters
PROGRAM CODE
function varargout = reduction(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @reduction_OpeningFcn, ...
'gui_OutputFcn', @reduction_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
24
32. Noise Reduction In images Using Filters
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function reduction_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = reduction_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function original_img_Callback(hObject, eventdata, handles)
function original_img_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function browse_Callback(hObject, eventdata, handles)
[f,pathname]=uigetfile({'*.*','All Files(*.*)'},'Select your file');
original_img=strcat(pathname,f);
input=importdata(original_img);
axes(handles.disp1);
imshow(input);
input1=rgb2gray(input);
axes(handles.noiseimg);
imshow(input1);
save('input1');
function noise_SelectionChangeFcn(hObject, eventdata, handles)
switch get(eventdata.NewValue,'Tag')
case 'speckle'
load('input1');
noise_img=imnoise(input1,'speckle');
figure,subplot(1,2,1), imshow(noise_img),title('Speckle Noise added to the Image');
subplot(1,2,2),imhist(noise_img),title('Histogram of Noised Image');
save('noise_img')
25
33. Noise Reduction In images Using Filters
case 'gaussian'
load('input1');
noise_img=imnoise(input1,'gaussian');
figure, subplot(1,2,1), imshow(noise_img),title('Gaussian Noise added to the Image');
subplot(1,2,2),imhist(noise_img),title('Histogram of Noised Image');
save('noise_img')
case 'sp'
load('input1');
noise_img=imnoise(input1,'salt & pepper');
figure, subplot(1,2,1), imshow(noise_img),title('Salt and Pepper Noise added to the
Image');
subplot(1,2,2),imhist(noise_img),title('Histogram of Noised Image');
save('noise_img');
case 'poisson'
load('input1');
noise_img=imnoise(input1,'poisson');
figure, subplot(1,2,1), imshow(noise_img),title('Poisson added to the Image');
subplot(1,2,2),imhist(noise_img),title('Histogram of Noised Image');
save('noise_img');
end
function filter_SelectionChangeFcn(hObject, eventdata, handles)
switch get(eventdata.NewValue,'Tag')
case 'median'
load('noise_img');
filtered_img = medfilt2(noise_img,[3 3]);
n=size(noise_img);
figure,subplot(1,2,1), imshow(filtered_img),title('Noise reduction using Median
filter');
subplot(1,2,2),imhist(noise_img),title('Histogram of filtered Image');
save('filtered_img');
case 'wiener'
load('noise_img');
filtered_img = wiener2(noise_img,[5 5]);
figure, subplot(1,2,1), imshow(filtered_img),title('Noise reduction using Wiener filter');
subplot(1,2,2),imhist(noise_img),title('Histogram of filtered Image');
save('filtered_img');
case 'avg'
load('noise_img');
26
34. Noise Reduction In images Using Filters
fil=fspecial('average',[3 3]);
filtered_img=imfilter(noise_img,fil);
figure,subplot(1,2,1), imshow(filtered_img),title('Noise reduction using Average filter');
subplot(1,2,2),imhist(filtered_img),title('Histogram of filtered Image');
save('filtered_img');
case 'gm'
load('noise_img');
noise1=im2double(noise_img);
[m n]=size(noise1);
si=1;
for i=1:m
for j=1:n
con=0;
s1=1;
for k1=i-si:i+si
for p1 = j-si:j+si
if((k1 > 0 && p1 > 0) && (k1 < m && p1<n))
con=con+1;
s1=s1*noise1(k1,p1);
end
end
end
filteredimg(i,j)=s1^(1/con);
end
end
figure,subplot(1,2,1), imshow(filteredimg),title('Noise reduction using Geometric filter');
subplot(1,2,2),imhist(filteredimg),title('Histogram of filtered Image');
case 'hm'
load('noise_img');
noise1=im2double(noise_img);
[m n]=size(noise1);
si=1;
for i=1:m
for j=1:n
con=0;
s1=0;
for k1=i-si:i+si
for p1 = j-si:j+si
if((k1 > 0 && p1 > 0) && (k1 < m && p1<n))
con=con+1;
if noise1(k1,p1)== 0
s1=s1+0;
else
s1=s1+(1/noise1(k1,p1));
end
end
end
27
35. Noise Reduction In images Using Filters
end
filteredimg(i,j)=con/s1;
end
end
figure,subplot(1,2,1), imshow(filteredimg),title('Noise reduction using Harmonic
filter');
subplot(1,2,2),imhist(filteredimg),title('Histogram of filtered Image');
case 'adp'
load('noise_img');
load('input1');
sz=size(input1,1)*size(input1,2);
noise_img1=double(noise_img);
m=5;
n=5;
c=padarray(noise_img1,[round(m/2),round(n/2)]);
lvar=zeros([size(noise_img1,1) size(noise_img1,2)]);
lmean=zeros([size(noise_img1,1) size(noise_img1,2)]);
temp=zeros([size(noise_img1,1) size(noise_img1,2)]);
newimg=zeros([size(noise_img1,1) size(noise_img1,2)]);
for i=1:size(c,1)-m-1
for j=1:size(c,2)-n-1
temp=c(i:i+(m-1),j:j+(n-1));
tmp=reshape(temp,[1,(m*n)]);
lmean(i,j)=mean(tmp);
lvar(i,j)=mean(tmp.^2)-mean(tmp).^2;
end
end
nvar=sum(lvar(:))/sz;
lvar=max(lvar,nvar);
newimg=nvar./lvar;
newimg=newimg.*(noise_img1-lmean);
filteredimg=noise_img1-newimg;
filteredimg=uint8(filteredimg);
figure,subplot(1,2,1), imshow(filteredimg),title('Noise reduction using Adaptive filter');
subplot(1,2,2),imhist(filteredimg),title('Histogram of filtered Image');
end
close all;
function varargout = untitled(varargin)
28
36. Noise Reduction In images Using Filters
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function load1_Callback(hObject, eventdata, handles)
[f,pathname]=uigetfile({'*.*','All Files(*.*)'},'Select your file');
original_img=strcat(pathname,f);
image=importdata(original_img);
axes(handles.imgload);
imshow(image);
image1=rgb2gray(image);
axes(handles.imgload1);
imshow(image1);
save('image1');
m=n(1);
q=n(2);
MSE=sum(sum((image1-filtered_img).^2))/(m*q);
PSNR=10*log10(255*255/MSE);
figure,subplot(1,2,1), imshow(filtered_img),title('Noise reduction using Average filter');
subplot(1,2,2),imhist(filtered_img),title('Histogram of filtered Image');
message = sprintf(' The PSNR = %.2f',PSNR);
msgbox(message);
case 'gm'
load('image1');
noise1=im2double(image1);
29
37. Noise Reduction In images Using Filters
[m n]=size(noise1);
si=1;
for i=1:m
for j=1:n
con=0;
s1=1;
for k1=i-si:i+si
for p1 = j-si:j+si
if((k1 > 0 && p1 > 0) && (k1 < m && p1<n))
con=con+1;
s1=s1*noise1(k1,p1);
end
end
end
filteredimg(i,j)=s1^(1/con);
end
end
figure,subplot(1,2,1), imshow(filteredimg),title('Noise reduction using Geometric filter');
subplot(1,2,2),imhist(filteredimg),title('Histogram of filtered Image');
filteredimg1=im2double(filteredimg);
n=size(noise1);
m=n(1);
q=n(2);
MSE=sum(sum((noise1-filteredimg1).^2))/(m*q);
PSNR=10*log10(255*255/MSE);
message = sprintf(' The PSNR = %.2f',PSNR);
msgbox(message);
case 'hm'
load('image1');
noise1=im2double(image1);
[m n]=size(noise1);
si=1;
for i=1:m
for j=1:n
con=0;
s1=0;
for k1=i-si:i+si
for p1 = j-si:j+si
if((k1 > 0 && p1 > 0) && (k1 < m && p1<n))
con=con+1;
if noise1(k1,p1)== 0
s1=s1+0;
else
s1=s1+(1/noise1(k1,p1));
30
38. Noise Reduction In images Using Filters
end
end
end
end
filtered_img(i,j)=con/s1;
end
end
filtered_img1=im2double(filtered_img);
n=size(noise1);
m=n(1);
q=n(2);
MSE=sum(sum((noise1-filtered_img1).^2))/(m*q);
PSNR=10*log10(255*255/MSE);
figure,subplot(1,2,1), imshow(filtered_img),title('Noise reduction using Harmonic filter');
subplot(1,2,2),imhist(filtered_img),title('Histogram of filtered Image');
message = sprintf(' The PSNR = %.2f',PSNR);
msgbox(message);
end
function close_Callback(hObject, eventdata, handles)
close all;
31
45. Noise Reduction In images Using Filters
Challenges
The project is limited to the default variance value for the different types of noise. It is also
limited to only basic noise removal techniques. The project is not made flexible to enhance an
image after the removal of noise.
Conclusion
In this project, we discussed different filtering techniques for removing noises in image.
Furthermore, we presented and compared results for these filtering techniques.The image is
given as the input, if the input image is colour image then it is converted in to gray scale in
order to reduce the processing time the contrast of input image is enhanced and the image is
denoised using various filter and the quality and accuracy is measured by PSNR and MSE
value and we evaluated the best denoised image according to these value.
This project can also be updated and made a little more accurate with use of other complex
technologies and methodologies and implemented for use of analyzing the satellite imagery.
The various unwanted things that appear in the satellite imagery like the clouds, fog, rain, etc.,
can be removed and a clear image with the clear view of the edges of land and other natural
features clearly visible.
38
47. Noise Reduction In images Using Filters
1.Pixel:A minute area of illumination on a display screen, one of many from
which an image is formed.
2.Image Acquisition:It is defined as the action of retrieving an image.
3.Hue:A color or shade.
4.Convolution:It is a small matrix used for blurring ,sharpening, embossing
and more in image processing.
5.Spike:A spike is a sharp rise in the frequency for a given variable.
6.Power Spectral Density:It is a measure of a signal’s power intensity in
the frequency domain.
7.Enhance:Intensify or increase the quality of the image.
8.Sharpening: Enhances the edges in an image.
9. Denoise:Extraction of noise from the image.
40