MATLAB_tutorial

MATLAB_tutorial - An introductory tutorial on MATLAB in Image Processing ECE 178(1-2pm Discussion batch TA Srivatsan Pallavaram I GETTING STARTED

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
An introductory tutorial on MATLAB in Image Processing ECE 178 (1-2pm Discussion batch, TA: Srivatsan Pallavaram) I. GETTING STARTED MATLAB is a data-analysis and visualization tool widely used by electrical engineers and stands for “Mathematics Laboratory.” The most important difference between MATLAB and C (or C++) is that functions in MATLAB are specifically written with a focus on large array- based operations in mind. Image processing is heavy on the memory usage as well as the run- time of programs. You would need the Image Processing toolbox installed in your MATLAB to work with the commands that are listed later in this worksheet. You can check if the Image Processing toolbox is installed using the ver command. Using “help images” one can see all the commands that are supported in this toolbox. If you find the help document scrolling past very fast you can switch the ‘more’ command using >> more on or for a more formal help use >> doc ‘command’ A MATLAB function is a keyword that accepts various parameters, and produces output of some sort. At times in this course, we may need to write our own functions (and this is very easy as you will see). A command is a particular usage of a function. Variables are elements used to store values. If you are using a windowed version of MATLAB, you may find a Workspace item in the View menu. This lists all your currently defined variables, their data types, sizes etc. Exercise 1: Explore the whos and who commands that are used to list the variables used in the workspace. At this point, I would like to stress that learning/ understanding MATLAB is impossible by just reading this handout. The exercises in this handout are motivated primarily by this reason. Using standard MATLAB routines “efficiently” Could mean the difference between a program that runs for a day and one that runs in an hour. Use of for loops is known to increase the run- time by a significant amount. Exercise 2: This exercise describes how ‘slow’ the for command can be. We can measure the time that elapses between the executions of a command using the tic toc timer of MATLAB. tic starts a stopwatch timer and toc stops it and prints out the elapsed time in seconds. Execute the following code and compare the elapsed time differences between the two. >> tic; for i = 1:10ˆ6, sin(i);end; toc; >> tic; i=1:10ˆ6; sin(i); toc; Understand how the for loop can slow down the process by quite a bit. II. BASIC MATRIX OPERATIONS IN MATLAB The standard data type of MATLAB operations is the matrix. Images, of course, are matrices whose elements are the gray values (or possibly the RGB values) of its pixels. I am assuming that most of you are aware of the basics of MATLAB. More information on these commands can be obtained using the help and lookfor commands. A standard 2 × 3 matrix is defined as >> A = [a11 a12 a13; a21 a22 a23;]; Matrix elements can be obtained using the standard row, column indexing scheme >> a(2,3) The reshape
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/28/2011 for the course ECE 178 taught by Professor Manjunath during the Fall '08 term at UCSB.

Page1 / 3

MATLAB_tutorial - An introductory tutorial on MATLAB in Image Processing ECE 178(1-2pm Discussion batch TA Srivatsan Pallavaram I GETTING STARTED

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online