* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Matrices and Pictures
Capelli's identity wikipedia , lookup
Matrix completion wikipedia , lookup
System of linear equations wikipedia , lookup
Linear least squares (mathematics) wikipedia , lookup
Rotation matrix wikipedia , lookup
Eigenvalues and eigenvectors wikipedia , lookup
Principal component analysis wikipedia , lookup
Jordan normal form wikipedia , lookup
Determinant wikipedia , lookup
Four-vector wikipedia , lookup
Singular-value decomposition wikipedia , lookup
Matrix (mathematics) wikipedia , lookup
Perron–Frobenius theorem wikipedia , lookup
Orthogonal matrix wikipedia , lookup
Non-negative matrix factorization wikipedia , lookup
Gaussian elimination wikipedia , lookup
Cayley–Hamilton theorem wikipedia , lookup
GK-12 Sensors! Portable Module Matrices and Pictures Lesson 2: Matrix Operations with digital pictures Anthony Puckett Introduction: Show slide 2. (X-ray of foot) Once a picture is represented by a matrix, the picture can be altered by using various matrix operations. Three matrices usually represent color pictures, one for each of the primary colors: red, green and blue (a.k.a. rgb). However, a single matrix can represent black and white pictures. The matrix operations are demonstrated on a single matrix representing a black and white digital X-ray. Contrast and Scalar Multiplication: Show slide 3. (Contrast: Scalar Multiplication) The students should be well versed in scalar multiplication and addition of matrices (you might want to make sure though). However, the students have probably not been exposed to a scalar multiple that is a function of the matrix element. This is the matrix operation needed to change the contrast or brightness. In effect a new matrix is being created from a function of the original matrix. Y f (X ) , where Y is a new matrix that is function of the original matrix X. This function is evaluated for element at each location in the original matrix to create an element at the same location in the new matrix. For example, Y (1,1) f ( X (1,1)) . The only constraint on the function is the range must be the same as the domain. So if the colors are represented by the integers from 1 to 256, the elements created in the new matrix must also be integers from 1 to 256. Rounding may be required. Several different functions are illustrated in slides 4 through 7. The students can be asked to derive the function for each graph to reinforce the concepts the students should already know. Show Slides 4-7. (Various functions) A histogram can be used to help determine a good function for creating better contrast. The histogram is a plot of the number of pixels for each color value in a picture. Show Slide 8. (Histogram) There are a large number of pixels at the lower half of the integers, so these values are doubled. The upper half the integers can’t be doubled because the range would be larger than the domain of the colors, so they are set equal to one. Show Slide 9. (Slope) Edge Sharpening: Convolution Convolution is a new operation for the students and not a common operation. It is an operation between two matrices that creates a scalar. In this case two 3x3 matrices are considered. The value of an element is multiplied by the value of the same element in the other matrix. The products of all 9 elements are summed to produce a scalar. Show Slide 10. (Convolution) In order to use convolution for edge sharpening the original matrix, X, needs to be altered slightly. A row or column of zeros is added to each edge of the matrix to create a new matrix, Xnew. A 3x3 matrix or filter, H, is used for the convolution. The filter is convolved with every smaller 3x3 matrix in Xnew. The scalar that is produced from the convolution is an element in the new matrix, Y. The location of the element in the new matrix corresponds to the element at the center of the 3x3 matrix in the original matrix, X. Show Slide 11 & 12. (Convolution and X-ray sharpened) Activity: Make your own contrast function (Optional) If there is time the students can suggest their own functions to change the contrast. This requires the file contrast.m and the program MATLAB. The contrast function should be changed for both the matrix X and the vector y.