Matrices and Digital Pictures: Part II

advertisement
GK-12 Sensors!
Matrices and Digital Pictures
Part II - Matrix operations with digital pictures.
GK-12 Sensors!
• Original Digital XRay
• 320 x 224
• 256 shades of gray
General Electric
GK-12 Sensors!
Contrast: Scalar Multiplication
Y  f (X )
Y (1,1)  f ( X (1,1))
• X is the matrix of the
original picture
• Y is the matrix of the
new picture
• Y is a function of X
• Matrix is multiplied
by a scalar to shift
color
• Scalar is defined by a
set of equations.
• The range of the
element values must
remain the same
GK-12 Sensors!
Negative
0  X 1
Y  1 X
1
0.8
Output
0.6
0.4
0.2
0
0
Original (X)
Negative (Y)
0.2
0.4
0.6
Input
0.8
1
GK-12 Sensors!
Square
0  X 1
Y (1,1)   X (1,1) 2
1
0.8
Output
0.6
0.4
0.2
Original (X)
Square (Y)
0
0
0.2
0.4
0.6
Input
0.8
1
GK-12 Sensors!
Square root
0  X 1
Y  1  ( X  1) 2
1
0.8
Output
0.6
0.4
0.2
Original (X)
Square root (Y)
0
0
0.2
0.4
0.6
Input
0.8
1
GK-12 Sensors!
Haversine
0  X 1
1
Y  1  cosX 
2
1
0.8
Output
0.6
0.4
0.2
Original (X)
Haversine (Y)
0
0
0.2
0.4
0.6
Input
0.8
1
GK-12 Sensors!
Histogram - A plot of the number pixels for each color value.
10000
Number of Pixels
8000
6000
4000
2000
0
0
50
100
150
200
Element Value
250
300
GK-12 Sensors!
Slope
0  X  0.5
0.5  X  1
Y  2X
Y 1
1
0.8
Output
0.6
0.4
0.2
0
0
Original (X)
Slope (Y)
0.2
0.4
0.6
Input
0.8
1
GK-12 Sensors!
Edge Sharpening: Convolution
1 1 1
H  1 9 1
• Convolution is an
operation between two
X 0 1 2
same size matrices that
0 2 2
1 1 1
creates a scalar.
• The elements at the same
location in each matrix are
y  H (1,1) X (1,1)  H (1,2) X (1,2)  ...
multiplied
• This product is summed
y  0  0  0  0  9  2  0  2  2  3 with the product of the
other elements.
0 0 0
GK-12 Sensors!
X
1 1 1
H  1 9 1
1 2
2 2
0
0
X new 
0
0
1 1 1
0
1
2
0
Y
0
2
2
0
0
0
0
0
3 13
13 13
• A new matrix of the same
size needs to be created
• Start with the matrix of
the original picture, X
• Add a row or column of
zeros on each edge
• Choose a 3x3 matrix from
Xnew convolve with H
• Create a new matrix, Y, by
convolving H with every
3x3 matrix
GK-12 Sensors!
Original (X)
Edge Sharpening
Download