Image Denoising by NLM

Embed Size (px)

DESCRIPTION

PROJECT

Citation preview

IMAGE DENOISING BY NLM CHAPTER 1

CHAPTER -1 INTRODUCTION

IMAGE DENOISING BY NLM CHAPTER 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 CHAPTER 1.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 CHAPTER 1

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 co-ordinates 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 CHAPTER 1

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 CHAPTER 1

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 CHAPTER 1

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 Images are read into the MATLAB environment using function imread whose syntax isimread(filename) Format name Description recognized extension TIFF Tagged Image File Format .tif, .tiff JPEG Joint Photograph Experts Group .jpg, .jpeg GIF Graphics Interchange Format .gif BMP Windows Bitmap .bmp PNG Portable Network Graphics .png XWD X Window Dump .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 CHAPTER 1

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 CHAPTER 1

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 fGives Name size Bytes Class F 1024*1024 1048576 unit8 arrayGrand 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 CHAPTER 1

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 fName Size Bytes ClassIMAGE DENOISING BY NLM CHAPTER 1

F 512*512 262144 unit8 arrayGrand 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 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 alternativelyFor 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) 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: 714IMAGE DENOISING BY NLM CHAPTER 1

Height: 682 Bit Depth: 8 Color Depth: grayscale 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);>> 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])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.

IMAGE DENOISING BY NLM CHAPTER 2

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.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.MName of the title:A non-local algorithm for imaged noisingYear of publishing:20-26 June 2005Source of the publishing: San Diego, CA, USA..ABSTRCT: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 2010Source of the publishing: Hong Kong.ABSTRCT: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 well-known 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 two-step 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 VarianceRobust methodsSource 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 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. ChonavelName of the title:"Statistical Signal Processing- modeling and estimationYear of publishing:Springer International Edition, 2002Source of the publishing: ISBNABSTRCT: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 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

IMAGE DENOISING BY NLM CHAPTER3 NOISENoise 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. 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 CHAPTER3

a)Original imageb)Added Shot Noisy at 10\%

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

a)3x3 Median Filteredb)5x5 Median Filtered

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

IMAGE DENOISING BY NLM CHAPTER3

a)b)

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. 3.2 UNIFORM NOISEThe 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.FIG 5: Image with salt and pepper noise and distribution function

IMAGE DENOISING BY NLM CHAPTER4

CHAPTER-4 FILTERS

IMAGE DENOISING BY NLM CHAPTER4

4.1 ANALOG AND DIGITAL FILTERSIn 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 ideaThere 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 4The resulting binary numbers, representing successive sampled values of the input signal, are transferred to the processor, which carries out numerical calculations on them.These 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 CHAPTER4

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 CHAPTER4

Using Linear FilteringLinear 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 FILTERSMany 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 FILTERSNoise 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 filtersOrder 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 CHAPTER4

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 filtersOrder 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 CHAPTER4

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 ISSUESTypically, 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 algorithmscan be much more efficient. Furthermore, some types of signals (very often the case for images) use whole number representations: in these cases,histogrammedians 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 CHAPTER44.7 EDGE PRESERVATION PROPORTIES

Median filtering is one kind of smoothing technique, as islinear 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, forspeckle noiseandsalt and pepper noise(impulsive noise), it is particularly effective. Because of this, median filtering is very widely used in digitalimage processing.

4.8 WIENER FILTER Insignal processing, theWiener filteris afilterused to produce an estimate of a desired or target random process by linear time-invariant filtering an observed noisy process, assuming known stationarysignal 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 outnoisethat has corrupted a signal. It is based on astatisticalapproach, and a more statistical account of the theory is given in theMMSE estimatorarticle.Typical filters are designed for a desiredfrequency 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 thelinear time-invariantfilter whose output would come as close to the original signal as possible. Wiener filters are characterized by the following: IMAGEDENOISING BY NLM CHAPTER4

1. Assumption: signal and (additive) noise are stationary linearstochastic processeswith known spectral characteristics or knownautocorrelationandcross-correlation2. 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 CHAPTER5

CHAPTER-5 DENOISING MECHANISM

IMAGE DENOISING BY NLM CHAPTER5

DENOISING MECHANISMMost 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 NOISEImage 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 CHAPTER55.2 AVERAGING FILTER 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

Insignal processing, it is often desirable to be able to perform some kind ofnoise reductionon an image or signal. Themedian filteris a nonlineardigital filteringtechnique, often used to removenoise. Such noise reduction is a typical pre-processing step to improve the results of later processing (for example,edge detectionon an image). Median filtering is very widely used in digitalimage processingbecause, under certain conditions, it preserves edges while removing noise.

IMAGE DENOISING BY NLM CHAPTER5

Fig10: Median filter functioningThe main idea of the median filter is to run through the signal entry by entry, replacing each entry with themedianof 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 higher-dimensional) 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 themedianis 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 CHAPTER5

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 py 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 impulseNoise,(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 SchemeNormally, 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 CHAPTER5

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 CHAPTER 5

FIG11:Flowchart for denoiseing scheme

IMAGE DENOISING BY NLM CHAPTER5A 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 CHAPTER6

CHAPTER-6 NON LOCAL MEAN ALGORITHM

IMAGE DENOISING BY NLM CHAPTER6

NON LOCAL MEAN ALGORITHMNon-local meansis an algorithm in image processing forimage 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 bemost 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 theGaussian smoothingmodel, theanisotropic diffusionmodel, thetotal variation denoising, theneighborhood filtersand an elegant variant, theWiener local empirical filter, the translation invariantwaveletthresholding, the non-local means method noise looks more likewhite noise.6.1 DEFENITIONSupposeis the area of an image,is the location inside,andare the clean and observed noisy image value at locationrespectively. Then the non-local means algorithm can be defined as

Wherea Gaussian is function with standard deviation,andis 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 CHAPTER6Non-local Means MethodEach pixel p of the non-local means denoised image is computed with the following formula:

whereV is the noisy image, and weights w(p,q) meet the following conditions and . 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 difference between the two neighborhoods or as a formula [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:

Z(p) is the normalizing constant defined as [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:

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.

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 over-weighing itself let w(p,p) be equal to the maximum weight of the other pixels, or in more mathematical terms [3].

IMAGE DENOISING BY NLM CHAPTER6

6.2 DISCRETE ALGORITHMIf imageis discrete, the non-local means algorithm can be represented as

Where the weightdepends on the distance between observed gray level vectors at pointsand. Such distance can be represented as

IMAGE DENOISING BY NLM CHAPTER6

So the weight can be defined as

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 152 pixels rather than a weighted average of N2 pixels for an NxN image.6.4 RESULTS&COMPARISIONS

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 CHAPTER6

Fig 14: MSE comparisions for peppers 256 image

.ImageGuassianWeinerNLM

Boat10.694910.07598.7463

Peppers25612.26289.74008.0115

fig15:mean squre error table

IMAGE DENOISING BY NLM CHAPTER6

PROPOSED NLM ALGORITHMThe 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 CHAPTER 7

CHAPTER-7 APPLICATIONS

IMAGE DENOISING BY NLM CHAPTER 7

APPLICATIONS1. Image segmentation2. Face Recognition3. Satellite applications4. Remote sensing applications5. Medical applications

IMAGE DENOISING BY NLM CHAPTER 8

CHAPTER-8 MATLAB

IMAGE DENOISING BY NLM CHAPTER8

8.1 INTRODUCTIONMATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and 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 MATLABThe 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 CHAPTER 8

8.2.1 MATLAB WindowThe 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 WindowThe 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 WindowMATLAB 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 WindowThe 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 M-files 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 CHAPTER 8

8.2.1.4 Command History WindowThe 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 WindowThe 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 WindowThe 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 CHAPTER 8

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 FilesMATLAB has three types of files for storing information. They are: M-files and MAT-files.8.3.1 M-FilesThese 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-files1. Script FilesIt 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-FilesThese 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 CHAPTER 8

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 CHAPTER 8

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 directoryDemo demonstrates what is possible in Mat labWho lists all of the variables in your Mat lab workspace?Whose list the variables and describes their matrix sizeClearerases variables and functions from memoryClear x erases the matrix 'x' from your workspace Close by itself, closes the current figure windowFigurecreates an empty figure windowHold onholds the current plot and all axis properties so that subsequent graphing Commands add to the existing graphHold off sets the next plot property of the current axes to "replace"findfindindices of nonzero elements e.g.:IMAGE DENOISING BY NLM CHAPTER 8

d = find(x>100) returns the indices of the vector x that are greater than 100Break terminate execution of m-file or WHILE or FOR loopfor 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));enddiff 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 producedby 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 workspaceSave filename x y z saves the matrices x, y and z into the file titled filename.IMAGE DENOISING BY NLM CHAPTER 8

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 filenameXlabel ( ) : Allows you to label x-axisYlabel ( ) : Allows you to label y-axisTitle ( ) : Allows you to give title for plotSubplot (): Allows you to create multiple Plots in the same window8.6 SOME BASIC PLOT COMMANDS:Kinds of plots:Plot(x,y) creates a Cartesian plot of the vectors x & yplot(y) creates a plot of y vs. the numerical values of the elements in the y-vectorSemilogx(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 radiansBar(x) creates a bar graph of the vector x. (Note also the command stairs(x))IMAGE DENOISING BY NLM CHAPTER 8

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 plotTitle ('text') places a title at top of graphics plotXlabel ('text') writes 'text' beneath the x-axis of a plotYlabel ('text') writes 'text' beside the y-axis of a plotText(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 plot8.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 CHAPTER 8

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 ba ./ b divides each element of a by the respective element of ba .\ b divides each element of b by the respective element of aa .^ 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 CHAPTER 8The 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 CHAPTER 8

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-1PROGRAM CODE

Clear allClose allClcmse = @(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 loopfor dx = -WindowSizeHalf:WindowSizeHalffordy = -WindowSizeHalf:WindowSizeHalfif dx ~= 0 || dy ~= 0% Compute the Integral Image Sd = integralImgSqDiff(PaddedImg,dx,dy); % Obtaine the Square difference for every pair of pixelsSqDist = Sd(PatchSizeHalf+1:end-PatchSizeHalf,PatchSizeHalf+1:end-PatchSizeHalf)+Sd(1:end-2*PatchSizeHalf,1:end-2*PatchSizeHalf)-Sd(1:end-2*PatchSizeHalf,PatchSizeHalf+1:end-PatchSizeHalf)-Sd(PatchSizeHalf+1:end-PatchSizeHalf,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;endendend% Speical controls to accumulate the contribution of the noisy pixels to be denoisedf = 1;u = u+f*M.*NoisyImg;u = u./(Z+f*M);% Output denoised imageDenoisedimg= u;function t = img2DShift(v,dx,dy)% FUNCTION img2DShift: Shift Image with respect to x and y coordinatest = zeros(size(v));type = (dx>0)*2+(dy>0);switch typecase 0 % dx0: move upper-left t(1:end-dx,1:end-dy) = v(dx+1:end,dy+1:end);endfunctionSd = integralImgSqDiff(v,dx,dy)% FUNCTION intergralImgDiff: Compute Integral Image of Squared Difference% Decide shift type, tx = vx+dx; ty = vy+dyt = img2DShift(v,dx,dy);% Createsqaured difference imagediff = (v-t).^2;% Construct integral image along rowsSd = cumsum(diff,1);% Construct integral image along columnsSd = cumsum(Sd,2);

APPENDIX-2

SIMULATION RESULTS

FIG16: SIMULATION RESULT

APPENDIX-3

CONCLUSIONThe de-noising results of the proposed algorithm are comparable to that of the original NL-Means in terms of MSE. Improvement in MSE is achieved with reference to the original NL-Means. 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 NL-Means, 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-4REFERENCES

[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-2014Page 78