MATLAB 1

64
THREE MONTHS SOFTWARE PROJECT REPORT IN EUREKA ELECTROSOFT SOLUTIONS PVT. LTD. SUBMITTED TO PUNJAB TECHNICAL UNIVERSITY, JALANDHAR in partial fulfillment of the requirements for the award of the degree of Bachelor of Technology in ELECTRICAL Engineering SUBMITTED BY PARMINDER KAUR Univ. Roll No. 1286435 Under the guidance of Academic Tutor Industrial Tutor Prof. Ranjit Bindal Er. Arvinder Singh Associate Prof.

description

rtt

Transcript of MATLAB 1

THREE MONTHS SOFTWARE PROJECT REPORTINEUREKA ELECTROSOFT SOLUTIONS PVT. LTD.SUBMITTED TO

PUNJAB TECHNICAL UNIVERSITY, JALANDHARin partial fulfillment of the requirements for the award of the degree ofBachelor of Technology in ELECTRICAL EngineeringSUBMITTED BYPARMINDER KAURUniv. Roll No. 1286435Under the guidance of Academic Tutor Industrial TutorProf. Ranjit Bindal Er. Arvinder SinghAssociate Prof.

Department of Electrical EngineeringRayat Institute of Engineering & Information TechnologyRailmajra, Distt. Shahid Bhagat Singh Nagar (Punjab)ACKNOWLEDGEMENTAt the outlet and above all I must bow with all the humanity before the divine power the has bestowed me with all the requisite intelligence, helps and above all the will to carry out to the consummation and stupendous task of investigation

No great endeavor is possible in any field in solitude. It needs inspiration, guidance and help at every step. So I would like to preface my report by expressing sincere and deep gratitude to those who made it possible for me to complete my project work.

I am thankful to Ms. Amitoj Kaur for providing me such an excellent opportunity to observe and study the work in progress in the EEAST Electrosoft Company who consistently motivated and guided me throughout the training. Last but not the least, I express my deep gratitude to the rest of staff members of the PLANT who were very cooperative and hardworking for providing me valuable information that will help me in future to shape my future well.

Parminder Kaur Roll No: 1286435

TABLE OF CONTENTPREFACE(i) Declaration of the student (ii) Copy of the certificate from the industry (iii) Acknowledgment

Chapter 1: Introduction 1.1 Software Tool Description1.2 Matlab Desktop1.3 What is Matlab1.4 Useful Functions of matlab1.5 Starting methods of Matlab1.6 Types of Window Command Window Workspace Window Editor Window Current Folder Help Window Layout and other window

Chapter 2: Graphical User Interface 2.1 What is GUI 2.2 What is GUI Contains 2.3 How does a GUI Works 2.4 Creating a Simple GUI with Guide Laying out a GUI Programming a GUI Opening a new GUI in Layout Editor Setting GUI Figure Size Adding Components Aligning Components Adding text to Component Labeling Push Button 2.5 Component Icon Description Push Button Check Box Edit Text Pop Up Menu Toggle Button Radio Button Axes Panel Button Group

Chapter 3: Digital Image Processing 3.1 Introduction3.2 Image and Picture3.3 What is Image Processing3.4 Types of digital images Binary Greyscale RGB Indexed

Chapter 4: Imnoise4.1 Types of Imnoise i) Gaussianii) Poissoniii) Salt and Pepperiv) Spackle

Chapter 5: Filters 5.1 What is Filter 5.2 Types of Filtersi) Wiener2 ii) Ordfilt2iii) Medfilt2

Chapter 6: Conclusion

Bibliograph

INTRODUCTIONSoftware Tool DescriptionSoftware tool used in this project is MATLAB. This tool is a product of MATHWORKS Company. All the related details are given at their website www.mathworks.com. Some of the introductory details to use the software interface is attached below. MATLAB DesktopWhen you start MATLAB, the MATLAB desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The first time MATLAB starts, the desktop appears as shown in the following illustration.

What is Matlab?Mat lab is a programming environment as well as a high level, interpreted, dynamically typed language, supporting functional, object oriented, and event driven paradigms. It is well suited for numerical computation, particularly computations involving matrix operations and linear algebra. Matlab has excellent support for data visualization and its concise and expressive syntax, as well as the plethora of predefined functions, results in a powerful environment excellent for rapid prototyping with minimal overhead. Yet, Matlab is not just a scripting language for quick and dirty calculations. Recent versions have seen a dramatic increase for the support of large scale, highly structured code to rival C++, Java and the like. If you want the best of both worlds, Matlab's integrated java support lets you create and manipulate instances of java classes right in your Matlab programs. You can also call out to code written in C, C++, Perl, Fortran, or execute dos or unix system commands. Furthermore, Matlab code can be exported for use in Java, C, C++, and .Net programs, or as a stand alone application, mitigating its primary disadvantage - that it is not free. As an interpreted language, some operations are slower than in a compiled language, particularly those involving loops. This too has improved in recent versions. In many cases, however, loops can be vectorized resulting in very quick code that invokes low level, highly optimized, compiled functions from the Matlab library. When the most computationally expensive parts of your program can be written this way, the speed of Matlab code rivals that of compiled languages. Finally, with the addition of various toolkits, e.g. for Statistics, Bioinformatics, Optimization, or Image Processing, to name just a few, the Matlab environment can be extended for more specialized requirements. Matlab is a product of the The Mathworks Company; for more general information, consult their website at http://www.mathworks.com/. Useful Functions1. help, doc, type, lookfor, who, whos1. clear, clearvars, clc, home, close1. what, version, isvarname, namelengthmax, startup.m1. save, load, dlmread, dlmwrite, textscan, fprintf, fopen, fclose,1. imread, imwrite, imagesc, colormap, axis image,As the code for the examples is embedded right into the document, it may be advantageous to open the tutorial in the Matlab web browser so that you can try out the examples as you read. You can execute code by highlighting it on the web page and pressing F9. The statements are processed as though they were typed one at a time in the command window. You can bring up the Matlab web browser by typing say web www.cs.ubc.ca/~mdunham at the command0020prompt, and can move it to whatever part of the screen you find most convenient. Starting MatlabTo launch Matlab double click on the Matlab shortcut or type Matlab at a command prompt. There are also several command line options available to control how Matlab will run. You can modify the properties of the shortcut to add these or include them at the command prompt. The -nojvm option loads Matlab without Java support, significantly reducing memory requirements at the cost of reduced functionality. None of the Matlab desktop windows are available in this mode, except for the command window. Here is how it looks.

You can get rid of the opening splash screen with -nospash and on unix systems bring up a Matlab command window right at the command prompt with the -nodesktop switch.

Startup FileYou can specify commands to execute every time Matlab starts by creating a file on the Matlab search path with the name, startup.m, and writing the commands there. In later versions of Matlab, preferences can be set under File->Preferences reducing the need for such a file, however, it can still be useful, particularly if you run Matlab in nojvm or nodesktop mode, or want to change advanced properties such as plotting defaults defined under root. Check out the following section in the plotting chapter for details. Root Properties Useful PreferencesYou may find it useful to set the following preference to save space when the results of calculations are displayed in the command window. 1. File->Preferences->Command Window->Text Display->Numeric display->compactCommand WindowMatlab commands are either executed in scripts or functions, or directly at the command window shown below. If you do not suppress output by adding a semicolon at the end of your commands, the results are displayed here as well. It is often useful to test out commands you are adding to a script or function in the command window first to ensure you have the syntax and desired behavior right. The last typed command can be retrieved by selecting the command window and pressing the up arrow key on your keyboard. Pressing it several times scrolls you backwards through the history of typed commands. By first typing in part of the command before pressing the up arrow, only those statements that began with the typed text are displayed. Furthermore, you can invoke Matlab's autocomplete feature by typing part of a command or function and pressing tab. A number of suggested options will appear. The same is true when editing files, e.g. typing edit eig followed by the tab key will list all of the m-files on the Matlab path that begin with eig.

Here are number of command window related commands.clc % clear the window

home % move the cursor to the top of the windowdiary on % record all input and output in a file called diaryclear all % clear all of the current variablesclearvars -except a b % clear all of the variables except a and bclose all % close all open figureswho % list all of the current variableswhos % same as who but with more detailv = version % display the current Matlab version%what % display a list of the files in the current directoryv =7.6.0.324 (R2008a)

VariablesWe can create named memory locations to store data, called variables, very easily in Matlab. Here we create a number of variables, however, we go into much more detail in the section on Matrices. Variable names must begin with a character and can contain up to 63 characters on most systems. Type namelengthmax to see the maximum on your system. They can also contain numbers or the underscore character. You can check that a potential variable name is valid with the isvarname command. isvarname test-123ans = 0isvarname test_123ans = 1Since Matlab is a dynamically typed language, we do not predefine the type of data we will store in a particular variable and can overwrite data of one type with data of another. Notice that the variable g, currently holds the number 1023. We will now assign it the following string. g = 'does this really work?'g =does this really work?You can save all of the variables in a workspace to a file by typing save filename at the command prompt and reload them again with load filename.

WorkspaceAll of the current variables, as well as basic information about them, can be viewed in a convenient graphical window called the workspace. If it is not already visible, you can bring it up by typing workspace at the command prompt or by going to the desktop drop down menu. You can then drag and place it wherever it is convenient. You can set what information you want displayed by right clicking on the header bar, (with "Name Value Class Size Bytes") in the picture below. If you double click on a variable it will open it in the variable editor where you can inspect or change its values. This is much more useful when dealing with matrices. Certain variables can also be immediately plotted from here with the plot selection button in the same window. We discuss plotting in some depth in the plotting chapter.Plotting

Current DirectoryThe current directory window, unsurprisingly, displays the files in the current working directory. You can open it via the drop down menu Desktop->Current Directory if it is not already open. From here you can navigate the file system and search for files. Type F5 to force a refresh.

UserpathMatlab automatically sets up a default directory where you can save your own Matlab files; it opens this directory, whenever its started. You can view and change this default by typing userpath or say userpath c:\Users\matt\Matlab\ at the command prompt. HelpOne of Matlab's best features is its extensive library of help files. There are far too many built in functions to memorize and even if you remember the name, the exact syntax might allude you. You can bring up the help navigator by going to Desktop -> Help or search right from the command window. Typing help functionname at the command prompt displays that function's documentation right there, whereas doc functionname brings this up in the help window. You can search by keyword in help or search the first line of every function's documentation with the look for command, as in look for eigen value.

EditorAs we mentioned, Matlab commands are executed either at the command prompt or by running scripts or functions, which can be created and edited with the built in editor. To launch the editor, if it is not already open, type edit or edit filename. Commands can be entered here and executed as a script. They are saved with a .m extension. To run your script, type in the name at the command prompt, or press F5 or the save and run button at the top of the editor. Your own functions can be written here as well. We discuss functions in depth in a dedicated chapter. Writing Functions You can set break points to halt execution at certain lines for debugging, which we discuss here.Debugging, Profiling, & Style Comments are written by preceding the line with the % symbol. Block comments are opened with %{ and closed with %}. To have Matlab word wrap a selection of comments, right click on the highlighted text and select, Wrap Selected Text. You can partition your code into editor cells by typing two percent signs, %%, at the beginning of the line. This can help organize your code into logical sections. You can also evaluate cells one at a time by selecting the evaluate cell button at the top of the editor. At any time, you can execute an arbitrary block of code by highlighting it and pressing F9. Cells are also used when publishing your code. This tutorial was written in Matlab and published to html by selecting the publish button at the top of the editor. This can be very useful when you want to share your code and results with others in a professional looking report. Certain constructs like for loops and functions can be folded, hiding all but the top line from view. Select the + or - symbols appearing on the left hand side of the editor, by the line numbers. Here is an image of the editor in action. Notice we have the open m-files listed in the center column; you can move these to the left right or bottom. We have also docked one of the figures in the top left. By default figures open in their own windows but it can sometimes be useful to work with a figure on the same screen: to do this, use the doc window arrow at the the top left of the figure.

There are many other configuration options and editor tools available; experiment by selecting the many buttons and exploring the drop down menus. Layouts and Other WindowsMatlab gives you a lot of freedom over how you organize the windows in the environment. For instance, you can have have multiple windows take up the same screen area and toggle between them at will, or place windows at the sides where they automatically hide until you select them. Try dragging them around to different places to see the effect. There are more windows than described here available under the Desktop drop down menu. You can save the current layout, select one of the default ones, tile all the windows, and perform many other related tasks under the Desktop drop down menu. Its worth taking the time to organize your layout effectively before you begin working.

Start BarMany of the tools and screens we have talked about, as well as links to various graphical wizards are available under the start bar in the bottom left hand of the environment. Input & Output\Input and output in Matlab is relatively easy and can be done with a few useful functions. We describe these first and show examples at the bottom of this section. The dlmread() is very useful for importing ascii delimited data into Matlab. You simply specify the filename and optionally the delimiter, although it can usually figure this out. To write data to a delimited file, use the dlmwrite() function. You can also use the built in import wizard by typing uiimport at the command prompt. This is particularly useful when you have data stored in the windows clipboard, copied from some third party program. If you are reading text from a file, try the textscan() function. You first have to open the file, however, with fopen() and then close it when you are done with fclose(). Here is an advanced example from the chapter on Strings. Importing Text example The imread() function is useful for reading image files and supports a wide range of formats. To write an image, use imwrite(). The imagesc() function can be used to view the image. To write arbitrary data, including text, to a file, use the fprintf() function in conjunction with fopen() and fclose(): fopen() returns a file id, which you then pass as the first argument to fprintf(). If you do not specify a file id, fprintf() prints the data to the command window. We discuss the formatting options available with this function here.

Formatting Strings For more information on, say, the textscan function type doc textscan at the command prompt. Here a a number of examples.A = rand(20,40); % create a random matrix

dlmwrite('testData.csv',A); % write to a file as a comma separated listclearB = dlmread('testData.csv'); % load it back inC = 'We will write this string to a file'; % create some text.fid = fopen('hello.txt','w'); % open a new file for writingfprintf(fid,C); % write it to a filefclose(fid); % remember to close the filefid = fopen('hello.txt','r'); % open with read accessD = textscan(fid,'%s'); % read it back in. %s to expect stringsD{:} % show the contents of Dfclose(fid); % remember to close the file.ans = 'We' 'will' 'write' 'this' 'string' 'to' 'a' 'file'load mandrill; % built in imageimagesc(X); % display itaxis image % window dimensions appropriate for an imagemap = colormap(bone); % a possible color scheme.

imwrite(X, map, 'mandrill.jpg', 'jpg'); % write the image to a jpeg fileclearX = imread('mandrill.jpg'); % load it back in.save example % save all the variables to a .mat fileclearload example % load them back inclose allclear all

Graphical User InterfaceWhat Is a GUI?A graphical user interface (GUI) is a graphical display in one or more windows containing controls, called components that enable a user to perform interactive tasks. The user of the GUI does not have to create a script or type commands at the command line to accomplish the tasks. Unlike coding programs to accomplish tasks, the user of a GUI need not understand the details of how the tasks are performed.The GUI components can be menus, toolbars, push buttons, radio buttons, list boxes, and slidersjust to name a few. GUIs created in MATLAB software can group related components together, read and write data files, and display data as tables or as plots.The GUI contains An axes component A pop-up menu listing three data sets that correspond to MATLAB functions: peaks, membrane, and sinc A static text component to label the pop-up menu Three buttons that provide different kinds of plots: surface, mesh, and contourWhen we click a push button, the axes component displays the selected dataset using the specified type of 3-D plot.

How Does a GUI Work?Most GUIs wait for their user to manipulate a control, and then respond to each action in turn. Each control, and the GUI itself, has one or more user-written routines (executable MATLAB code) known as callbacks, named for the fact that they call back to MATLAB to ask it to do things. The execution of each callback is triggered by a particular user action such as pressing a screen button, clicking a mouse button, selecting a menu item, typing a string or a numeric value, or passing the cursor over a component. The GUI then responds to these events.

You, as the creator of the GUI, provide callbacks which define what the components do to handle events. This kind of programming is often referred to as event-driven programming. In the example, a button click is one such event. In event-driven programming, callback execution is asynchronous, that is, it is triggered by events external to the software. In the case of MATLAB GUIs, most events are user interactions with the GUI, but the GUI can respond to other kinds of events as well, for example, the creation of a file or connecting a device to the computer.Although you can provide a callback with certain data and make it do anything you want, you cannot control when callbacks will execute. That is, when your GUI is being used, you have no control over the sequence of events that trigger particular callbacks or what other callbacks might still be running at those times. This distinguishes event-driven programming from other types of control flow, for example, processing sequential data files

Creating a Simple GUI with GUIDELaying Out a GUIGUIDE, the MATLAB graphical user interface development environment, provides a set of tools for creating graphical user interfaces (GUIs). These tools simplify the process of laying out and programming GUIs.The GUIDE Layout Editor enables you to populate a GUI by clicking and dragging GUI components such as buttons, text fields, sliders, axes, and so on into the layout area. It also enables to create menus, context menus, and a toolbar for the GUI. Other tools, which are accessible from the Layout Editor, enable to size the GUI, modify component look and feel, align components, set tab order, view a hierarchical list of the component objects, and set GUI options.Programming a GUIWhen we save we GUI layout, GUIDE automatically generates an M-file that we can use to control how the GUI works. This M-file provides code to initialize the GUI and contains a framework for the GUI callbacksthe routines that execute in response to user-generated events such as a mouse click. Using the M-file editor, we can add code to the callbacks to perform the functions we want.Opening a New GUI in the Layout Editor1 Start GUIDE by typing guide at the MATLAB prompt. This displays the GUIDE Quick Start dialog shown in the following figure.

2 In the Quick Start dialog, select the Blank GUI (Default) template.Click OK to display the blank GUI in the Layout Editor, as shown in the figure

Setting the GUI Figure SizeSet the size of the GUI by resizing the grid area in the Layout Editor. Clickthe lower-right corner and drag it until the GUI is approximately 3 incheshigh and 4 inches wide. If necessary, make the window larger.

Adding the Components1 Add the three push buttons to the GUI. For each push button, select the push button from the component palette at the left of the Layout Editor and drag it into the layout area. Position them approximately as shown in the following figure.

2 Add the remaining components to the GUI. A static text area A pop-up menu An axes Arrange the components as shown in the following

Aligning the ComponentsWe can use the Alignment Tool to align components with respect to one another, if they have the same parent. To align the three push buttons:1 Select all three push buttons by pressing Ctrl and clicking them.2 Select Align Objects from the Tools menu to display the Alignment Tool. figure. Resize the axes component to approximately 2-by-2 inches.3 Make these settings in the Alignment Tool, as shown in the following figure: 20 pixels spacing between push buttons in the vertical direction. Left-aligned in the horizontal direction.4 Click OK. Your GUI now looks like this in the Layout Editor.

Adding Text to the ComponentsAlthough the push buttons, pop-up menu, and static text show some text in the Layout Editor, the text is not appropriate to the GUI being created. This topic shows how to modify the default text. Labeling the Push Buttons Entering Pop-Up Menu Items Modifying the Static TextAfter we have added the appropriate text, the GUI will look like this in the Layout Editor.

Labeling the Push ButtonsEach of the three push buttons lets the user choose a plot type: surf, mesh, and contour. This topic shows you how to label the buttons with those choices.1 Select Property Inspector from the View menu.

2 In the layout area, select the top push button by clicking it.

3 In the Property Inspector, select the String property and then replace the existing value with the word Surf.4 Click outside the String field. The push button label changes to Surf.

5 Select each of the remaining push buttons in turn and repeat steps 3 and 4. Label the middle push button Mesh, and the bottom button Contour.

Entering Pop-Up Menu ItemsThe pop-up menu provides a choice of three data sets: peaks, membrane, and sinc. These data sets correspond to MATLAB functions of the same name. This topic shows how to list those data sets as choices in the pop-menu.1 In the layout area, select the pop-up menu by clicking it.2 In the Property Inspector, click the button next to String. The String dialog box displays.

3 Replace the existing text with the names of the three data sets: Peaks, Membrane, and Sinc. Press Enter to move to the next line.

4 When you are done, click OK. The first item in your list, Peaks, appears in the pop-up menu in the layout area.

Modifying the Static TextIn this GUI, the static text serves as a label for the pop-up menu. The user cannot change this text. This topic shows you how to change the static text to read Select Data.1 In the layout area, select the static text by clicking it.2 In the Property Inspector, click the button next to String. In the String dialog box that displays, replace the existing text with the phrase Select Data.

3 Click OK. The phrase Select Data appears in the static text component above the pop-up menu.

Component Icon DescriptionPush Button Push buttons generate an action when clicked .For example, an OK button might apply settings and close a dialog box. When you click a push button, it appears depressed; when you release the mouse button, the push button appears raised.Slider Sliders accept numeric input within a specified range by enabling the user to move a sliding bar, which is called a slider or thumb. Users move the slider by clicking the slider and dragging it, by clicking in the trough, or by clicking an arrow. The location of the slider indicates the relative location within the specified range.Radio Button Radio buttons are similar to check boxes, but radio buttons are typically mutually exclusive within a group of related radio buttons. That is, when you select one button the previously selected button is deselected. To activate a radio button, click the mouse button on the object. The display indicates the state of the button. Use a button group to manage mutually exclusive radio buttons.Check Box Check boxes can generate an action when checked and indicate their state as checked or not checked. Check boxes are useful when providing the user with a number of independent choices, for example, displaying a toolbar.

Edit Text Edit text components are fields that enable users to enter or modify text strings. Use edit text when you want text as input. Users can enter numbers but you must convert them to their numericequivalents.Static Text Static text controls display lines of text. Static text is typically used to label other controls, provide directions to the user, or indicate values associated with a slider. Users cannot change static text interactively.Pop-Up Menu Pop-up menus open to display a list of choices when users click the arrow.List Box List boxes display a list of items and enable usersToggle Button Toggle buttons generate an action and indicate whether they are turned on or off. When you click a toggle button, it appears depressed, showing that it is on. When you release the mouse button, the toggle button remains depressed until you click it a second time. When you do so, the button returns to the raised state, showing that it is off. Use a button group to manage mutually exclusive toggle buttons.Table Use the table button to create a table component.Axes Axes enable your GUI to display graphics such as graphs and images. Like all graphics objects, axes have properties that you can set to control many aspects of its behavior and appearance.Panel Panels arrange GUI components into groups. By visually grouping related controls, panels can make the user interface easier to understand. A panel can have a title and various borders. Panel children can be user interface controls and axes as well as button groups and other panels. The position of each component within a panel is interpreted relative to the panel. If you move the panel, its children move with it and maintain their positions on the panel.Button Group Button groups are like panels but are used to manage exclusive selection behavior for radio buttons and toggle buttons.

Property InspectorAbout the Property InspectorIn GUIDE, as in MATLAB generally, you can see and set most components properties using the Property Inspector. To open it from the GUIDE LayoutEditor, do any of the following: Select the component you want to inspect, or double-click it to open the Property Inspector and bring it to the foreground Select Property Inspector from the View menu Click the Property Inspector buttonThe Property Inspector window opens, displaying the properties of the selected component. For example, here is a view of a push buttons properties.

Scroll down to see additional properties. Click any property value or icon to the left of one to set its value, either directly in that field or via a modal GUI such as a pop-up menu, text dialog, or color picker. Click the plus boxes on the left margin to expand multiline properties, such as BackgroundColor, Extent, and Position.

Using the Property Inspector to Align ComponentsThe Property Inspector enables you to align components by setting their Position properties. A components Position property is a 4-element vector that specifies the location of the component on the GUI and its size: [distance from left, distance from bottom, width, height. The values are given in the units specified by the Units property of the component.1 Select the components you want to align. See Selecting Components 2 Select Property Inspector from the View menu or click the PropertyInspector button .3 In the Property Inspector, scroll to the Units property and note its currentsetting, then change the setting to inches.4 Scroll to the Position property. A null value means that the element differs in value for the different components. This figure shows the Position property for multiple components of the same size.

5 Change the value of x to align their left sides. Change the value of y to align their bottom edges. For example, setting x to 2.0 aligns the left sides of the components 2 inches from the left side of the GUI.6 When the components are aligned, change the Units property back to itsoriginal setting.

IMNOISETypes of Imnoise: Types of Imnoise: Four types of Imnoise 1) Gaussian2) Poisson3) Salt and pepper4) Spackle 1) Gaussian: Gaussian white noise with constant mean and varianceSyntax: J = imnoise(I,'gaussian',m,v)J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.2) Poisson: poisson noiseSyntax: J = imnoise(I,'poisson')J = imnoise(I,'poisson') generates Poisson noise from the data instead of adding artificial noise to the data. If I is double precision, then input pixel values are interpreted as means of Poisson distributions scaled up by 1e12. For example, if an input pixel has the value 5.5e-12, then the corresponding output pixel will be generated from a Poisson distribution with mean of 5.5 and then scaled back down by 1e12. If I is single precision, the scale factor used is 1e6. If I is uint8 or uint16, then input pixel values are used directly without scaling. For example, if a pixel in a uint8 input has the value 10, then the corresponding output pixel will be generated from a Poisson distribution with mean 10. 3) Salt and Pepper: on and off pixelSyntax: J = imnoise(I,'salt & pepper',d) J = imnoise(I,'salt & pepper',d) adds salt and pepper noise to the image I, where d is the noise density. This affects approximately d*numel(I) pixels. The default for d is 0.05.4) Speckle: multiplicativeSyntax: J = imnoise(I,'speckle',v)J = imnoise(I,'speckle',v) adds multiplicative noise to the image I, using the equation J = I+n*I, where n is uniformly distributed random noise with mean 0 and variance v. The default for v is 0.04.

FILTERS:In signal processing, a filter is a device or process that removes from a signal some unwanted component or feature. Filtering is a class of signal processing, the defining feature of filters being the complete or partial suppression of some aspect of the signal. Most often, this means removing some frequencies and not others in order to suppress interfering signals and reduce background noise. However, filters do not exclusively act in the frequency domain; especially in the field of image processing many other targets for filtering exist. Correlations can be removed for certain frequency components and not for others without having to act in the frequency domain. Types of filters: Three types of filter1) wiener22) Ordfilt23) medfilt2

1) Wiener2: 2-D adaptive noise-removal filteringSyntax: J = wiener2(I, [m n], noise) [J, noise] = wiener2(I, [m n]) wiener2 lowpass-filters a grayscale image that has been degraded by constant power additive noise. wiener2 uses a pixelwise adaptive Wiener method based on statistics estimated from a local neighborhood of each pixel. J = wiener2(I, [m n], noise) filters the image I using pixelwise adaptive Wiener filtering, using neighborhoods of size m-by-n to estimate the local image mean and standard deviation. If you omit the [m n] argument, m and n default to 3. The additive noise (Gaussian white noise) power is assumed to be noise. [J, noise] = wiener2(I, [m n]) also estimates the additive noise power before doing the filtering. wiener2 returns this estimate in noise. 2) Ordfilt2: 2-D order-statistic filtering Syntax: B = ordfilt2(A, order, domain) B = ordfilt2(A, order, domain, S) B = ordfilt2(..., padopt) B = ordfilt2(A, order, domain) replaces each element in A by the orderth element in the sorted set of neighbors specified by the nonzero elements in domain. B = ordfilt2(A, order, domain, S) where S is the same size as domain, uses the values of S corresponding to the nonzero values of domain as additive offsets. B = ordfilt2(..., padopt) controls how the matrix boundaries are padded. Set padopt to 'zeros' (the default) or 'symmetric'. If padopt is 'zeros', A is padded with 0's at the If padopt is 'symmetric', A is symmetrically extended at the boundaries.3) Medfilt2: 2-D median filtering Syntax: B = medfilt2(A, [m n]) B = medfilt2(A) B = medfilt2(A, 'indexed', ...) B = medfilt2(..., padopt) Median filtering is a nonlinear operation often used in image processing to reduce "salt and pepper" noise. A median filter is more effective than convolution when the goal is to simultaneously reduce noise and preserve edges. B = medfilt2(A, [m n]) performs median filtering of the matrix A in two dimensions. Each output pixel contains the median value in the m-by-n neighborhood around the corresponding pixel in the input image. medfilt2 pads the image with 0s on the edges, so the median values for the points within [m n]/2 of the edges might appear distorted. B = medfilt2(A) performs median filtering of the matrix A using the default 3-by-3 neighborhood. B = medfilt2(A, 'indexed', ...) processes A as an indexed image, padding with 0s if the class of A is uint8, or 1s if the class of A is double. B = medfilt2(..., padopt) controls how the matrix boundaries are padded. padopt may be 'zeros' (the default), 'symmetric', or 'indexed'. If padopt is 'symmetric', A is symmetrically extended at the boundaries. If padopt is 'indexed', A is padded with ones if it is double; otherwise it is padded with zeros.

BIBLIOGRAPHY GGSTP Manuals Daily Diary www.Google.com www.wikipedia.com