Docsity

MATLAB Image Processing-Digital Image Processing-Lecture 04 Slides Slides-Electrical and Computer Engineering, Slides of Digital Image Processing

Partial preview of the text

Download MATLAB Image Processing-Digital Image Processing-Lecture 04 Slides Slides-Electrical and Computer Engineering and more Slides Digital Image Processing in PDF only on Docsity!

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-

Computer Vision &

Digital Image Processing

MATLAB for Image Processing

Matlab introduction

• Basic MATLAB commands

• MATLAB windows

• Reading images

• Displaying images

– image()

– colormap()

– mesh()

– view()

• Basic matrix operations

• MATLAB Web site: http://www.mathworks.com

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-

Starting MATLAB

  • On the PC, click the matlab icon
  • On a workstation, type ‘matlab’

Creating a window (MATLAB figure)

• figure : Create figure window.

• figure , by itself, creates a new figure window, and returns

its handle.

• figure (H) makes H the current figure, forces it to become

visible, and raises it above all other figures on the screen. If

Figure H does not exist, and H is an integer, a new figure is

created with handle H.

• GCF returns the handle to the current figure.

• Execute get (H) to see a list of figure properties and their

current values.

• Execute set (H) to see a list of figure properties and their

possible values.

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-

Example bitmap file read

• [lena,lmap]=bmpread('lena128.bmp');

Name of the array which

will hold the pixel data

Name of the array which

will hold the colormap

File to read: in this case

lena64.bmp is a 128x

image with a gray scale

colormap

Displaying the image

• To display the image in the current figure, use the image()

command

  • image(lena);

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-

Setting the colormap

  • To set the colormap for a particular figure, use the colormap()

function

  • colormap(lmap);
  • combined commands: image(lena);colormap(lmap);

Other ways of viewing the image

• The image() command gives an expected visual

representation of an image

• Other views of the image, say perhaps as a three-D

plot, may reveal information about the image not

obvious in a 2-D representation

• The mesh() command will display a 3-D mesh plot

of the image data with a default viewing perspective

• The view() command allows selection of a user

specified viewpoint

– view(-15,-70) seems to be a good choice

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-

Creating arrays

• Arrays and/or matrices may be entered as follows:

EDU» A=[

1 2 3];

• Creates a 3x3 matrix

• A=[1 2 3;1 2 3;1 2 3]; accomplishes the

same thing

A

Multiplying matrices

• Given matrices:

• Performing C=A*B yields:

• Performing D=A.*B yields:

(an element-by-element multiply)

A

B

C

D

Other matrix operations

• Scalar operations: addition & multiplication

• Powers of arrays

• Obtaining matrix sizes and values

– size(), length(), max(), min()

• Creating special arrays: all zeros, all ones,

diagonal, etc.

– zeros(), ones(), linspace(), rand(), diag()

• Array searches and comparisons

• Logical operations