PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

56 Practical MATLAB® Applications for Engineers


R.1.169 For example, the color image of the magic(10) matrix is processed and displayed as
follows, Figure 1.46:
MATLAB Solution




image(magic(10))
title(‘Image of the magic(10) matrix’)




R.1.170 Images can be transformed and processed by the fi ltering functions presented in
Chapter 6. In general, the fi ltering process involves sophisticated mathematical
manipulations, that rely on the theory of complex variables and transform theory.
Precisely for these reasons MATLAB provides its users with simple fi ltering
commands, avoiding all the complicated mathematics used on image processing
defi ned for 2-D matrices such as gradianr(matrix_A) and del1(matrix_A).
The command gradianr(matrix_A) returns the numerical gradient, whereas the
command del1(matrix_A) returns its derivative (the discrete Laplacian).


R.1.171 Let us illustrate some of the image processing techniques by performing the fi rst
and second derivative using as an illustrative example, the matrix y = magic(10).
The results are shown in Figures 1.47 and 1.48.
MATLAB Solution
y = magic(10);




ygrad = gradient(y);
figure(1);
image(ygrad)
title(‘gradient of magic(10)’)
ydel2 = del2(y);
figure(2);
image(ydel2)
title(‘second derivative (del2) of magic(10)’)




R.1.172 Animation and motion of video signals can be accomplished using MATLAB by
displaying pictures or fi gures one after the other, referred to as frames.


R.1.173 The MATLAB command getframe captures the content of the current fi gure win-
dow and creates with it a movie frame. The getframe command is placed usually


FIGURE 1.46
(See color insert following page 374.) Color plot of the magic matrix of R.1.169.


Image of the magic (10) matrix
1 2 3 4 5 6 7 8 9

10
12345678910
Free download pdf