1
1371 Review Test #3
1.
Matrices/Images
a.
Images are just a three dimensional matrix, or three layers of matrices laid on top of one another, so
we‟ll lump them together.
b.
Access matrices my saying
mat(row,column) (with numbers obviously)
c.
Ok, so vectors are of size 1xNx1
and we only need one loop.
Matrices are RxCx1 and we need two
loops to go through each row and each column.
Images are RxCxD and we need 3 loops: one for
rows, one for columns, and one for dimensionality ( <
cool word, isn‟t it?)
d.
To make a matrix you enter them with the [ ] brackets marking the ends of the matrix and a
semicolon to delineate the rows
i.
x = [ 1 2 3 ; 4 5 6 ; 7 8 9]
<= 3x3 matrix
e.
Kicker about matrices is that you can use vectors to index both the rows and columns… for example
,
lets say that mat is a 24 x 56 matrix and you want to get the top right hand corner of that… how do
you do it? vector indexing in a matrix
i.
[r c ]
= size(mat)
new = mat( floor(r/2) : r ,
floor(c/2):c)
f.
General template for iterating through a matrix in which you need to check every element of matrix:
[r c] = size(mat)
for i1 = 1 : r
for i2 = 1 : c
Check stuff using mat(i1,i2)
end
end
g.
For an image, it is:
mat = imr
ead(pic)
<= necessary depending on what question tells you…
[r c d] = size(mat)
for i1 = 1 : r
for i2 = 1 : c
for i3 = 1 :d
Check stuff using mat( i1 , i2 , i3 )
end
end
h.
One of the trickier point about images is deciding when to use mat = double(mat) and then later on
use mat = uint8(mat) … Look at the points below to have a better idea…
i.
Since image matrices are of type unit8, the
y have a max range of 0 to 255 … also, none of the
mathematical operations work the way you would like them to ( see below ) on a unit8 data
type.
So if you are told to double the intensities, take the square root of the intensities, or
even just add 10 to everything, you must first convert the image matrix to double, perform
the operation, then cast it back to unit8.
1.
a = uint8(250);
b = a+15
b =
255
ii.
As a general rule with image matrices, you won‟t be hurt if you convert it to double then
back to unit8 … even if you don‟t need to do it, you will not hurt anything in the matrix.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2
i.
Also, some of the nice matrix manipulations we know only work on a 1 dimensional matrix (like the
transpose)… in order to fix this, you must iterate through the dimensions and look
at each layer
individually… this way you are only dealing with a 1
D matrix.
2.
Sound
a.
Analog vs. Digital
i.
The main difference between the analog and digital in reference to sound is that the analog
signal is a continuous line whereas the digital signal has to be sampled at a specific time
interval so that the computer can store the information at specific time intervals and not the
entire sound.
ii.
Even though we are not hearing every part of the sounds, for standard CD quality, there are
44100 samples in a second.
In a human sensory phenomenon, our brain fills in the gaps of the
blank sounds and puts it all together as a continuous sound. (Another example of this
phenomenon is the idea of blinking: every time you blink, it isn‟t like the lights go out for a
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '07
 Haris
 Numerical Analysis, Derivative

Click to edit the document details