Anda di halaman 1dari 79

IMAGE DENOISING BY NLM

CHAPTER 1

CHAPTER -1
INTRODUCTION

IMAGE DENOISING BY NLM


PNC&VIET

CHAPTER 1
ECE-2014

Page 1

1.1 INTRODUCTION:
Over the years a variety of methods have been introduced to remove noise from digital images,
such as Gaussian filtering, anisotropic filtering, Total Variation minimization etc. However, many
of these algorithms remove the fine details and structure of the image in addition to the noise
because of assumptions made about the frequency content of the image.
The Non-Local Means algorithm does not make these assumptions, but instead assumes that the
image contains an extensive amount of redundancy. These redundancies can then be exploited to
remove the noise in the image. Previous methods attempt to separate the image into the smooth
part (true image) and the oscillatory part (noise) by removing the higher frequencies from the
lower frequencies.
However, not all images are smooth. Images can contain fine details and structures which
have high frequencies. When the high frequencies are removed, the high frequency content of the
true image will be removed along with the high frequency noise because the methods cannot
distinguish the difference between the noise and true image. This will result in a loss of fine
detail in the de-noised image.
Also, the issue to remove the low frequency noise from the image was a concern. Low
frequency noise will remain in the image even after de-noising. Due to the loss of image details,
Baudes A., Coll B., Morel J.M. have developed the Non-Local Means (NL Means) algorithm.
In this paper, NL-Means algorithm for standard database images and natural photograph
images captured by general digital camera is implemented.

IMAGE DENOISING BY NLM


PNC&VIET

CHAPTER 1
ECE-2014

Page 2

1.2 DIGITAL IMAGE PROCESSING


An image may be defined as a two-dimensional function f(x, y), where x & y are spatial
coordinates, & the amplitude of at any pair of coordinates (x, y) is called the intensity or Gray
level of the image at that point. When x, y & the amplitude values of f are all finite discrete
quantities, we call the image a digital image. The field of DIP refers to processing digital image
by means of digital computer. Digital image is composed of a finite number of elements, each of
which has a particular location & value. The elements are called pixels.
Vision is the most advanced of our sensor, so it is not surprising that image play the single
most important role in human perception. However, unlike humans, who are limited to the visual
band of the EM spectrum imaging machines cover almost the entire EM spectrum, ranging from
gamma to radio waves. They can operate also on images generated by sources that humans are
not accustomed to associating with image.
There is no general agreement among authors regarding where image processing stops &
other related areas such as image analysis& computer vision start. Sometimes a distinction is
made by defining image processing as a discipline in which both the input & output at a process
are images. This is limiting & somewhat artificial boundary. The area of image analysis (image
understanding) is in between image processing & computer vision.
There are no clear-cut boundaries in the continuum from image processing at one end to
complete vision at the other. However, one useful paradigm is to consider three types of
computerized processes in this continuum: low-, mid-, & high-level processes. Low-level
process involves primitive operations such as image processing to reduce noise, contrast
enhancement & image sharpening. A low- level process is characterized by the fact that both its
inputs & outputs are images.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 1

ECE-2014

Page 3

Mid-level process on images involves tasks such as segmentation, description of that object to
reduce them to a form suitable for computer processing &classification of individual objects. A
mid-level process is characterized by the fact that its inputs generally are images but its outputs
are attributes extracted from those images.
Finally higher- level processing involves Making sense of an ensemble of recognized
objects, as in image analysis & at the far end of the continuum performing the cognitive
functions normally associated with human vision.Digital image processing, as already defined is
used successfully in a broad range of areas of exceptional social & economic value.

1.3 IMAGE
An image is represented as a two dimensional function f(x, y) where x and y are spatial coordinates and the amplitude of f at any pair of coordinates (x, y) is called the intensity of the
image at that point.

Gray scale image:


A grayscale image is a function I(xylem) of the two spatial coordinates of the image plane.
I(x, y) is the intensity of the image at the point (x, y) on the image plane.
I (xylem)takes non-negative values assume the image is bounded by arectangle[0, a] [0,
b]I: [0, a] [0, b] [0, info)

Color image:
It can be represented by three functions, R (xylem)for red,G (xylem)for green and B
(xylem)for blue.An image may be continuous with respect to the x and y coordinates and

also

in amplitude.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 1

ECE-2014

Page 4

Converting such an image to digital form requires that the coordinates as well as the
amplitude to be digitized. Digitizing the coordinates values is calledsampling. Digitizing the
amplitude values is called quantization.

Coordinate convention:
The result of sampling and quantization is a matrix of real numbers. We use two principal ways
to represent digital images. Assume that an image f(x, y) is sampled so that the resulting image
has M rows and N columns. We say that the image is of size M X N. The values of the
coordinates (xylem) are discrete quantities.
For notational clarity and convenience, we use integer values for these discrete
coordinates. In many image processing books, the image origin is defined to be at
(xylem)=(0,0).The next coordinate values along the first row of the image are (xylem)=(0,1).It is
important to keep in mind that the notation (0,1) is used to signify the second sample along the
first row. It does not mean that these are the actual values of physical coordinates when the
image was sampled.
Following figure shows the coordinate convention. Note that x ranges from 0 to M-1 and
y from 0 to N-1 in integer increments. The coordinate convention used in the toolbox to denote
arrays is different from the preceding paragraph in two minor ways. First, instead of using
(xylem) the toolbox uses the notation (race) to indicate rows and columns.
Note, however, that the order of coordinates is the same as the order discussed in the
previous paragraph, in the sense that the first element of a coordinate topples, (alb), refers to a
row and the second to a column. The other difference is that the origin of the coordinate system
is at (r, c) = (1, 1); thus, r ranges from 1 to M and c from 1 to N in integer increments. IPT
documentation refers to the coordinates.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 1

ECE-2014

Page 5

Less frequently the toolbox also employs another coordinate convention called spatial
coordinates which uses x to refer to columns and y to refers to rows. This is the opposite of our
use of variables x and y.

Image as Matrices:
The preceding discussion leads to the following representation for a digitized image
function:
f (0, 0)

f (0, 1)

..

f (0, N-1)

f (1, 0)

f (1, 1)

f (1, N-1)

f (xylem) =

.
.

.
.

f (M-1, 0) f (M-1, 1) f (M-1, N-1)


The right side of this equation is a digital image by definition. Each element of this
array is called an image element, picture element, pixel or pxl. The terms image and pixel are
used throughout the rest of our discussions to denote a digital image and its elements.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 1

ECE-2014

Page 6

A digital image can be represented naturally as a MATLAB matrix:


f (1, 1) f (1, 2) . f (1, N)
f (2, 1)

f (2, 2) .. f (2, N)
.

f=

.
.

.
.

f (M, 1) f (M, 2) .f (M, N)


Where f (1, 1) = f (0, 0) (note the use of a monoscope font to denote MATLAB
quantities). Clearly the two representations are identical, except for the shift in origin. The
notation f (p, q) denotes the element located in row p and the column q.
For example f (6, 2) is the element in the sixth row and second column of the matrix f.
typically we use the letters M and N respectively to denote the number of rows and columns in a
matrix. A 1xN matrix is called a row vector whereas an Mx1 matrix is called a column vector. A
1x1 matrix is a scalar.
Matrices in MATLAB are stored in variables with names such as A, a, RGB, real array and
so on. Variables must begin with a letter and contain only letters, numerals and underscores. As
noted in the previous paragraph, all MATLAB quantities are written using monoscope characters.
We use conventional Roman, italic notation such as f(x, y), for mathematical expressions

IMAGE DENOISING BY NLM

CHAPTER 1

Reading Images
PNC&VIET

ECE-2014

Page 7

Images are read into the MATLAB environment using function imread whose syntax is
imread(filename)
Format name
TIFF

Description
Tagged Image File Format

recognized extension
.tif, .tiff

JPEG

Joint Photograph Experts Group

.jpg, .jpeg

GIF

Graphics Interchange Format

.gif

BMP

Windows Bitmap

.bmp

PNG

Portable Network Graphics

XWD

X Window Dump

.png
.xwd

Here filename is a spring containing the complete of the image file(including any
applicable extension).For example the command line
>> f = imread (8. jpg);
Reads the JPEG (above table) image chestxray into image array f. Note the use of single
quotes () to delimit the string filename. The semicolon at the end of a command line is used by
MATLAB for suppressing output.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 1

ECE-2014

Page 8

If a semicolon is not included.MATLAB

displays the results

of the operation(s)

specified in that line. The prompt symbol(>>) designates the beginning of a command line, as it
appears in the MATLAB command window.
When as in the preceding command line no path is included in filename, imread reads the
file from the current directory and if that fails it tries to find the file in the MATLAB search path.
The simplest way to read an image from a specified directory is to include a full or relative path
to that directory in filename.
For example,
>> f = imread (D:\my images\chestxray.jpg);
Reads the image from a folder called my images on the D: drive, whereas
>> f = imread (. \ my images\chestxray .jpg);
Reads the image from the my images subdirectory of the current of the current working
directory. The current directory window on the MATLAB desktop toolbar displays MATLABs
current working directory and provides a simple, manual way to change it. Above table lists
some of the most of the popular image/graphics formats supported by imread and imwrite.

Function size gives the row and column dimensions of an image:


>>Size (f)
Ans = 1024 * 1024

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 1

ECE-2014

Page 9

This function is particularly useful in programming when used in the following form to
determine automatically the size of an image:
>>[M,N]=size(f);
This syntax returns the number of rows(M) and columns(N) in the image.
The whole function displays additional information about an array. For instance ,the
statement
>> Whos f
Gives
Name
F

size
1024*1024

Bytes

Class

1048576

unit8 array

Grand total is 1048576 elements using 1048576 bytes


The unit8 entry shown refers to one of several MATLAB data classes. A semicolon at the
end of a line has no effect, so normally one is not used.

Displaying Images
Images are displayed on the MATLAB desktop using function imshow, which has the basic
syntax:
Imshow (f,g)

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 1

ECE-2014

Page 10

Where f is an image array and g is the number of intensity levels used to display it.
If g is omitted, it defaults to 256 levels .using the syntax: Imshow (f, {low high}) Displays as
black all values less than or equal to low and as white all values greater than or equal to high.
The values in between are displayed as intermediate intensity values using the default number of
levels .Finally the syntax Imshow (f,[ ])
Sets variable low to the minimum value of array f and high to its maximum value. This
form of imshow is useful for displaying images that have a low dynamic range or that have
positive and negative values.
Function pixval is used frequently to display the intensity values of individual pixels
interactively. This function displays a cursor overlaid on an image. As the cursor is moved over
the image with the mouse the coordinates of the cursor position and the corresponding intensity
values are shown on a display that appears below the figure window .When working with color
images, the coordinates as well as the red, green and blue components are displayed. If the left
button on the mouse is clicked and then held pressed, Pixval displays the Euclidean distance
between the initial and current cursor locations.
The syntax form of interest here is Pixval which shows the cursor on the last image
displayed. Clicking the X button on the cursor window turns it off. The following statements
read from disk an image called rose_512.tif extract basic information about the image and
display it using imshow:
>>f=imread (rose_512.tif);
>>whos f
Name

Size

Bytes

Class

IMAGE DENOISING BY NLM

512*512

PNC&VIET

262144

CHAPTER 1

unit8 array
ECE-2014

Page 11

Grand total is 262144 elements using 262144 bytes


>>imshow (f)
A semicolon at the end of an imshow line has no effect, so normally one is not used.
If another image,g, is displayed using imshow, MATLAB replaces the image in the screen with
the new image. To keep the first image and output a second image, we use function figure as
follows:
>>figure ,imshow(g)
Using the statement
>>imshow(f),figure ,imshow(g) displays both images.
Note that more than one command can be written on a line ,as long as different commands
are properly delimited by commas or semicolons. As mentioned earlier, a semicolon is used
whenever it is desired to suppress screen outputs from a command line.
Suppose that we have just read an image h and find that using imshow produces the image.
It is clear that this image has a low dynamic range, which can be remedied for display purposes
by using the statement.
>>imshow (h, [ ])

IMAGE DENOISING BY NLM

CHAPTER 1

WRITING THE IMAGE

PNC&VIET

ECE-2014

Page 12

Images are written to disk using function imwrite, which has the following basic syntax:
Imwrite (f,filename)
With this syntax, the string contained in filename must include a recognized file format extension
.Alternatively; the desired format can be specified explicitly with a third input argument.
>>imwrite (f,patient10_run1,tif)Or alternatively
For example the following command writes f to a TIFF file named patient10_run1:
>>imwrite(f,patient10_run1.tif)
If filename contains no path information, then imwrite saves the file in the current working
directory.
The imwrite function can have other parameters depending on e file format selected. Most
of the work in the following deals either with JPEG or TIFF images ,so we focus attention here
on these two formats.
More general imwrite syntax applicable only to JPEG images is
imwrite (f,filename.jpg,,quality,q)
Where q is an integer between 0 and 100(the lower number the higher the degradation due to
JPEG compression).

IMAGE DENOISING BY NLM

CHAPTER 1

For example, for q=25 the applicable syntax is


>>imwrite(f,bubbles25.jpg,quality,25)
PNC&VIET

ECE-2014

Page 13

The image for q=15 has false contouring that is barely visible, but this effect becomes quite
pronounced for q=5 and q=0.Thus, an expectable solution with some margin for error is to
compress the images with q=25.In order to get an idea of the compression achieved and to obtain
other image file details, we can use function imfinfo which has syntax.
Imfinfo filename
Here filename is the complete file name of the image stored in disk.
For example,
>> Imfinfo bubbles25.jpg
Outputs the following information (note that some fields contain no information in this

case):

Filename: bubbles25.jpg
FileModDate: 04-jan-2003 12:31:26
FileSize:

13849

Format: jpg
Format Version:
Width:

714

IMAGE DENOISING BY NLM

Height:

CHAPTER 1

682

Bit Depth:

Color Depth: grayscale


PNC&VIET

ECE-2014

Page 14

Format Signature:
Comment:

{}

Where file size is in bytes. The number of bytes in the original image is corrupted simply
by multiplying width by height by bit depth and dividing the result by 8. The result is
486948.Dividing this file size gives the compression ratio:(486948/13849)=35.16.This
compression ratio was achieved. While maintaining image quality consistent with the
requirements of the appearance. In addition to the obvious advantages in storage space, this
reduction allows the transmission of approximately 35 times the amount of UN compressed data
per unit time.
The information fields displayed by imfinfo can be captured in to a so called structure
variable that can be for subsequent computations. Using the receding an example and assigning
the name K to the structure variable.
We use the syntax

>>K=imfinfo (bubbles25.jpg);

To store in to variable K all the information generated by command imfinfo, the


information generated by imfinfo is appended to the structure variable by means of fields,
separated from K by a dot. For example, the image height and width are now stored in structure
fields K. Height and K. width.

IMAGE DENOISING BY NLM

CHAPTER 1

As an illustration, consider the following use of structure variable K to commute the


compression ratio for bubbles25.jpg:
>> K=imfinfo (bubbles25.jpg);

PNC&VIET

ECE-2014

Page 15

>> Image_ bytes =K.Width* K.Height* K.Bit Depth /8;


>> Compressed_ bytes = K.FilesSize;
>> Compression_ ratio=35.162
Note that iminfo was used in two different ways. The first was t type imfinfo bubbles25.jpg
at the prompt, which resulted in the information being displayed on the screen. The second was
to type K=imfinfo (bubbles25.jpg),which resulted in the information generated by imfinfo
being stored in K.
These two different ways of calling imfinfo are an example of command function duality,
an important concept that is explained in more detail in the MATLAB online documentation.
More general imwrite syntax applicable only to tif images has the form Imwrite
(g,filename.tif,compression,rameter,.resloutionpa,[colres rowers] )
Where parameter can have one of the following principal values: none indicates no
compression, pack bits indicates pack bits compression (the default for none binary images)
and ccitt indicates ccitt compression. (The default for binary images).
The 1*2 array [colres rowers]Contains two integers that give the column resolution and
row resolution in dot per_ unit (the default values).

IMAGE DENOISING BY NLM

CHAPTER 1

For example, if the image dimensions are in inches, colres is in the number of
dots(pixels)per inch (dpi) in the vertical direction and similarly for rowers in the horizontal
direction. Specifying the resolution by single scalar, res is equivalent to writing [res res].
>>imwrite(f,sf.tif,compression,none,resolution,..[300 300])
PNC&VIET

ECE-2014

Page 16

the values of the vector[colures rows] were determined by multiplying 200 dpi by the ratio
2.25/1.5, which gives 30 dpi. Rather than do the computation manually, we could write
>>res=round(200*2.25/1.5);
>>imwrite (f,sf.tif,compression,none,resolution,res)
Where its argument to the nearest integer.It function round rounds is important to note that the
number of pixels was not changed by these commands. Only the scale of the image changed. The
original 450*450 image at 200 dpi is of size 2.25*2.25 inches. The new 300_dpi image is
identical, except that is 450*450 pixels are distributed over a 1.5*1.5_inch area. Processes such
as this are useful for controlling the size of an image in a printed document without sacrificing
resolution.
Often it is necessary to export images to disk the way they appear on the MATLAB
desktop. This is especially true with plots .The contents of a figure window can be exported to
disk in two ways. The first is to use the file pull-down menu is in the figure window and then
choose export. With this option the user can select a location, filename, and format. More control
over export parameters is obtained by using print command:

Print-fno-dfileformat-rresno

filename.

IMAGE DENOISING BY NLM

CHAPTER 1

Where no refers to the figure number in the figure window interest, file format refers one of the
file formats in table above. Resno is the resolution in dpi, and filename is the name we wish to
assign the file. If we simply type print at the prompt, MATLAB prints (to the default printer) the
contents of the last figure window displayed. It is possible also to specify other options with
print, such as specific printing device.

PNC&VIET

ECE-2014

Page 17

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 2

ECE-2014

Page 18

CHAPTER-2
LITERATURE SURVEY

IMAGE DENOISING BY NLM

CHAPTER 2

LITERATURE SURVEY
Literature survey 1:
Name of author:Jin Wang; YanwenGuo; Yiting Ying; Yanli Liu; QunshengPeng,
Name of the title:Fast Non-Local A1gorithm for Image De noising.
Year of publishing:8- l1 October 2006.
Source of the publishing: Atlanta, USA.
PNC&VIET

ECE-2014

Page 19

Abstract :
For the non-local denoising approach presented by Buades et al., remarkable denoising results
are obtained at high expense of computational cost. In this paper, a new algorithm that reduces
the computational cost for calculating the similarity of neighborhood windows is proposed. We
first introduce an approximate measure about the similarity of neighborhood windows, then we
use an efficient summed square image (SSI) scheme and fast Fourier transform (FFT) to
accelerate the calculation of this measure. Our algorithm is about fifty times faster than the
original non-local algorithm both theoretically and experimentally, yet produces comparable
results in terms of mean-squared error (MSE) and perceptual image quality.

IMAGE DENOISING BY NLM

CHAPTER 2

Literature survey 2:
Name of author:Buades, A, ColI, B, Morel J.M
Name of the title:A non-local algorithm for imaged noising
Year of publishing:20-26 June 2005
Source of the publishing: San Diego, CA, USA..
ABSTRCT:

PNC&VIET

ECE-2014

Page 20

We propose a new measure, the method noise, to evaluate and compare the performance of
digital image denoising methods. We first compute and analyze this method noise for a wide
class of denoising algorithms, namely the local smoothing filters. Second, we propose a new
algorithm, the nonlocal means (NL-means), based on a nonlocal averaging of all pixels in the
image. Finally, we present some experiments comparing the NL-means algorithm and the local
smoothing filters.

IMAGE DENOISING BY NLM

CHAPTER 2

Literature survey 3:
Name of author:Quing Xu, Hailin Jiang, Rieeardo Seopigno, Mateu Sbert,
Name of the title:A New Approach for Very Dark Video De noising and Enhancement"
Year of publishing:Proceding of IEEE 17th International Conference on Image Processing,
26-29 September 2010

Source of the publishing: Hong Kong.


ABSTRCT:
PNC&VIET

ECE-2014

Page 21

The paper presents a novel three-stage algorithm for very-low-light video denoising and
enhancement. The proposed technique invokes twice, in the first and the third stages, the wellknown Non-Local Means (NLM) method for spatial and temporal denoising: it is well adapted to
the application, leading to the definition of a novel NLM tool. The intermediate stage performs a
custom tone adjustment specifically aimed at enlarging the dynamic range of very dark videos.
The overall approach transforms very dark videos into more watchable ones, effectively reduces
very high noise, and all in all, produces high quality restored image sequences outperforming the
recent state-of-the-art results. Additionally, the first and third stages can be combined as a twostep filtering scheme for normal-light videos: the novel denoising solution achieves a heavy
noise removal, while reducing motion blur artifacts and preserving image details.

IMAGE DENOISING BY NLM

CHAPTER 2

Literature survey 4:
Name of author:Jonathan Taylor,
Name of the title:Introduction to Regression and Analysis of Variance
Robust methods

Source of the publishing:StanfordUniversity, USA.


ABSTRCT:

Vehicle routing problems have been extensively analyzed to reduce transportation costs. More
particularly, the vehicle routing problem with time windows (VRPTW) imposes the period of
time of customer availability as a constraint, a very common characteristic in real world
PNC&VIET

ECE-2014

Page 22

situations. Using minimization of the total distance as the main objective to be fulfilled, this
work implements an efficient hybrid system which associates non-monotonic simulated
annealing to hill climbing with random restart (multi-start). Firstly, the algorithm is compared to
the best results published in the literature for the 56 Solomon instances. Then, it is shown how
statistical methods - analysis of variance and linear regression - can be used to determine the
significance degree of the system's parameters to obtain an even better and more reliable
performance.

IMAGE DENOISING BY NLM

CHAPTER 2

Literature survey 5:
Name of author:T. Chonavel
Name of the title:"Statistical Signal Processing- modeling and estimation
Year of publishing:Springer International Edition, 2002
Source of the publishing: ISBN
ABSTRCT:

An overview is provided of the several components of a research effort aimed at the development
of a theory of multiresolution stochastic modeling and associated techniques for optimal
multiscale statistical signal and image processing. A natural framework for developing such a
theory is the study of stochastic processes indexed by nodes on lattices or trees in which different
PNC&VIET

ECE-2014

Page 23

depths in the tree or lattice correspond to different spatial scales in representing a signal or
image. In particular, it is shown how the wavelet transform directly suggests such a modeling
paradigm. This perspective then leads directly to the investigation of several classes of dynamic
models and related notions of multiscale stationarity in which scale plays the role of a time-like
variable. The investigation of models on homogeneous trees is emphasized. The framework
examined here allows for consideration, in a very natural way, of the fusion of data from sensors
with differing resolutions. Also, thanks to the fact that wavelet transforms do an excellent job of
'compressing' large classes of covariance kernels, it is seen that these modeling paradigms appear
to have promise in a far broader context than one might expect.

IMAGE DENOISING BY NLM

CHAPTER 3

CHAPTER-3
NOISE

PNC&VIET

ECE-2014

Page 24

IMAGE DENOISING BY NLM

CHAPTER3

NOISE
Noise is any undesired information that contaminates an image. Noise appears in videos from a
variety of sources. In typical videos the noise can be modeled with a Gaussian ("normal"),
uniform, or salt-and-pepper ("impulse) distribution.
Noise is everywhere and thus we have to learn to live with it. Noise gets introduced into
the data via any electrical system used for storage, transmission, and/or processing. In addition,
nature will always plays a "noisy" trick or two with the data under observation. When
encountering an image corrupted with noise then it needs to improve its appearance for a specific
application.
The techniques applied are application-oriented. Also, the different procedures are
related to the types of noise introduced to the image. Some examples of noise are: Gaussian or
White, Rayleigh, Shot or Impulse, periodic, sinusoidal or coherent, uncorrelated, and granular.

PNC&VIET

ECE-2014

Page 25

When performing median filtering, each pixel is determined by the median value of all pixels in
a selected neighborhood (mask, template, and window).
The median value m of a population (set of pixels in a neighborhood) is that value in which half
of the population has smaller values than m, and the other half has larger values than m. This
class of filter belongs to the class of edge preserving smoothing filters which are non-linear
filters. These filters Smoothes the data while keeping the small and sharp details. Median
filtering is a simple and very effective noise removal filtering process. Its performance is
particularly good for removing shot noise. Shot noise consists of strong spike like isolated
values. Shown below are the original image and the same image after it has been corrupted by
shot noise at 10%. This means that 10% of its pixels were replaced by full white pixels. Also
shown are the median filtering results using 3x3 and 5x5 windows; three (3) iterations of 3x3
median filter applied to the noisy image; and finally for comparison, the result when applying a
5x5 mean filter to the noisy image.

IMAGE DENOISING BY NLM

a)Original image

CHAPTER3

b)Added Shot Noisy at 10\%

FIG-: Comparison of the original image and shot noise added


image.

PNC&VIET

ECE-2014

Page 26

a)3x3 Median Filtered

b)5x5 Median Filtered

Fig1.: Comparison of the non-linear Median filter and the linear Mean filter.

IMAGE DENOISING BY NLM

a)
PNC&VIET

CHAPTER3

b)
ECE-2014

Page 27

a)3x3 Median Filtered applied 3 times; b)5x5 Average Filter

Fig2. Comparison of the 3x3 Median filter applied 3 times and 5x5 Average Filter

3.1GAUSSIAN NOISE:
The shape of the distribution of this noise type as a function of gray level can be modeled
as a histogram and can be seen in Fig.

IMAGE DENOISING BY NLM

CHAPTER3

FIG3: Image with Gaussian noise and distribution function.

PNC&VIET

ECE-2014

Page 28

3.2 UNIFORM NOISE


The shape of the distribution of this noise type as a function of gray level can be modeled as a
histogram and can be seen in Fig.

FIG 4: Image with uniform noise and distribution function.

IMAGE DENOISING BY NLM

CHAPTER3

3.3 SALT & PEPPER NOISE:


The shape of the distribution of this noise type as a function of gray level can be modeled
as a histogram and can be seen in Fig.

PNC&VIET

ECE-2014

Page 29

FIG 5: Image with salt and pepper noise and distribution function

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER4

ECE-2014

Page 30

CHAPTER-4
FILTERS

IMAGE DENOISING BY NLM

CHAPTER4

4.1 ANALOG AND DIGITAL FILTERS

PNC&VIET

ECE-2014

Page 31

In signal processing, the function of a filter is to remove unwanted parts of the signal, such as
random noise, or to extract useful parts of the signal, such as the components lying within a
certain frequency range.
The following block diagram illustrates the basic idea.

FIG 6: block diagram illustrates the basic idea


There are two main kinds of filter, analog and digital. They are quite different in their physical
makeup and in how they work.
An analog filter uses analog electronic circuits made up from components such as
resistors, capacitors and op amps to produce the required filtering effect. Such filter circuits are
widely used in such applications as noise reduction, video signal enhancement, graphic
equalizers in hi-fi systems, and many other areas. There are well-established standard techniques
for designing an analog filter circuit for a given requirement. At all stages, the signal being
filtered is an electrical voltage or current which is the direct analogue of the physical quantity
(e.g. a sound or video signal or transducer output) involved.
A digital filter uses a digital processor to perform numerical calculations on sampled
values of the signal. The processor may be a general-purpose computer such as a PC, or a
specialized DSP (Digital Signal Processor) chip. The analog input signal must first be sampled
and digitized using an ADC (analog to digital converter).

IMAGE DENOISING BY NLM

CHAPTER 4

The resulting binary numbers, representing successive sampled values of the input signal,
are transferred to the processor, which carries out numerical calculations on them.These

PNC&VIET

ECE-2014

Page 32

calculations typically involve multiplying the input values by constants and adding the products
together. If necessary, the results of these calculations,
Which now represent sampled values of the filtered signal, are output through a DAC
(digital to analog converter) to convert the signal back to analog form. Note that in a digital filter,
the signal is represented by a sequence of numbers, rather than a voltage or current.
The following diagram shows the basic setup of such a system.

FIG 7: the basic setup of a DAC system.

4.2 ADVATAGES OF USING DIGITAL FILTER:


The following list gives some of the main advantages of digital over analog filters.
1. A digital filter is programmable, i.e. its operation is determined by a program stored in the
processor's memory. This means the digital filter can easily be changed without affecting the
circuitry (hardware). An analog filter can only be changed by redesigning the filter circuit.
2. Digital filters are easily designed, tested and implemented on a general-purpose computer or
Workstation.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER4

ECE-2014

Page 33

3. The characteristics of analog filter circuits (particularly those containing active components)
are subject to drift and are dependent on temperature. Digital filters do not suffer from these
problems, and so are extremely stable with respect both to time and temperature.
4. Unlike their analog counterparts, digital filters can handle low frequency signals accurately. As
the speed of DSP technology continues to increase, digital filters are being applied to high
Frequency signals in the RF (radio frequency) domain, which in the past was the exclusive
preserve of analog technology.
5. Digital filters are very much more versatile in their ability to process signals in a variety of
ways; this includes the ability of some types of digital filter to adapt to changes in the
Characteristics of the signal.
6. Fast DSP processors can handle complex combinations of filters in parallel or cascade
(series),Making the hardware requirements relatively simple and compact in comparison with the
equivalent analog circuitry.

4.3 LINEAR FILTERING:


Filtering is a technique for modifying or enhancing an image. For example, if filtering an image
to emphasize certain features or remove other features. Image processing operations
implemented with filtering include smoothing, sharpening, and edge enhancement.
Filtering is a neighborhood operation, in which the value of any given pixel in the output
image is determined by applying some algorithm to the values of the pixels in the neighborhood
of the corresponding input pixel. A pixel's neighborhood is some set of pixels, defined by their
locations relative to that pixel. (See Neighborhood and Block Operations for a general discussion
of neighborhood operations.)

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER4

ECE-2014

Page 34

Using Linear Filtering


Linear filtering is used to remove certain types of noise. Certain filters, such as averaging or
Gaussian filters, are appropriate for this purpose. For example, an averaging filter is useful for
removing grain noise from a photograph. Because each pixel gets set to the average of the pixels
in its neighborhood, local variations caused by grain are reduced.

4.4NONLINEAR FILTERS
Many nonlinear filters can be seen as extended linear filters. In the recent years there has been a
strong tendency towards non-linear filtering. One of the most important advances in this field is
the use of order statistics in filtering. Nonlinear filters based on ranking within a local moving
window are one of the most efficient methods for signal/image restoration and enhancement,
especially in the presence of impulsive type noise. Filtering techniques, which are based on order
statistics, are generally faster than the conventional linear filtering techniques, because they
require comparisons and no arithmetic operations.

4.5 SPATIAL DOMAIN FILTERS


Noise removal using spatial filters:
Spatial filters can be effectively used to remove various types of noise in digital videos. These
spatial filters typically operate on small neighborhoods, 3 x 3 to 11 x 11, and some can be
implemented as convolution masks.

4.5.1 Order filters


Order filters operate on small sub videos, windows, and replace the center pixel value (similar to
the convolution process). Order statistic is a technique that ranges all the pixels in sequential
order, based on gray-level value.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER4

ECE-2014

Page 35

The most useful of the order filters is the median filter. The median filter selects the
middle pixel value from the ordered set. This type of filter works best with salt-and-pepper noise.
Median filter tends to partially blur image these disadvantages eliminate adaptive median filter.
The maximum and minimum filters are two order filters that can be used for elimination
of salt-and-pepper (impulse) noise. The maximum filter selects the largest value within an
ordered window of pixel values.
Noise removal using spatial filters:
Spatial filters can be effectively used to remove various types of noise in digital videos. These
spatial filters typically operate on small neighborhoods, 3 x 3 to 11 x 11, and some can be
implemented as convolution masks.

4.5.2Median filters
Order filters operate on small sub videos, windows, and replace the center pixel value (similar to
the convolution process). Order statistic is a technique that ranges all the pixels in sequential
order, based on gray-level value.
The most useful of the order filters is the median filter. The median filter selects the
middle pixel value from the ordered set. This type of filter works best with salt-and-pepper noise.
Median filter tends to partially blur image (example of median filter applied to image
with salt & pepper noise is in Fig.1). These disadvantages eliminate adaptive median
filter(example of adaptive median filter applied to image with salt & pepper noise is in Fig.2).
The maximum and minimumfilters are two order filters that can be used for elimination
of salt-and-pepper (impulse) noise. The maximum filter selects the largest value within an
ordered window of pixel values (example of maximum filter applied to image with salt & pepper
noise is in Fig. 3).

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER4

ECE-2014

Page 36

FIG8: Image with order filter.


The median filter is popular because of its demonstrated ability to reduce random impulsive
noise without blurring edges as much as a comparable linear lowpass filter.

4.6ALGORITHM IMPLEMENTATION ISSUES


Typically, by far the majority of the computational effort and time is spent on calculating the
median of each window. Because the filter must process every entry in the signal, for large
signals such as images, the efficiency of this median calculation is a critical factor in determining
how fast the algorithm can run. The "vanilla" implementation described above sorts every entry
in the window to find the median; however, since only the middle value in a list of numbers is
required, selection algorithms can be much more efficient. Furthermore, some types of signals
(very often the case for images) use whole number representations: in these
cases, histogram medians can be far more efficient because it is simple to update the histogram
from window to window, and finding the median of a histogram is not particularly onerous.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER4

ECE-2014

Page 37

4.7 EDGE PRESERVATION PROPORTIES

Median filtering is one kind of smoothing technique, as is linear Gaussian filtering. All
smoothing techniques are effective at removing noise in smooth patches or smooth regions of a
signal, but adversely affect edges. Often though, at the same time as reducing the noise in a
signal, it is important to preserve the edges. Edges are of critical importance to the visual
appearance of images, for example. For small to moderate levels of (Gaussian) noise, the median
filter is demonstrably better than Gaussian blur at removing noise whilst preserving edges for a
given, fixed window size. However, its performance is not that much better than Gaussian blur
for high levels of noise, whereas, for speckle noise and salt and pepper noise (impulsive noise), it
is particularly effective. Because of this, median filtering is very widely used in digital image
processing.

4.8 WIENER FILTER


In signal processing, the Wiener filter is a filter used to produce an estimate of a desired or target
random process by linear time-invariant filtering an observed noisy process, assuming known
stationary signal and noise spectra, and additive noise. The Wiener filter minimizes the mean
square error between the estimated random process and the desired process.
The goal of the Wiener filter is to filter out noise that has corrupted a signal. It is based on
a statistical approach, and a more statistical account of the theory is given in the MMSE
estimatorarticle.Typical filters are designed for a desired frequency response. However, the
design of the Wiener filter takes a different approach. One is assumed to have knowledge of the
spectral properties of the original signal and the noise, and one seeks the linear timeinvariant filter whose output would come as close to the original signal as possible. Wiener filters
are characterized by the following:

IMAGEDENOISING BY NLM

PNC&VIET

CHAPTER4

ECE-2014

Page 38

1. Assumption: signal and (additive) noise are stationary linear stochastic processes with
known spectral characteristics or known autocorrelation and cross-correlation
2. Requirement: the filter must be physically realizable/causal (this requirement can be
dropped, resulting in a non-causal solution)
3. Performance criterion: minimum mean-square error (MMSE)

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER5

ECE-2014

Page 39

CHAPTER-5
DENOISING MECHANISM

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER5

ECE-2014

Page 40

DENOISING MECHANISM
Most of the imaging techniques are degraded by noise so that the image is preprocessed using
denoising technique to extract the useful information. To analyze the medical image i.e.
segmenting the brain tissues, initially the noise must be removed from the MRI image for
retaining the original information. Noise in medical imaging is mainly caused by variation in the
detector sensitivity, reduced object visibility (low contrast), chemical or photographic
limitations, and random fluctuations in radiation signal. Initially the MRI image is taken as an
input data. The MRI image is added with Gaussian Noise. The denoising is performed using
averaging filter, median filter and wiener filter. The performance of these denoising techniques is
measured using Peak Signal to Noise Ration.

5.1GAUSSIAN NOISE
Image noise is defined as the label assigned initially at any pixel arrangement will be in a
random manner. Gaussian noise is statistical noise that has its probability function equal to that
of normal distribution, also called Gaussian distribution. The mean and variance are the defining
factors. Gaussian noise whose frequency spectrum after a Fourier transform has a bell shaped
curve and is symmetric around mean. In order to test the resistance of an image and also to
evaluate the performance of the MRI brain image Gaussian noise is added and filtered using
some noise filters. Each pixel in the noisy image contains both true pixel value and random
Gaussian distribution noise value. Gaussian distribution equation is below.

Where mhu denotes mean value of x and sigma denotes std.

IMAGE DENOISING BY NLM

CHAPTER5

5.2 AVERAGING FILTER

PNC&VIET

ECE-2014

Page 41

methodofsmoothingimages.Average

filter

isoftenusedtoreducenoise

andalsoreducetheamount ofintensityvariationfromonepixeltoanother.Here,first takean average


thatissumoftheelementsand dividethesum bythenumberofelements.Next, replaceeachpixelinan
image by the average of pixels in a square window surroundingthispixel.

Fig9:the functionality behindtheaveragingfilter

5.3MEDIAN FILTER

In signal processing, it is often desirable to be able to perform some kind of noise


reduction on an image or signal. The median filter is a nonlinear digital filtering technique,
often used to remove noise. Such noise reduction is a typical pre-processing step to improve
the results of later processing (for example, edge detection on an image). Median filtering is
very widely used in digital image processing because, under certain conditions, it preserves
edges while removing noise.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER5

ECE-2014

Page 42

Fig10: Median filter functioning

The main idea of the median filter is to run through the signal entry by entry, replacing
each entry with the median of neighboring entries. The pattern of neighbors is called the
"window", which slides, entry by entry, over the entire signal. For 1D signals, the most obvious
window is just the first few preceding and following entries, whereas for 2D (or higherdimensional) signals such as images, more complex window patterns are possible (such as "box"
or "cross" patterns). Note that if the window has an odd number of entries, then the median is
simple to define: it is just the middle value after all the entries in the window are sorted
numerically.

5.4 PROPOSED DENOISING ALGORITHM


Gaussian noise is equally distributed over the signal. Impulsive noise is denoted by changing part
of an image pixel with noisy values, thisnoise affects image pixel by pixel not the whole area of
an image. Such noise is introduced during an acquisition process or due to transmission errors.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER5

ECE-2014

Page 43

Impulsive noise can be classified as fixed valued impulse noise and Variable type impulse noise.
An image containing noise can be described as follows:
x(i,j) =

{ i, j probability p

y i, j probability 1 p (1)
where x(i, j) denotes a corrupted image pixel, y(i, j) denotes a uncorrupted image pixel and (i, j)
denotes a corrupted pixel at the location (i, j).In fixed value impulse noise, corrupted pixels take
either minimum or maximum values i.e. (i, j) {Nmin , Nmax }, and for variable type
impulse
Noise,(i.e.,RVIN) corrupted pixels take any value within the range minimum to maximum value
i.e., i,j [Nmin , Nmax ] ,where Nmin and Nmax denote the lowest and the highest pixel
values within the specified range respectively .
(a) Fixed value Impulse Noise
(b) Variable type impulse Noise
Hence, it is little difficult to remove variable type impulse noise rather than fixed value
impulse noise. For the preservation of fine image details and also suppression of noise is the
main challenging phenomenon. The difference between fixed value and variable type impulse
noise are represented in.
In the case of fixed value impulse noise, the pixel is replaced with noise may be either
Nmin (0) or Nmax (255), where as in variable typeimpulse noise situation it may range from
Nmin to Nmax. Suppressing variable type impulse noise is more difficult than removing
fixed-valued impulse noise. The differences in gray levels between a corrupted pixel and its
uncorrupted neighbors are significant most of the times.

5.4.1 Noise Detection Scheme


Normally, two concerns are included in developing a determination process. First, it determines,
its measure by using statistical parameter to capture and also to represent the local property of
region. Second, a procedure to determine a threshold value for an unknown image.

IMAGE DENOISING BY NLM


PNC&VIET

CHAPTER5
ECE-2014

Page 44

The existing denoising methods use many different approach to determine whether a given image
pixel is a noisy one in this sense. Based on two-state methods, the new impulse detectors that is
attempt to indicate each image pixel as either corrupted or an uncorrupted pixel. The
phenomenon of these two methods is to determine image pixels to be significant. One of the
simplest and most inherent methods is to comparea image pixels intensity with the median pixel
intensity in its neighborhood. Another relative complex method such as the ACWM, DWM and
DTBDM use more complex criteria to conclude whether a pixel is an impulsive one.
However, this approach is simple or complex, each image pixel is decided under the same
decision, without considering the property of each image pixel. Furthermore, these existing
methods are resulted poor performance, when the density of is high. In fact, the level of impulse
noise in an image is different. Some pixels look more like corrupted pixels, and some do not look
like corrupted pixels. Theoretically, for separate levels, independent decision rules should be
adopted. Hence, prior to making a decision, all pixels should be grouped based on the level of
how impulsive-like.
Then, in different group, adopt different decision rules. In statistics, there are various
methods for detecting outliers. Among them, a conventional measure of the outlyingness of an
observation with respect to a sample is the ratio between its distance to the sample mean and
standard deviation (SD). Due to the statistics, the impulse noise can be detected easily. In
response to the aspects aforementioned, a novel detection paper mechanism for impulse noise is
proposed in this paper. The flowchart of denoising algorithm.

IMAGE DENOISING BY NLM


PNC&VIET

CHAPTER 5
ECE-2014

Page 45

FIG11:Flowchart for denoiseing scheme

IMAGE DENOISING BY NLM


PNC&VIET

CHAPTER5
ECE-2014

Page 46

A new detection mechanism has been proposed based on the new statistics. Most of the existing
detection methods are often realized bycomparing certain number of local neighborhood
statistics to the same number of corresponding thresholds. However, all these existing detection
methods mentioned above, deal with every pixel under the same rule without considering the
outlyingness differences among thepixels.
Theproposed detection mechanism describes the outlyingness of the pixels and divides
the pixels into four clusters based on the ROR values. The simple absolute deviation to the
median is used to identify the impulsive noise in each cluster. In fact, according to the principle
of the proposed detection mechanism, different decision rules could be adopted in different
clusters. Therefore, to choose a suitable decision rule of every cluster, the median filter analysis
and the detection method in DWM are used to get better results.
Detecting one by one pixel can get good results, but the efficiency may be low.
Therefore, a new detection pattern has been proposed that detects all the noisy pixels once in the
block, and this method could be called as the block-wise pattern. For good performance, the
capability of noise detection is very important. Here, the new detection method is compared with
other methods like DTBDM. A new impulse detector should be able to detect most of the
corrupted pixels as possible. If there are too many undetected noisy pixels, these pixels will lead
to the presence of noticeable noise patches.
Compared to other methods the proposed method can identify most of the noisy pixels. The
results show that our method is more robust to the noise ratio than the other methods.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER6

ECE-2014

Page 47

CHAPTER-6
NON LOCAL MEAN ALGORITHM

PNC&VIET

ECE-2014

Page 48

IMAGE DENOISING BY NLM

CHAPTER6

NON LOCAL MEAN ALGORITHM


Non-local means is an algorithm in image processing for image denoising. Unlike "local
smoothing" filters, non-local means does not update a pixel's value with an average those of the
pixels around it - instead, it updates it using a weighted average of the pixels judged to be most
similar'. The weight of each pixel depends on the distance between its intensity grey level vector
and that of the target pixel. Non-local means algorithm was published by Antonin Buades,et al.
in 2005.
If compared with other well-known denoising techniques, such as the Gaussian
smoothing model,

the anisotropic

diffusion model,

the total

variation

denoising,

the neighborhood filters and an elegant variant, the Wiener local empirical filter, the translation
invariant wavelet thresholding, the non-local means method noise looks more like white noise.

6.1 DEFENITION
Suppose

is the area of an image ,

is the location inside

and observed noisy image value at location

and

are the clean

respectively. Then the non-local means algorithm

can be defined as

PNC&VIET

ECE-2014

Page 49

Where

and

Gaussian

is

function

with

standard

deviation ,

is the filtering parameter.

IMAGE DENOISING BY NLM

CHAPTER6

The non-local means algorithm does not make the same assumptions about the image as other
methods. Instead it assumes the image contains an extensive amount of self-similarity. Efros
and Leung originally developed the concept of self-similarity for texture synthesis [4]. An
example of self-similarity is displayed in Figure 1 below. The figure shows three pixels p, q1,
and q2 and their respective neighborhoods. The neighborhoods of pixels p and q1 are similar,
but the neighborhoods of pixels p and q2 are not similar.
Adjacent pixels tend to have similarneighborhoods, but non-adjacent pixels will also
have similarneighborhoods when there is structure in the image [1]. For example, in Figure 1
most of the pixels in the same column as p will have similar neighborhoods to p's neighborhood.
The self-similarity assumption can be exploited to denoise an image.

Pixels with similar

neighborhoods can be used to determine the denoised value of a pixel.

Figure 12: Example of self-similarity in an image. Pixels p and q1 have similar neighborhoods,
but pixels p and q2 do not have similar neighborhoods. Because of this, pixel q1 will have a
stronger influence on the denoised value of p than q2.

IMAGE DENOISING BY NLM


PNC&VIET

CHAPTER6
ECE-2014

Page 50

Non-local Means Method


Each pixel p of the non-local means denoised image is computed with the following formula:
NL V

w p ,q V q
q V

whereV is the noisy image, and weights w(p,q) meet the

0 w p ,q
following conditions

1
and

w p ,q

. Each pixel is a weighted average of

all the pixels in the image. The weights are based on the similarity between the neighborhoods
of pixels p and q [1, 2]. For example, in Figure1 above the weight w(p,q1) is much greater than
w(p,q2) because pixels p and q1 have similar neighborhoods and pixels p and q2 do not have
similar neighborhoods. In order to compute the similarity, a neighborhood must be defined.
Let Ni be the square neighborhoodcentered about pixel i with a user-defined radius Rsim.
To compute the similarity between two neighborhoods take the weighted sum of squares
d p ,q

difference between the two neighborhoods or as a formula

V Np

V Nq

2
2, F

[1,

2].F is the neighborhood filter applied to the squared difference of the neighborhoods and will be
further discussed later in this section. The weights can then be computed using the following
formula:

PNC&VIET

ECE-2014

Page 51

1
e
Z p

w p ,q

Z p
Z(p) is the normalizing constant defined as

d p ,q
h

d p, q
h

[1,2]. his the weight-

decay control parameter and will be further discussed in section 2.2.


As previously mentioned, F is the neighborhood filter with radius Rsim. The weights of F are
computed by the following formula:

1
Rsim

Rsim

1 2 i 1

i m

IMAGE DENOISING BY NLM

CHAPTER6

wherem is the distance the weight is from the center of the filter. The filter gives more weight to
pixels near the center of the neighborhood, and less weight to pixels near the edge of the
neighborhood. The center weight of F has the same weight as the pixels with a distance of one
[3]. Despite the filter's unique shape, the weights of filter F do sum up to one.

PNC&VIET

ECE-2014

Page 52

Figure13: Shape of filter F when Rsim = 4.


Equation (1) from above does have a special case when q = p. This is because the weight w(p,p)
can be much greater than the weights from every other pixel in the image. By definition this
makes sense because every neighborhood is similar to itself. To prevent pixel p from overweighing itself let w(p,p) be equal to the maximum weight of the other pixels, or in more
w p, p

max w p , q

mathematical terms

p q
[3].

IMAGE DENOISING BY NLM

CHAPTER6

6.2 DISCRETE ALGORITHM


If image

is discrete, the non-local means algorithm can be represented as

PNC&VIET

ECE-2014

Page 53

Where the weight

depends on the distance between observed gray level vectors at

points and . Such distance can be represented as

IMAGE DENOISING BY NLM

CHAPTER6

So the weight can be defined as

PNC&VIET

ECE-2014

Page 54

6.3 NON-LOCAL MEANS PARAMETERS


The non-local means algorithm has three parameters. The first parameter, h, is the weight-decay
control parameter which controls where the weights lay on the decaying exponential curve. If h
is set too low, not enough noise will be removed. If h is set too high, the image will become
blurry. When an image contains white noise with a standard deviation of h should be set
between 10and

15
.
The second parameter, Rsim, is the radius of the neighborhoods used to find the similarity
between two pixels. If Rsim is too large, no similar neighborhoods will be found, but if it is too
small, too many similar neighborhoods will be found. Common values for Rsim are 3 and 4 to
give neighborhoods of size 7x7 and 9x9, respectively [1, 2].
The third parameter, Rwin, is the radius of a search window. Because of the inefficiency
of taking the weighted average of every pixel for every pixel, it will be reduced to a weighted
average of all pixels in a window. The window is centered at the current pixel being computed.

IMAGE DENOISING BY NLM

CHAPTER6

Common values for Rwin are 7 and 9 to give windows of size 15x15 and 19x19,
respectively [1, 2]. With this change the algorithm will take a weighted average of 15 2 pixels
rather than a weighted average of N2 pixels for an NxN image.

6.4 RESULTS&COMPARISIONS
PNC&VIET

ECE-2014

Page 55

The non-local means method was tested on several images with added the Gaussian white noise.
the neighborhood size was set to 7,and similarity window was set to be 3,in all the test cases to
obtain the optimum results. This method is genarally rendered positive results.
Guassian and Weiner filtering methods were compared to non-local means using three criteria.1)
visualqualitycomparision,2) mean square

comparision,3)method noise comparision.when

compared visually,the Denoised images obtained using non-local mean method were clear and
did not seem to contain any noise. the MSE of these images were significantly lower. the table1
compares the MSE for different standard deviation of the added noise between the methods. the
method noise of NLM were very similar to white noise. the comparision of denoiseing results of
the non-local means method vs Guassian and weiner filtering is shown in fig

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER6

ECE-2014

Page 56

Fig 14: MSE comparisions for peppers 256 image

.
Image
Boat

Guassian
10.6949

Weiner
10.0759

NLM
8.7463

Peppers256

12.2628

9.7400

8.0115

fig15:mean squre error table

IMAGE DENOISING BY NLM

CHAPTER6

PROPOSED NLM ALGORITHM


PNC&VIET

ECE-2014

Page 57

The proposed algorithm is as follows

Get Image Info


Initialize the denoised image and the weight max
Initialize the accumulated weights
Pad noisy image to avoid Boarder Issues
Compute the Integral Image and obtain the Square difference for every pair of pixels
Compute the weights for every pixel and obtain the corresponding noisy pixels
Compute and accumulatedenoised pixels
Update weight max and accumulated weights

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 7

ECE-2014

Page 58

CHAPTER-7
APPLICATIONS

IMAGE DENOISING BY NLM

CHAPTER 7

APPLICATIONS
1. Image segmentation
PNC&VIET

ECE-2014

Page 59

2.
3.
4.
5.

Face Recognition
Satellite applications
Remote sensing applications
Medical applications

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 60

CHAPTER-8
MATLAB

IMAGE DENOISING BY NLM

CHAPTER8

8.1 INTRODUCTION
MATLAB is a high-performance language for technical computing. It integrates
computation, visualization, and programming in an easy-to-use environment where problems and
PNC&VIET

ECE-2014

Page 61

solutions are expressed in familiar mathematical notation. MATLAB stands for matrix
laboratory, and was written originally to provide easy access to matrix software developed by
LINPACK (linear system package) and EISPACK (Eigen system package) projects. MATLAB is
therefore built on a foundation of sophisticated matrix software in which the basic element is
array that does not require pre dimensioning which to solve many technical computing problems,
especially those with matrix and vector formulations, in a fraction of time.
MATLAB features a family of applications specific solutions called toolboxes. Very
important to most users of MATLAB, toolboxes allow learning and applying specialized
technology. These are comprehensive collections of MATLAB functions (M-files) that extend
the MATLAB environment to solve particular classes of problems. Areas in which toolboxes are
available include signal processing, control system, neural networks, fuzzy logic, wavelets,
simulation and many others.
Typical uses of MATLAB include: Math and computation, Algorithm development, Data
acquisition, Modeling, simulation, prototyping, Data analysis, exploration, visualization,
Scientific and engineering graphics, Application development, including graphical user interface
building.

8.2 Basic Building Blocks of MATLAB


The basic building block of MATLAB is MATRIX. The fundamental data type is the
array. Vectors, scalars, real matrices and complex matrix are handled as specific class of this
basic data type. The built in functions are optimized for vector operations. No dimension
statements are required for vectors or arrays.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 62

8.2.1 MATLAB Window


The MATLAB works based on five windows: Command window, Workspace window,
Current directory window, Command history window, Editor Window, Graphics window and
Online-help window.
8.2.1.1 Command Window
The command window is where the user types MATLAB commands and expressions at
the prompt (>>) and where the output of those commands is displayed. It is opened when the
application program is launched. All commands including user-written programs are typed in
this window at MATLAB prompt for execution.
8.2.1.2 Work Space Window
MATLAB defines the workspace as the set of variables that the user creates in a work
session. The workspace browser shows these variables and some information about them.
Double clicking on a variable in the workspace browser launches the Array Editor, which can be
used to obtain information.
8.2.1.3 Current Directory Window
The current Directory tab shows the contents of the current directory, whose path is
shown in the current directory window. For example, in the windows operating system the path
might be as follows: C:\MATLAB\Work, indicating that directory work is a subdirectory of the
main directory MATLAB; which is installed in drive C. Clicking on the arrow in the current
directory window shows a list of recently used paths. MATLAB uses a search path to find Mfiles and other MATLAB related files. Any file run in MATLAB must reside in the current
directory or in a directory that is on search path.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 63

8.2.1.4 Command History Window


The Command History Window contains a record of the commands a user has entered in
the command window, including both current and previous MATLAB sessions. Previously
entered MATLAB commands can be selected and re-executed from the command history
window by right clicking on a command or sequence of commands. This is useful to select
various options in addition to executing the commands and is useful feature when experimenting
with various commands in a work session.
8.2.1.5 Editor Window
The MATLAB editor is both a text editor specialized for creating M-files and a graphical
MATLAB debugger. The editor can appear in a window by itself, or it can be a sub window in
the desktop. In this window one can write, edit, create and save programs in files called M-files.
MATLAB editor window has numerous pull-down menus for tasks such as saving,
viewing, and debugging files. Because it performs some simple checks and also uses color to
differentiate between various elements of code, this text editor is recommended as the tool of
choice for writing and editing M-functions.
8.2.1.6 Graphics or Figure Window
The output of all graphic commands typed in the command window is seen in this
window.
8.2.1.7 Online Help Window
MATLAB provides online help for all its built in functions and programming language
constructs. The principal way to get help online is to use the MATLAB help browser, opened as a
separate window either by clicking on the question mark symbol (?) on the desktop toolbar, or by
typing help browser at the prompt in the command window. The help Browser is a web browser
integrated into the MATLAB desktop that displays a Hypertext Markup Language (HTML)
documents.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 64

The Help Browser consists of two panes, the help navigator pane, used to find
information, and the display pane, used to view the information. Self-explanatory tabs other than
navigator pane are used to perform a search.
8.3 MATLAB Files
MATLAB has three types of files for storing information. They are: M-files and MATfiles.
8.3.1 M-Files
These are standard ASCII text file with m extension to the file name and creating own
matrices using M-files, which are text files containing MATLAB code. MATLAB editor or
another text editor is used to create a file containing the same statements which are typed at the
MATLAB command line and save the file under a name that ends in .m.
There are two types of M-files
1. Script Files
It is an M-file with a set of MATLAB commands in it and is executed by typing name of file on
the command line. These files work on global variables currently present in that environment.
2. Function Files
A function file is also an M-file except that the variables in a function file are all local.
This type of files begins with a function definition line.
8.3.2 MAT-Files
These are binary data files with .mat extension to the file that are created by MATLAB
when the data is saved. The data written in a special format that only MATLAB can read. These
are located into MATLAB with load command.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 65

8.4 The MATLAB System:


The MATLAB system consists of five main parts:
8.4.1 Development Environment:
This is the set of tools and facilities that help you use MATLAB functions and files. Many
of these tools are graphical user interfaces. It includes the MATLAB desktop and Command
Window, a command history, an editor and debugger, and browsers for viewing help, the
workspace, files, and the search path.
8.4.2 The MATLAB Mathematical Function:
This is a vast collection of computational algorithms ranging from elementary functions like
sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse,
matrix Eigen values, Bessel functions, and fast Fourier transforms.
8.4.3 The MATLAB Language:
This is a high-level matrix/array language with control flow statements, functions, data
structures, input/output, and object-oriented programming features. It allows both "programming
in the small" to rapidly create quick and dirty throw-away programs, and "programming in the
large" to create complete large and complex application programs.
8.4.4 Graphics:
MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as
annotating and printing these graphs. It includes high-level functions for two-dimensional and
three-dimensional data visualization, image processing, animation, and presentation graphics.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 66

It also includes low-level functions that allow you to fully customize the appearance of graphics
as well as to build complete graphical user interfaces on your MATLAB applications.
8.4.5 The MATLAB Application Program Interface (API):
This is a library that allows you to write C and FORTRAN programs that interact with
MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking), calling
MATLAB as a computational engine, and for reading and writing MAT-files.
8.5 SOME BASIC COMMANDS:
Pwdprints working directory
Demo

demonstrates what is possible in Mat lab

Who

lists all of the variables in your Mat lab workspace?

Whose

list the variables and describes their matrix size

Clearerases variables and functions from memory


Clear x erases the matrix 'x' from your workspace
Close by itself, closes the current figure window
Figurecreates an empty figure window
Hold onholds the current plot and all axis properties so that subsequent graphing
Commands add to the existing graph
Hold off sets the next plot property of the current axes to "replace"
findfindindices of nonzero elements e.g.:

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 67

d = find(x>100) returns the indices of the vector x that are greater than 100
Break terminate execution of m-file or WHILE or FOR loop
for repeat statements a specific number of times, the general form of a FOR
Statement is:
FOR variable = expr, statement, ..., statement END
For n=1:cc/c;
magn (n,1)=NaNmean(a((n-1)*c+1:n*c,1));
end
diff

difference and approximate derivative e.g.:


DIFF(X) for a vector X, is [X(2)-X(1) X(3)-X(2) ... X(n)-X(n-1)].

NaN

the arithmetic representation for Not-a-Number, a NaN is obtained as a

Result of mathematically undefined operations like 0.0/0.0


INF

the arithmetic representation for positive infinity, an infinity is also produced

by operations like dividing by zero, e.g. 1.0/0.0, or from overflow, e.g. exp(1000).
Save

saves all the matrices defined in the current session into the file,

matlab.mat, located in the current working directory


Load

loads contents of matlab.mat into current workspace

Save filename x y z

saves the matrices x, y and z into the file titled filename.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 68

matSave filename x y z /ascii

save the matrices x, y and z into the file titled filename.dataLoad

filename loads the contents of filename into current workspace; the file can be a binary (.mat)
file
Load filename.data loads the contents of filename.dat into the variable filename
Xlabel ( ) : Allows you to label x-axis
Ylabel ( ) : Allows you to label y-axis
Title ( )

: Allows you to give title for

plot
Subplot (): Allows you to create multiple
Plots in the same window
8.6 SOME BASIC PLOT COMMANDS:
Kinds of plots:
Plot(x,y)

creates a Cartesian plot of the vectors x & y

plot(y)

creates a plot of y vs. the numerical values of the elements in the y-vector

Semilogx(x,y) plots log(x) vs y


semilogy(x,y) plots x vs log(y)
loglog(x,y)

plots log(x) vs log(y)

Polar (theta,r) creates a polar plot of the vectors r & theta where theta is in radians
Bar(x)

creates a bar graph of the vector x. (Note also the command stairs(x))

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 69

Bar(x, y) creates a bar-graph of the elements of the vector y, locating the bars
According to the vector elements of 'x' Plot description:
Grid creates a grid on the graphics plot
Title ('text') places a title at top of graphics plot
Xlabel ('text') writes 'text' beneath the x-axis of a plot
Ylabel ('text') writes 'text' beside the y-axis of a plot
Text(x,y, text') writes 'text' at the location (x,y)
Text(x,y,'text','SC') writes 'text' at point x,y assuming lower left corner is (0,0) and upper right
corner is (1,1)axis ([xmin xmax ymin ymax]) sets scaling for the x- and y-axes on the current
plot
8.7 ALGEBRIC OPERATIONS IN MATLAB:
Scalar Calculations:
+

Addition

Subtraction

Multiplication

Right division (a/b means a b)

left division (a\b means b a)

Exponentiation

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 70

For example

3*4

executed in 'matlab' gives ans=12

4/5

gives ans=0.8

Array products: Recall that addition and subtraction of matrices involved


addition or subtraction of the individual elements of the matrices. Sometimes it is desired to
simply multiply or divide each element of an matrix by the corresponding element of another
matrix 'array operations.
Array or element-by-element operations are executed when the operator is preceded by a '.'
(Period):
a .* b

multiplies each element of a by the respective element of b

a ./ b

divides each element of a by the respective element of b

a .\ b

divides each element of b by the respective element of a

a .^ b

raise each element of a by the respective b element

8.8 MATLAB WORKING ENVIRONMENT:


8.8.1 MATLAB DESKTOP
Matlab Desktop is the main Matlab application window. The desktop contains five sub
windows, the command window, the workspace browser, the current directory window, the
command history window, and one or more figure windows, which are shown only when the
user displays a graphic.
The command window is where the user types MATLAB commands and expressions at
the prompt (>>) and where the output of those commands is displayed. MATLAB defines the
workspace as the set of variables that the user creates in a work session.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 71

The workspace browser shows these variables and some information about them. Double
clicking on a variable in the workspace browser launches the Array Editor, which can be used to
obtain information and income instances edit certain properties of the variable.
The current Directory tab above the workspace tab shows the contents of the current
directory, whose path is shown in the current directory window. For example, in the windows
operating system the path might be as follows: C:\MATLAB\Work, indicating that directory
work is a subdirectory of the main directory MATLAB; WHICH IS INSTALLED IN
DRIVE C. clicking on the arrow in the current directory window shows a list of recently used
paths. Clicking on the button to the right of the window allows the user to change the current
directory.
MATLAB uses a search path to find M-files and other MATLAB related files, which are
organize in directories in the computer file system. Any file run in MATLAB must reside in the
current directory or in a directory that is on search path. By default, the files supplied with
MATLAB and math works toolboxes are included in the search path.

The easiest way to see

which directories are soon the search path, or to add or modify a search path, is to select set path
from the File menu the desktop, and then use the set path dialog box. It is good practice to add
any commonly used directories to the search path to avoid repeatedly having the change the
current directory.
The Command History Window contains a record of the commands a user has entered in
the command window, including both current and previous MATLAB sessions. Previously
entered MATLAB commands can be selected and re-executed from the command history
window by right clicking on a command or sequence of commands.

IMAGE DENOISING BY NLM

PNC&VIET

CHAPTER 8

ECE-2014

Page 72

This action launches a menu from which to select various options in addition to executing the
commands. This is useful to select various options in addition to executing the commands. This
is a useful feature when experimenting with various commands in a work session.
8.8.2 Using the MATLAB Editor to create M-Files:
The MATLAB editor is both a text editor specialized for creating M-files and a graphical
MATLAB debugger. The editor can appear in a window by itself, or it can be a sub window in
the desktop. M-files are denoted by the extension .m, as in pixelup.m.
The MATLAB editor window has numerous pull-down menus for tasks such as saving,
viewing, and debugging files. Because it performs some simple checks and also uses color to
differentiate between various elements of code, this text editor is recommended as the tool of
choice for writing and editing M-functions.
To open the editor , type edit at the prompt opens the M-file filename.m in an editor
window, ready for editing. As noted earlier, the file must be in the current directory, or in a
directory in the search path.
8.8.3 Getting Help:
The principal way to get help online is to use the MATLAB help browser, opened as a
separate window either by clicking on the question mark symbol (?) on the desktop toolbar, or by
typing help browser at the prompt in the command window. The help Browser is a web browser
integrated into the MATLAB desktop that displays a Hypertext Markup Language(HTML)
documents. The Help Browser consists of two panes, the help navigator pane, used to find
information, and the display pane, used to view the information. Self-explanatory tabs other than
navigator pane are used to perform a searc

APPENDIX-1
PROGRAM CODE

PNC&VIET

ECE-2014

Page 73

Clear all
Close all
Clc
mse = @(a,b) (a(:)-b(:))'*(a(:)-b(:))/numel(a);
snr = @(clean,noisy) 20*log10(mean(noisy(:))/mean(abs(clean(:)noisy(:))));
%%%%%%%%%%% reading an image %%%%%%%%%%%%%%%
I=uigetfile ('*.tif','Select an image');
I = imread (I);
I=im2double (I);
Imshow (I);
Title ('Clean Image')
%%%%%%%%% Adding noise to an image %%%%%%%%%%%%%%%%%%
N = imnoise (I, Gaussian', 0, .001);
Figure, imshow (N);
Title (['Noisy Image, mse = ' num2str (mse (I,N)), snr = ', num2str (snr
(I,N))])
%%%%%%%%%%%%% Applying NLM to noisy image %%%%%%%%%%%%%
D = Fast_NLM (N,5,3,0.1);
Figure, imshow (D);
title (['Denoised Image, mse = ' num2str(mse(I,D)), ', snr = ',
num2str(snr(I,D))])
PaddedImg = padarray(NoisyImg,
[PatchSizeHalf,PatchSizeHalf],'symmetric','both');
PaddedV = padarray(NoisyImg,
[WindowSizeHalf,WindowSizeHalf],'symmetric','both');
% Main loop
for dx = -WindowSizeHalf:WindowSizeHalf
fordy = -WindowSizeHalf:WindowSizeHalf
if dx ~= 0 || dy ~= 0
% Compute the Integral Image
Sd = integralImgSqDiff(PaddedImg,dx,dy);
% Obtaine the Square difference for every pair of pixels
SqDist = Sd(PatchSizeHalf+1:end-PatchSizeHalf,PatchSizeHalf+1:endPatchSizeHalf)+Sd(1:end-2*PatchSizeHalf,1:end-2*PatchSizeHalf)-Sd(1:end2*PatchSizeHalf,PatchSizeHalf+1:end-PatchSizeHalf)-Sd(PatchSizeHalf+1:endPatchSizeHalf,1:end-2*PatchSizeHalf);
% Compute the weights for every pixels
w = exp(-SqDist/(2*Sigma^2));
% Obtaine the corresponding noisy pixels
V=PaddedV((WindowSizeHalf+1+dx):(WindowSizeHalf+dx+Height),
(WindowSizeHalf+1+dy):(WindowSizeHalf+dy+Width));
% Compute and accumalatedenoised pixels
u = u+w.*v;
% Update weight max
M = max(M,w);
% Update accumlatedweighgs
Z = Z+w;
end
end
end

PNC&VIET

ECE-2014

Page 74

% Speical controls to accumulate the contribution of the noisy pixels to be


denoised
f = 1;
u = u+f*M.*NoisyImg;
u = u./(Z+f*M);
% Output denoised image
Denoisedimg= u;
function t = img2DShift(v,dx,dy)
% FUNCTION img2DShift: Shift Image with respect to x and y coordinates
t = zeros(size(v));
type = (dx>0)*2+(dy>0);
switch type
case 0 % dx<0,dy<0: move lower-right
t(-dx+1:end,-dy+1:end) = v(1:end+dx,1:end+dy);
case 1 % dx<0,dy>0: move lower-left
t(-dx+1:end,1:end-dy) = v(1:end+dx,dy+1:end);
case 2 % dx>0,dy<0: move upper-right
t(1:end-dx,-dy+1:end) = v(dx+1:end,1:end+dy);
case 3 % dx>0,dy>0: move upper-left
t(1:end-dx,1:end-dy) = v(dx+1:end,dy+1:end);
end
functionSd = integralImgSqDiff(v,dx,dy)
% FUNCTION intergralImgDiff: Compute Integral Image of Squared Difference
% Decide shift type, tx = vx+dx; ty = vy+dy
t = img2DShift(v,dx,dy);
% Createsqaured difference image
diff = (v-t).^2;
% Construct integral image along rows
Sd = cumsum(diff,1);
% Construct integral image along columns
Sd = cumsum(Sd,2);

APPENDIX-2
SIMULATION RESULTS
PNC&VIET

ECE-2014

Page 75

PNC&VIET

ECE-2014

Page 76

FIG16:
SIMULATION

RESULT

APPENDIX3
CONCLUSION

PNC&VIET

ECE-2014

Page 77

The de-noising results of the proposed algorithm are comparable to that of the original NLMeans in terms of MSE. Improvement in MSE is achieved with reference to the original NLMeans. Smaller MSE indicates that the estimate is closer to the Original Image. The proposed
algorithm performs the best on periodic textures like the stripped scarf, trousers in the Barbara
image. The Natural photograph like "Well" also have enough redundancy to exploit by NLMeans, that's why the results are comparable with the Standard Test images. With the proposed
algorithm, the de-noising is achieved with smoother reconstruction and less artifacts. It proves
that the algorithm is spontaneous and powerful. The proposed de-noising algorithm
accomplished its goal of de-noising, i.e. improving PSNR and preserving the details, especially
the edges.

APPENDIX-4
REFERENCES

PNC&VIET

ECE-2014

Page 78

[I] B. Goossens, H.Q. Luong, A. Pizuriea, W. Philips, "An Improved Non-Local


DenoisingAigorithm," lnternational Workshop on Local andNon-Loeal Approximation in Image
Processing, 25-29 August 2008,Lausanne, Switzerland.
[2] Jin Wang; YanwenGuo; Yiting Ying; Yanli Liu; Quashing Pong, "Fast Non-Local A1gorithm
for Image De noising", IEEE International Conference on image, Processing, 8- l1 October 2006,
Atlanta, USA.
[3] Buades, A, ColI, B, Morel J.M, "A non-local algorithm for imagedenoising", IEEE Computer
SoeietyConferenee on Computer Vision and Pattern Recognition, 20-26 June 2005, San Diego,
CA, USA.
[4] Quing Xu, Hailin Jiang, Rieeardo Seopigno, Mateu Sbert, "A NewApproach for Very Dark
Video De noising and Enhancement", Proceding of IEEE 17th International Conference on
Image Proeessing,26-29 September 2010, Hongkong. Page(s):1185-1188.
[5] Jonathan Taylor, "lntroduetion to Regression and Analysis of VarianeeRobust methods", a
tutorial from Department of Statisties, StanfordUniversity, USA.
[6] T. Chonavel, "Statistieal Signal Proeessing- modeling and estimation",Springerlnternational
Edition, 2002, lSBN 1-85233-385-5

PNC&VIET

ECE-2014

Page 79

Anda mungkin juga menyukai