You are on page 1of 20

Digital Image Processing

2008/2009

Background - matrices

09-Oct-2008
Matrices - examples

A matrix is a rectangular table of numbers

1 4 3 1
1 0  6 43
 
7 0 87 0 
 
 5 56 5 0
Matrices - examples

A matrix is a rectangular table of numbers

 3.2  0.9 1 1.4  8 


 0 
9.3 3.1 5  9.1

 0.9  0.9 0 11 8.3 
Matrices - examples

A matrix is a rectangular table of numbers

 0.5
 1.2
 
 7.8
 
 9.2
 0.5
Matrices - examples

A matrix is a rectangular table of numbers

 a11 a12 
a a22 
 21
a31 a32 
Terminology

The horizontal lines in a matrix are called rows

1 4 3 1
1 0  6 43
 
7 0 87 0 
 
 5 56 5 0
Terminology

The vertical lines in a matrix are called columns

1 4 3 1
1 0  6 43
 
7 0 87 0 
 
 5 56 5 0
Terminology

An element of a matrix can be defined by its row and its column

1 4 3 1
1 0  6 43
 
7 0 87 0 
 
 5 56 5 0

This is the (2,3) element of the matrix.


Terminology

If a matrix has n rows and m columns we say that its dimension is n x m.

The dimension of this matrix is 3 x 5

 3.2  0.9 1 1.4  8 


 0 9. 3 3.1 5  9.1
 
 0.9  0.9 0 11 8.3 
Matrix addition

The addition of matrices is component-wise.

The two matrices must have the same dimension.

 a11 a12  b11 b12   a11  b11 a12  b12 


a    
 21 a22  b21 b22  a21  b21 a22  b22 
Matrix addition

Example 1:

2 3 1 3 3 6 
1 2  0 9  1 11
     
Scalar multiplication

The multiplication of a matrix by a number is component-wise

 a11 a12   c  a11 c  a12 


c 
a21 a22  c  a21 c  a22 

Scalar multiplication

Example 2:

1 7 3 21
3    
 0 2   0 6 
Matrix multiplication
Let A be a n x m matrix and let B be a m x k matrix.

Then A*B is a n x k matrix

 a11 a12  a1m   b11 b12  b1k   c11 c12  c1k 


a a 22  a 2 m   b21 b22  b2 k  c21 c22  c2 k 
 21 * 
             
     
 a n1 an 2  anm  bm1 bm 2  bmk  cn1 cn 2  cnk 

m
with cij   ail blj
l 1
Matrix multiplication
To find the (i,j) element of the A*B matrix:

• take the i-th row of A, that is ( ai1 , ai 2 ,..., aim )

• take the j-th column of B, that is (b1 j , b2 j ,..., bmj )

• multiply them component-wise and add the components

cij  ai1b1 j  ai 2b2 j    aim bmj


Matrix multiplication

Example 3:

1 3 4 0 0 2 15 
5 2 1  * 1 1 0   
     
0 1 2 3 1 1  

1*0 + 3*1 + 4*3 = 15


Matrix multiplication

Example 3:

1 3 4 0 0 2 15 7 
5 2 1  * 1 1 0   
     
0 1 2 3 1 1  

1*0 + 3*1 + 4*1 = 7


Matrix multiplication

Example 3:

1 3 4 0 0 2 15 7 6
5 2 1 * 1 1 0   
     
0 1 2 3 1 1   

1*2 + 3*0 + 4*1 = 6


Matrix multiplication

Example 3:

1 3 4 0 0 2 15 7 6
5 2 1 * 1 1 0   5 
     
0 1 2 3 1 1   

5*0 + 2*1 + 1*3 = 5


Matrix multiplication

Example 3:

1 3 4 0 0 2 15 7 6 
5 2 1  * 1 1 0   5 3 11
     
0 1 2 3 1 1   7 3 2 

You might also like