0% found this document useful (0 votes)
167 views

Practical Image and Video Processing Using MATLAB®

Uploaded by

misbah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
167 views

Practical Image and Video Processing Using MATLAB®

Uploaded by

misbah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Practical Image and Video Processing

Using MATLAB®

MATLAB basics

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
What will we learn?
 What is MATLAB and why has it been selected to be
the tool of choice for this book?

 What programming environment does MATLAB


offer?

 What are M-files?

 What is the difference between MATLAB scripts and


functions?

 How can I get started in MATLAB?

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Introduction to MATLAB
 MATLAB (MATrix LABoratory):
 A Data analysis tool
 A Prototyping tool
 A Visualization tool
 Has built-in support for matrices (basic data type) and matrix operations
 Has excellent graphics capabilities
 Is a high-level programming language and development environment.
 Has extensive built-in documentation
 Excellent Help with Examples
 Demos

 Many toolboxes (including the Image Processing Toolbox – see


Chapter 4).
 “Hands on”
 Try Tutorial 3.1: MATLAB - a guided tour on page 44.

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Introduction to MATLAB
 MATLAB algorithm development environment provides:
 Command line interface
 An interpreter
 Matlab acts as an interpreter b/w user code and computer hardware
 It interprets commands, which shortens programming time by
eliminating the
 need for compilation.
 Extremely convenient when goal is rapid algorithm prototyping
 Once algo. is stable, it can be compiled with MATCOM for faster execution,
which is particularly important for large data sets.
 An extensive set of (numerical and string manipulations) functions
 2D and 3D plotting functions
 Ability to build GUI

 MATLAB - a guided tour on page 44.

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Basic elements of MATLAB
 Working environment
 Matlab Desktop
 Matlab Editor
 Help System

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Basic elements of MATLAB
 Matlab Desktop

A: Workspace
B: Command History
C: Current Directory
D: Command Window
+ Figure Window(s)

Set Path

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Basic elements of MATLAB
 Matlab Editor
 Used to create and edit M-files (Scripts + Functions)
 Includes useful functions for saving, viewing, and debugging etc.

 Matlab Help System


 Includes help browser which displays help documents
 doc imread
 Help h1 line
 Lookfor integration
 helpwin
 Demos

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Basic elements of MATLAB
Important!!!
 Command Window: ✓ Semicolon
 clc ➢ Output Suppression
➢ End of Row
 clear / clear all
✓Colon
 close all ➢ Vector Creation
 who ➢ Row/Colum Selection
➢ Makes 2D matrix a column
 whos matrix
 which ✓linspace
 ver / version ✓( ) function
➢ Input arguments
 computer ➢ Matrix Subscript
✓[ ] function
➢ Output arguments
➢ Matrix Definition
➢ Deletion / Empty matrix
➢ Concatenation (cat); See
also repmat
By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Basic elements of MATLAB
 Data classes / Data Types

{
Non-Numeric
By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Basic elements of MATLAB
 Standard arrays • (b-a)*rand(m,n)+a
• std*randn(m,n)+
• round(randn(m,n))
• randi(imax,m,n)
•Randperm( )

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
M-files: scripts and functions
 Command Line operation  Executing one line at a time
 M-files in MATLAB can be:
 scripts that simply execute a series of MATLAB commands or
statements; or
 functions that can accept arguments (parameters) and produce one or
more output values.

 Scripts
 An M-file containing a script consists of a sequence of commands to be
interpreted and executed.
 M-files are syntax color coded to aid in reading them.
 In addition to calls to built-in functions, scripts may also contain variable
declarations, calls to user-created functions, decision statements and
repetition loops.
 Scripts are usually created using a text editor and stored with a
meaningful name and the .m extension.

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
M-files: scripts
 Scripts
 Once a script has been created and saved, it can be invoked
from the command line simply by typing its name.
 Or F5 / F9 function keys for full and partial execution.
 The Cell Mode: A new editing mode allows you to make
minor adjustments to variables, and re-execute a block of
code easily.
 Cell blocks allow you to modify and execute one block of code at a time.
 To create a cell block, all you need to do is give it a block title (using %%).
 More than one cell block can exist in a single script.
 Example: script3_3_2.m.

By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.

You might also like