Practical Image and Video Processing Using...

15
Chapter 3 – MATLAB basics Practical Image and Video Processing Using MATLAB® By Oge Marques Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.

Transcript of Practical Image and Video Processing Using...

Page 1: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

Chapter 3 – MATLAB basics

Practical Image and Video Processing Using MATLAB®

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

Page 2: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

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.

Page 3: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

Introduction to MATLAB

MATLAB (MATrix LABoratory): data analysis, prototyping, and visualization tool with built-in support for matrices and matrix operations, excellent graphics capabilities, and a high-level programming language and development environment.

Very popular with engineers, scientists, and researchers in both industry and academia.

Extensive built-in documentation.

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.

Page 4: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

Basic elements of MATLAB

Working environment

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

Workspace variables

Command history

Current directory

Command window

Page 5: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

Basic elements of MATLAB

Data classes

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

Page 6: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

Basic elements of MATLAB

Standard arrays

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

Page 7: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

M-files: scripts and functions

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.

In addition to calls to built-in functions, scripts may also contain variable declarations, calls to user-created functions (which may be stored in separate files), decision statements and repetition loops.

Scripts are usually created using a text editor (e.g., the built-in MATLAB Editor) and stored with a meaningful name and the .m extension.

Once a script has been created and saved, it can be invoked from the command line simply by typing its name.

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

Page 8: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

M-files: scripts and functions

Functions

An M-file containing a function has the following structure:

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

Page 9: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

M-files: scripts and functions

Functions Example

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

Page 10: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

MATLAB array and matrix arithmetic operators

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

Page 11: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

MATLAB specialized matrix operations

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

Page 12: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

MATLAB specialized arithmetic functions supported by the IPT

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

Page 13: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

MATLAB relational and logical operators and logical functions

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

Page 14: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

MATLAB selected built-in variables and constants

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

Page 15: Practical Image and Video Processing Using MATLAB®instructor.sdu.edu.kz/~konst/cv2015/week03/Slides_Chapter03.pdf · Practical Image and Video Processing Using ... An M-file containing

Hands-on

Tutorial 3.1: MATLAB - a guided tour (page 44)

Tutorial 3.2: MATLAB data structures (page 46)

Tutorial 3.3: Programming in MATLAB (page 53)

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