Graphics Programs Reference
In-Depth Information
ans(:,:,2) =
9
9
9
And to sum over “pages”:
>> sum(a,3)
ans =
4
5
6
7
8
9
10
11
12
Note that sum(a) is equal to sum(a,1) . The sum over “pages” gives a
3
1 matrix.
The sum function and other functions that operate on vectors, like
mean , diff , max , and so on, work as you might expect them to for multi-
dimensional arrays. By default they usually operate on the first non-
singleton dimension of the array. Many functions that operate on two-
dimensional matrices do not have such straightforward multidimensional
extensions. For example, if we try to take the transpose of our matrix:
×
3 matrix, which is the same as a 3
×
3
×
>> a'
??? Error using = = > '
Transpose on ND array is not defined.
The transpose operation (exchanging rows and columns) makes no sense
here because it is insu@ciently specified. (If you want to rearrange a
multidimensional array's dimensional ordering, use the permute func-
tion; in our example, try permute(a,[2 1 3]) ). Another example is
the eigenvalue operator eig , which has no mathematical meaning for
multidimensional arrays. In fact, none of the functions that appear if
you type help matfun has a reasonable meaning for multidimensional
matrices. Nor do the matrix operators * , ^ , \ or / .
29.3 RGB Images
Introduction to RGB Images
RGB images in matlab are M
3 matrices consisting of red, green,
and blue intensity maps. When such a three-dimensional matrix is used
as an input to the image command, matlab adds the red, green, and
blue intensities to give the right colours on the screen. To illustrate the
idea, our first example reproduces three overlapped discs of red, green,
and blue light to give yellow, cyan, magenta, and white overlaps. We
generate matrices of ( x, y ) points covering the plane from
×
N
×
2to2:
[x,y] = meshgrid(linspace(-2,2,200));
Search WWH ::




Custom Search