Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

MATLAB Image Processing: Understanding Scalars, Vectors, Matrices, and Image Operations, Lab Reports of Electrical and Electronics Engineering

An introduction to matlab image processing, covering the basics of scalars, vectors, matrices, and image operations. Topics include understanding the difference between element-by-element computations and matrix computations, using functions, and working with various image types and formats. Students are encouraged to read the provided resources and complete exercises for further learning.

Typology: Lab Reports

Pre 2010

Uploaded on 08/30/2009

koofers-user-2wi
koofers-user-2wi 🇺🇸

10 documents

1 / 4

Toggle sidebar

Related documents


Partial preview of the text

Download MATLAB Image Processing: Understanding Scalars, Vectors, Matrices, and Image Operations and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity! Handout #3 ECE 178 Jan 10, 2006 W2006 Guidelines for Getting Started with Matlab I. You should familiarize yourself with the Matlab environment by either accessing the online documentation or the help/Matlab help menu within Matlab. The online documentation at http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.html does not require you to have Matlab on your computer (i.e. can be read at home). Do not worry about remembering all the details because you will learn them as the course progress. Below are some key items to which you should give more attention. 1) Know how to define and perform computations on scalars, vectors, and matrices (addition, multiplication, etc.). 2) Make sure you understand the difference between element-by- element computations and matrix computations, i.e. the difference between A.*B and A*B. 3) Understand how to use and write functions (look up functions in help for more details). 4) Know simple plotting in 2D. II. You should read over the information on the Matlab Image Processing Toolbox at http://www.ece.ucsb.edu/~manj/ece178/matlabip.htm and the online/Matlab documentation for the Image Processing Toolbox. Here are some key items. 1) Understand the types of images: Indexed, Intensity, Binary, RGB. 2) Understand some basic image formats: jpg, bmp, tiff, etc. 3) Know how to load/read an image onto the workspace, and how to save/write an image from the workspace. 4) Know how the image data is represented in the workspace. 5) Know how to convert from one image type/format to another. 6) Understand image coordinates. 7) Know how to display an image. III. You should read and do some of the exercises from An introductory tutorial on MATLAB in Image Processing (attached to this page). Note the Common Pitfalls section. An introductory tutorial on MATLAB in Image Processing ECE 178, W2006 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 function produces a matrix with elements taken column by column from the given matrix. MATLAB also allows matrix elements to be obtained using a single number; this number being the position when the matrix is written as a single column. For e.g. a matrix with r rows and c columns, element a(i, j) corresponds to a(i + r · (j - 1)). We would rarely be using this notation. Addition of matrices is done as >> c = a+b; The inv, det and ’ commands do the inverse, determinant and transpose operations respectively. Exercise 3: Matrices can be flipped up or down using flipud, left or right using fliplr and rotated by 90 degrees by rot90. Explore them. To obtain a row of values, or a block of values, we use the colon (:) operator. Pointwise multiplication (Hadamard product of two matrices) is done with >> c = a.*b; We also have dot division and dot powers. The command >> a.ˆ2 produces a matrix, each element of which is the square of corresponding elements of a. Exercise 4: Using the colon and dot operators alone, generate the first 15 cubes. Sometimes, we would need to generate some special matrices and random matrices. An
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved