Module2ImageProcessing
Module2ImageProcessing
Authors:
Tamar Avineri, North Carolina School of Science and Mathematics, Durham NC
Emily Berkeley, Panther Creek High School, Cary, NC
Ashley Miller, North Rowan High School, Spencer, NC
Abstract: In this all-inclusive module students will learn how to use matrices and vectors to manipulate and
edit images. The students will be provided with their own image editing activity where they will create their
own classroom “Instagram feed.” There is also an extension activity that incorporates some basic Python
programming into this module.
The authors would like to acknowledge the support of the National Science Foundation through the grant
DMS-1845406
2
Implementation Notes 3
Lesson 1: Introduction to Matrices and Matrix Operations 5
Lesson Plan 5
Guided Notes – Teacher Version 9
Lesson 2: Matrix Multiplication 14
Lesson Plan 14
Guided Notes – Teacher Version 16
Lesson 3: Introduction to Image Processing 22
Lesson Plan 22
Guided Notes – Teacher Version 25
Lesson 4: (Extension) Image Processing using Computer Science 40
Lesson Plan 40
Lesson 5: Instagram Project 42
Lesson Plan 42
Warm-Up – Teacher Version 44
Instagram Project 47
References and Additional Readings 48
Appendices 49
Appendix A: Lesson Materials – Student Versions 49
Lesson 1: Guided Notes – Student Version 49
Lesson 2: Guided Notes – Student Version 54
Lesson 3: Guided Notes – Student Version 61
Lesson 5: Warm-Up – Student Version 9
Appendix B: Lesson Materials – Templates/Examples 15
Lesson 4: Math Symbols Image 15
Lesson 5: Instagram Project Stock Images 16
Lesson 5: Instagram Project Example 18
3
Implementation Notes
v Length of module:
Ø In total, this unit is designed to take approximately 3.5 days of 90-minute lessons, or
7 days of 45-minute lessons, including the final project. There is also an extension
project that is designed to take approximately 85 minutes.
Ø Each of the lessons is accompanied by an estimate of the length of time it is
designed to take in class. If the estimate is longer than you can devote in class, feel
free to select portions for students to complete outside of class.
Ø There is an extension project that includes coding in Python. This is a lesson that is
intended for Discrete Math for Computer Science but would be a great tool if you
have the extra time to implement the lesson in the Math 4 or Pre-Calculus class.
v Assessments:
Ø Feel free to select portions of the guided notes to serve as out-of-class activities.
Ø Any problem set contained within guided notes could be given as homework
assignments.
Ø As an alternative to the final project in this module, you could choose to give
students a standard test or quiz on the skills that have been learned.
v Student Versions: Please note that the student versions are located at the end of this
document in Appendix A.
5
Lesson Plan
(~60 minutes)
Warm Up ~15 Students read the opening problem (e.g., Teacher hands out a sheet of
Elicit/Engage min Textbook Problem or other context of paper with the opening
Build relevance through a interest) from a handout and/or projected problem written on it and/or
problem on a screen. projects it on the screen.
Try to find out what your In groups of 2-3, students talk briefly about Teacher opens with the
students already know how they would answer the question from question, “How might we
Get them interested the teacher. (~5 minutes) The teacher brings organize this information in a
back students to share out with the class. (~3 way that allows us to answer
minutes) questions about the
Students are provided guided notes to university’s inventory?”
document new terms (e.g., matrix,
dimension, row, column, etc.) They will After students discuss, the
complete the notes through the discussion teacher solicits students’
conducted by the teacher. (~5 minutes) responses.
Explore I Students complete the second matrix from Teacher circulates the room to
Connectivity to build ~15 the problem in their groups. (~5 min) observe/monitor students’
understanding of concepts min work.
Allow for collaboration consider Students work in groups of 2-3 to answer
heterogeneous groups teacher’s question. (~5 minutes) Teacher then poses question:
Move deliberately from concrete “How could we use these
to abstract matrices to determine the
Apply scaffolding & total inventory of books at the
personalization university?”
Explain I ~5 min Students offer their ideas on how to define Teacher conducts discussion
Personalize/Differentiate as matrix addition (and subtraction). on matrix addition and
needed subtraction.
Adjust along Students engage in class discussion on
teacher/student centered teachers’ questions. Teacher poses questions: “Is
continuum matrix addition commutative?
Provide vocabulary Is it associative? Is matrix
Clarify understandings subtraction commutative? Is
it associative? Why/why not?”
Explore II Students work in groups of 2-3 to answer Teacher then poses question:
Connectivity to build ~5 min teacher’s question. (~5 minutes) “How could we use these
understanding of concepts matrices to determine the
Allow for collaboration consider inventory of books at the
heterogeneous groups university if the librarian
Move deliberately from concrete would like to double the
to abstract inventory?”
Apply scaffolding &
personalization Once students have some
time to answer question,
teacher returns to full class
discussion to ask how we
could define scalar
multiplication..
Explain II ~5 min Students offer their ideas on how to define Teacher conducts discussion
Personalize/Differentiate as scalar multiplication. on scalar multiplication.
needed
Adjust along
teacher/student centered
continuum
Provide vocabulary
Clarify understandings
Extend ~15 Students complete class problem set in Teacher circulates the room
Apply knowledge to new min groups of 2-3 to apply their new knowledge. and observes/monitors
scenarios students’ work.
Continue to personalize as
needed
Consider grouping
homogeneously
8
Evaluate N/A Students will complete guided notes and a Teacher will review students’
Formative Assessment problem set for practice. Students turn in work as they circulate room
How will you know if students their solutions to the last problem in the and monitor progress,
understand throughout the problem set as an exit ticket (e.g., Stereo engaging students who may be
lesson? Problem) having difficulty in discussion
to probe their thinking.
A university is taking inventory of the books they carry at their two biggest bookstores.
The East Campus bookstore carries the following books:
Hardcover: Textbooks-5280; Fiction-1680; NonFiction-2320; Reference-1890
Paperback: Textbooks-1930; Fiction-2705; NonFiction-1560; Reference-2130
In order to work with this information, we can represent the inventory of each bookstore using an
organized array of numbers known as a matrix.
Definitions: A matrix is a rectangular table of entries and is used to organize data in a way that can
be used to solve problems. The following is a list of terms used to describe matrices:
• A matrix’s size (or dimension) is written by listing the number of rows “by” the number
of columns.
• The values in a matrix, A, are referred to as entries or elements. The entry in the “mth”
• If a matrix has only one row, then it is a row vector. If it has only one column, then the
• The transpose of a matrix, A, written AT, switches the rows with the columns of A and the
• Two matrices are equal if they have the same size and the same corresponding entries.
10
The inventory of the books at the East Campus bookstore can be represented with the following 2 x
4 matrix:
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘 5280 1680 2320 1890
𝐸= 2 <
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘 1930 2705 1560 2130
Similarly, the West Campus bookstore’s inventory can be represented with the following matrix:
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘 7230 2450 3100 1380
𝑊= 2 <
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘 1740 2420 1750 1170
In order to add or subtract matrices, they must first be of the same size. The result of the addition
or subtraction is a matrix of the same size as the matrices themselves, and the entries are obtained by
adding or subtracting the elements in corresponding positions.
In our campus bookstores example, we can find the total inventory between the two bookstores as
follows:
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘 12510 4130 5420 3270
= 2 <
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘 3670 5125 3310 3300
11
Scalar Multiplication
Multiplying a matrix by a constant (or scalar) is as simple as multiplying each entry by that number!
Suppose the bookstore manager in East Campus wants to double his inventory. He can find the
number of books of each type that he would need by simply multiplying the matrix E by the scalar
(or constant) 2. The result is as follows:
𝑇 𝐹 𝑁 𝑅 𝑇 𝐹 𝑁 𝑅
5280 1680 2320 1890 2(5280) 2(1680) 2(2320) 2(1890)
2𝐸 = 2 ∗ 2 <=J K
1930 2705 1560 2130 2(1930) 2(2705) 2(1560) 2(2130)
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘 10560 3360 4640 3780
= 2 <
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘 3860 5410 3120 4260
12
1 0 1 0 6 −21 5
𝐴 = L 2 −4 3M 𝐵 = [2 8 −6] 𝐶 = L2 4 −9 M 𝐷 = L−2M
−6 1 8 5 −7 1 3
Find each of the following, or explain why the operation cannot be performed:
a. 𝐴 + 𝐵: This operation cannot be performed, since matrices 𝐴 and 𝐵 are of different dimensions.
1 0 1 0 6 −21 𝟏 −𝟔 𝟐𝟐
c. 𝐴 − 𝐶 = L 2 −4 3M − L2 4 −9 M = L 𝟎 −𝟖 𝟏𝟐M
−6 1 8 5 −7 1 −𝟏𝟏 𝟖 𝟕
0 6 −21 1 0 1 −𝟏 𝟔 −𝟐𝟐
d. 𝐶 − 𝐴 = L2 4 −9 M − L 2 −4 3M = L 𝟎 𝟖 −𝟏𝟐M
5 −7 1 −6 1 8 𝟏𝟏 −𝟖 −𝟕
1 0 1 0 6 −21
f. – 𝐴 + 4𝐶 = − L 2 −4 3M + 4 ∗ L2 4 −9 M =
−6 1 8 5 −7 1
−1 0 −1 0 24 −84 −𝟏 𝟐𝟒 −𝟖𝟓
L−2 4 −3M + L 8 16 −36M = L 𝟔 𝟐𝟎 −𝟑𝟗M
6 −1 −8 20 −28 4 𝟐𝟔 −𝟐𝟗 −𝟒
g. 𝐵 – 𝐷: This operation cannot be performed, since B and D are not of the same size.
0 6 −21 1 0 1
h. 2𝐶 − 6𝐴 = 2 ∗ L2 4 −9 M − 6 ∗ L 2 −4 3M =
5 −7 1 −6 1 8
13
0 12 −42 6 0 6 −𝟔 𝟏𝟐 −𝟒𝟖
L4 8 −18M − L 12 −24 18M = L−𝟖 𝟑𝟐 −𝟑𝟔M
10 −14 2 −36 6 48 𝟒𝟔 −𝟐𝟎 −𝟒𝟔
2 5 𝟕
#
i. 𝐵 + 𝐷 = L 8 M + L−2M = L 𝟔 M
−6 3 −𝟑
14
Lesson Plan
Warm Up ~5 min Students read the opening problem (e.g., Teacher hands out a sheet of
Elicit/Engage
Build relevance through a Opera Problem or other context of interest) paper with the opening
problem from a handout and/or projected on a problem written on it and/or
screen. projects it on the screen.
Try to find out what your
students already know Teacher opens with the
Get them interested question, “How might we
organize this information in a
way that allows us to answer
the question?”
15
Explain ~15 Students follow along the teachers’ Teacher conducts lesson on
Personalize/Differentiate as
needed min explanation on their opening problem. matrix multiplication using the
Adjust along opening problem to
teacher/student centered Students share their thoughts on teacher’s demonstrate the operation.
continuum
Provide vocabulary posed questions.
Clarify understandings Teacher poses questions: “Is
matrix multiplication
commutative? Is it
associative? Why/why not?”
Teacher provides examples of
why they are/aren’t, and
students practice the
operation with those
examples.
Extend ~25 Students complete class problem set in Teacher will review students’
Apply knowledge to new
scenarios min groups of 2-3 to apply their new knowledge. work as they circulate room
Continue to personalize as and monitor progress,
needed engaging students who may be
Consider grouping
homogeneously having difficulty in discussion
to probe their thinking.
The Metropolitan Opera is planning its last cross-country tour. It plans to perform Carmen and La
Traviata in Atlanta in May. The person in charge of logistics wants to make plane reservations for the two
troupes. Carmen has 2 stars, 25 other adults, 5 children, and 5 staff members. La Traviata has 3 stars, 15
other adults, and 4 staff members. There are 3 airlines to choose from. Redwing charges round-trip fares
to Atlanta of $630 for first class, $420 for coach, and $250 for youth. Southeastern charges $650 for first
class, $350 for coach, and $275 for youth. Air Atlanta charges $700 for first class, $370 for coach, and
$150 for youth. Assume stars travel first class, other adults and staff travel coach, and children travel for
the youth fare.
Use multiplication and addition to find the total cost for each troupe to travel each of the airlines.
It turns out that we can solve problems like these using a matrix operation, specifically matrix
multiplication!
We first note that matrix multiplication is only defined for matrices of certain sizes. For the product 𝐴𝐵
of matrices 𝐴 and 𝐵, where 𝐴 is an 𝑚 𝑥 𝑛 matrix, 𝐵 must have the same number of rows as 𝐴 has
columns. So, 𝐵 must have size 𝒏 𝑥 𝑝. The product 𝐴𝐵 will have size 𝒎 𝒙 𝒑.
Exercises
The following is a set of abstract matrices (without row and column labels):
2 4 1
1 −1 6
𝑀=2 < 𝑁 = L0 −1 3M 𝑂=2 <
2 0 −1
1 0 2
0 ! 4
" 3 1
𝑃=f !g 𝑄 = L1 M 𝑅=2 <
−1 −1 0
" 3
3 1 1 4 2 6 −1
𝑆=j1 0k 𝑇=j2 k 𝑈 = L5 3 1 0M
0 2 −3
−1 1 4 0 2 −1 1
List at least 5 orders of pairs of matrices from this set for which the product is defined. State the
dimension of each product.
MO: 2x1 MP: 2x2 PM: 2x2 MR: 2x2 RM: 2x2 NQ: 3x1
We can multiply these two matrices to obtain the same answers we obtained above, all in one matrix!
Carmen/Redwing: $15110
Carmen/Southeastern: $13175
La Traviata/Redwing: $9870
La Traviata/Southeastern: $8600
Exercises
1. The K.L. Mutton Company has investments in three states - North Carolina, North Dakota, and
New Mexico. Its deposits in each state are divided among bonds, mortgages, and consumer
loans. The amount of money (in millions of dollars) invested in each category on June 1 is
displayed in the table below.
NC ND NM
Bonds 13 25 22
Mort. 6 9 4
Loans 29 17 13
The current yields on these investments are 7.5% for bonds, 11.25% for mortgages, and 6% for
consumer loans. Use matrix multiplication to find the total earnings for each state.
𝑵𝑪 𝑵𝑫 𝑵𝑴
𝑩𝒐𝒏𝒅𝒔 𝑴𝒐𝒓𝒕. 𝑳𝒐𝒂𝒏𝒔 𝑩𝒐𝒏𝒅𝒔 𝟏𝟑 𝟐𝟓 𝟐𝟐 𝑵𝑪 𝑵𝑫 𝑵𝑴
[𝟏. 𝟎𝟕𝟓 𝟏. 𝟏𝟏𝟐𝟓 𝟏. 𝟎𝟔] =[
𝑴𝒐𝒓𝒕. L𝟔 𝟗 𝟒 M 𝟑. 𝟑𝟗 𝟑. 𝟗𝟎𝟕𝟓 𝟐. 𝟖𝟖]
𝑳𝒐𝒂𝒏𝒔 𝟐𝟗 𝟏𝟕 𝟏𝟑
2. Several years ago, Ms. Allen invested in growth stocks, which she hoped would increase in value
over time. She bought 100 shares of stock A, 200 shares of stock B, and 150 shares of stock C.
At the end of each year she records the value of each stock. The table below shows the price per
share (in dollars) of stocks A, B, and C at the end of the years 1984, 1985, and 1986.
Total value of the stocks (in dollars) at the end of each year:
3. The Sound Company produces stereos. Their inventory includes four models - the Budget, the
Economy, the Executive, and the President models. The Budget needs 50 transistors, 30
capacitors, 7 connectors, and 3 dials. The Economy model needs 65 transistors, 50 capacitors, 9
connectors, and 4 dials. The Executive model needs 85 transistors, 42 capacitors, 10 connectors,
and 6 dials. The President model needs 85 transistors, 42 capacitors, 10 connectors, and 12 dials.
The daily manufacturing goal in a normal quarter is 10 Budget, 12 Economy, 11 Executive, and 7
President stereos.
a. How many transistors are needed each day? Capacitors? Connectors? Dials?
b. During August and September, production is increased by 40%. How many Budget, Economy,
Executive, and President models are produced daily during these months?
Define the matrices for the inventory parts (𝑰) and the daily manufacturing goal (𝑵) as
𝒕 𝒄𝒂 𝒄𝒐 𝒅
𝑩 𝟓𝟎 𝟑𝟎 𝟕 𝟑 𝑩 𝑬𝒄 𝑬𝒙 𝑷
𝑰 = 𝑬𝒄 𝟔𝟓 𝟓𝟎 𝟗 𝟒 k 𝒂𝒏𝒅 𝑵=[
j 𝟏𝟎 𝟏𝟐 𝟏𝟏 𝟕]
𝑬𝒙 𝟖𝟓 𝟒𝟐 𝟏𝟎 𝟔
𝑷 𝟖𝟓 𝟒𝟐 𝟏𝟎 𝟏𝟐
𝑵𝑯 = 𝟐𝟒𝟗
21
𝟐𝟒𝟗
With 7-hour workdays, the number of employees needed is 𝟕 = 𝟑𝟓. 𝟔, which implies
that 36 employees are needed to maintain full production. For August and September,
𝟏.𝟒𝑵𝑯 𝟑𝟒𝟖.𝟔
we want 𝟕 = 𝟕 , which rounds to 50.
4. The president of the Lucrative Bank is hoping for a 21% increase in checking accounts, a 35%
increase in savings accounts, and a 52% increase in market accounts. The current statistics on the
number of accounts at each branch are as follows:
What is the goal for each branch in each type of account? (HINT: multiply by a 3 × 2 matrix
with certain nonzero entries on the diagonal and zero entries elsewhere.) What will be the total
number of accounts at each branch?
The goal for each branch in each type of account is given by:
𝒄 𝒔 𝒎 𝒄 𝒔 𝒎
𝑵 𝟒𝟎𝟎𝟑𝟗 𝟏𝟎𝟏𝟑𝟓 𝟓𝟏𝟐 𝒄 𝟏. 𝟐𝟏 𝟎 𝟎
⋅ 𝒔
𝑺 L𝟏𝟓𝟐𝟑𝟏 𝟖𝟕𝟓𝟏 𝟏𝟎𝟓 M L 𝟎 𝟏. 𝟑𝟓 𝟎 M
𝑫 𝟐𝟓𝟔𝟏𝟐 𝟏𝟐𝟏𝟖𝟕 𝟗𝟕 𝒎 𝟎 𝟎 𝟏. 𝟓𝟐
𝒄 𝒔 𝒎
𝑵 𝟒𝟖𝟒𝟒𝟕 𝟏𝟑𝟔𝟖𝟐 𝟕𝟕𝟖. 𝟐𝟒
= 𝑺 L𝟏𝟖𝟒𝟑𝟎 𝟏𝟏𝟖𝟏𝟒 𝟏𝟓𝟗. 𝟔 M
𝑫 𝟑𝟎𝟗𝟗𝟏 𝟏𝟔𝟒𝟓𝟐 𝟏𝟒𝟕. 𝟒𝟒
𝟏
Right-multiplying this result by the matrix f𝟏g yields the following total number of
𝟏
𝑻𝒐𝒕𝒂𝒍
𝑵 𝟔𝟐𝟗𝟎𝟕. 𝟔𝟖
accounts at each branch: .
𝑫 L𝟑𝟎𝟒𝟎𝟐. 𝟗𝟔M
𝑺 𝟒𝟕𝟓𝟗𝟎. 𝟒𝟏
Note: this answer can also be obtained by just adding up the entries in each row of the
previous matrix.
22
Lesson Plan
(~90 minutes)
Warm Up ~10 Students work on nonogram activity in Teacher opens with a color-
Elicit/Engage
min groups of 2-3. by-number nanogram-style
Build relevance through a
problem image displayed to the class
(Activity site)
and prompts students to
Try to find out what your
students already know complete the diagram.
Get them interested (Teacher provides the
rules/process of completing a
nanogram.)
Explain Ia ~10 Students follow along the teachers’ Teacher conducts lesson on
Personalize/Differentiate as
needed min explanation. interpreting what the sum,
Adjust along difference, scalar
teacher/student centered Students then work together in groups of 2-3 multiplication and
continuum
Provide vocabulary on practice problems based on the teacher’s combinations of operations of
Clarify understandings lesson. matrices would represent in
the context of images.
Explain II ~15 Students engage in discussion as a class, Teacher debriefs the results
Personalize/Differentiate as
needed min facilitated by the teacher. They share their from the Explore session and
Adjust along results up at the board and present them to conducts class discussion on
teacher/student centered the class. results.
continuum
Provide vocabulary
Clarify understandings
Extend ~20 Students apply their new understanding to a Teacher will review students’
Apply knowledge to new
scenarios min problem set involving specific images. work as they circulate room
Continue to personalize as and monitor progress,
needed engaging students who may be
Consider grouping
homogeneously having difficulty in discussion
to probe their thinking.
In this lesson, we will discuss representations of images and methods to manipulate those images.
Matrix representations:
• A grayscale image is a 2-dimensional array of numbers. An 8-bit image has entries between 0
and 255.
• The value 255 represents a white color, and the value 0 represents a black color.
• Lower numbers translate to darker pixels, while higher numbers translate to lighter pixels.
• For an image that has 𝑚 𝑥 𝑛 pixels (i.e., “picture elements”), we represent that image using a
matrix of size 𝒎 𝒙 𝒏. The entries of the matrix indicate the pixel value of the corresponding
Example: This 4 𝑥 4 image of the raccoon is represented by the matrix on the right below:
26
Exercises:
1. Write a matrix that represents each of the following images.
a.
0 255 255
⎡255 0 255⎤
⎢ ⎥
⎢255 0 255⎥
⎢255 255 0 ⎥
⎣255 0 255⎦
b.
255 255 255 255
L 0 255 0 255M
255 255 255 0
0 255 255
0 255 255
a. „ …
255 0 0
255 255 0
0 255 255
b. L0 0 255M
0 255 255
27
255 0 0
c. 2 <
0 255 0
Color Images:
Color images can be stored in a similar fashion to a grayscale image. Instead of one number (0-255)
per pixel, one stores three numbers per pixel – these three numbers denote the “amount” of red,
“amount” of green, and “amount” of blue in each pixel. These three numbers can be used to depict
a wide range of colors.
28
Image transformations:
Once images are represented as matrices, we can describe many transformations of those images
using basic matrix operations!
Example: Suppose we have two separate images that can be represented by the matrices 𝐴 = 9255 0
@
0 255
and 𝐵 = 9 0 0
@.
255 0
/
3. Compute 𝐶 = 0 𝐴. How would you describe the image represented by 𝐶 in relation to the image
represented by 𝐴?
1 1 255 0 51 0
𝐶= 𝐴= 2 <=2 <
5 5 0 255 0 51
The image represented by the matrix 𝐶 would have pixels that are darker than those in the image represented
by matrix 𝐴.
Note: When mathematical operations on images result in entries that range outside of the integer values 0
through 255, image visualization tools treat them as 255 if the value exceeds 255, and as 0 if the value is
below 0.
29
Exercises:
1. a. Describe an image whose matrix representation contains entries of all zeros.
The image would be entirely black.
2. Let 𝐴 and 𝐵 be matrices that represent two images of the same size. Describe in words what each of the
following means.
a. 𝐴 − 𝐵
This matrix represents the image that is the result of darkening the image represented by 𝐴, if 𝐵 has at least
one nonzero entry.
b. 5𝐴 + 𝐵
This matrix represents the lightening of the image represented by 𝐴, since all of the values in 𝐴 are multiplied
by a positive number, and the entries in 𝐵 are added to those entries.
From our earlier work, we know that the image represented by the matrix 𝑋 = 9255 0
@ would
0 255
be:
2. Write the matrix that corresponds to the reflection of each of the following about the
a. 𝑥 −axis
b. 𝑦 −axis
255 255 0
255 255 0
𝑦 −axis: „ …
0 0 255
0 255 255
255 255 0
𝑦 −axis: L255 0 0M
255 255 0
255 0 0 0 255 0
c. 2 < 𝑥 −axis: 2 <
0 255 0 255 0 0
0 0 255
𝑦 −axis: 2 <
0 255 0
32
Question: From our work above, we know that the matrix representing the image reflected about
2 4
the 𝑥-axis is 2 <. What matrix would we need to multiply 𝑋 by on the left in order to obtain the
1 3
matrix of the image reflected about the 𝒙-axis? Show that your answer gives you the correct result.
0 1
2 <
1 0
0 1 1 3 2 4
2 <2 <=2 <
1 0 2 4 1 3
Question: From our work above, we know that the matrix representing the image reflected about
3 1
the 𝑦-axis is 2 <. What matrix would we need to multiply 𝑋 by on the right in order to obtain
4 2
the matrix of the image reflected about the 𝒚-axis? Show that your answer gives you the correct
result.
0 1
2 <
1 0
1 3 0 1 3 1
2 <2 <= 2 <
2 4 1 0 4 2
The matrix you used above is a form of a permutation matrix (here referred to as a reverse identity
matrix). This matrix is always square, and its size is determined by the size of the matrix it is
multiplied to (i.e. in order for the matrix multiplication to be performed).
Exercises:
1. What size does the reverse identity matrix need to be to be used to reflect an image represented
by a 5 𝑥 3 matrix about the 𝑥-axis? Why?
The matrix must be a 𝟓 𝒙 𝟓 matrix, so that it can left-multiply the 𝟓 𝒙 𝟓 matrix. The reverse
identity matrix is square, and it must have the same number of columns as the 𝟓 𝒙 𝟑 matrix
has rows.
1
Note that these values each represent a shade of color between white and black, where 0 represents black, and 1 represents white.
While we have used only values of 0 and 255 thus far, we will use these values in this example to make the reflections clear.
33
2. What size does the reverse identity matrix need to be to be used to reflect an image represented
by a 5 𝑥 3 matrix about the 𝑦-axis? Why?
The matrix must be a 𝟑 𝒙 𝟑 matrix, so that it can right-multiply the 𝟓 𝒙 𝟑 matrix. The
reverse identity matrix is square, and it must have the same number of rows as the 𝟓 𝒙 𝟑
matrix has columns.
3. Use the reverse identity matrix of the appropriate size to reflect the images represented by the
following matrices about the 𝑥-axis.
0 255 255 𝟎 𝟎 𝟏 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓
a. L0 0 255M L𝟎 𝟏 𝟎M L𝟎 𝟎 𝟐𝟓𝟓M = L𝟎 𝟎 𝟐𝟓𝟓M
0 255 255 𝟏 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓
4. Use the reverse identity matrix of the appropriate size to reflect the images represented by the
following matrices about the 𝑦-axis.
0 255 255 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟏 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎
a. L0 0 255M L𝟎 𝟎 𝟐𝟓𝟓M L𝟎 𝟏 𝟎M = L𝟐𝟓𝟓 𝟎 𝟎M
0 255 255 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟏 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎
𝟎 𝟎 𝟏
255 0 0 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓
c. 2 < 2 < L𝟎 𝟏 𝟎M = 2 <
0 255 0 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟎
𝟏 𝟎 𝟎
34
Using this method, we first convert our matrices into vectors (i.e., single column or single row
matrices).
Examples:
1
1 3 2
1. For 𝑋 = 2 <, 𝑣𝑒𝑐(𝑋) = „ ….
2 4 3
4
1
⎡2⎤
⎢3⎥
⎢ ⎥
1 4 7 ⎢4⎥
2. For 𝑋 = L2 5 8M, 𝑣𝑒𝑐(𝑋) = ⎢ 5 ⎥.
3 6 9 ⎢6⎥
⎢7⎥
⎢8⎥
⎣9⎦
35
3
5 3 6
3. For 𝑋 = „ …, 𝑚𝑎𝑡(𝑋) = 2 <.
6 5 1
1
1
⎡ 0 ⎤
⎢ 0 ⎥
⎢ ⎥
⎢ 0 ⎥ 1 0 0
4. For 𝑋 = ⎢ 1 ⎥, 𝑚𝑎𝑡(𝑋) = L0 1 0M.
⎢ 0 ⎥ 0 0 1
⎢ 0 ⎥
⎢ 0 ⎥
⎣ 1 ⎦
Exercises:
2
2 3 1
b. 𝐵 = 2 < 𝑣𝑒𝑐(𝐵) = „ ….
1 6 3
6
8
⎡7⎤
⎢8⎥
⎢ ⎥
8 8 8 ⎢8⎥
c. 𝐶 = L7 7 7M 𝑣𝑒𝑐(𝐶) = ⎢ 7 ⎥.
8 8 8 ⎢8⎥
⎢8⎥
⎢7⎥
⎣8⎦
36
8
⎡ 7⎤
⎢ 6⎥
⎢ ⎥
⎢ 5⎥ 8 5 2
b. 𝑌 = ⎢4⎥ 𝑚𝑎𝑡(𝑌) = L7 4 1M
⎢ 3⎥ 6 3 0
⎢ 2⎥
⎢ 1⎥
⎣ 0⎦
37
1
1 3 2
Consider the matrix 𝑋 = 2 <. We know that 𝑣𝑒𝑐(𝑋) = „ ….
2 4 3
4
Question: From our earlier work, we know that the reflection of the image with matrix 𝑋 about the
2
2 4 1
𝑥-axis would be 𝑌 = 2 <. So, 𝑣𝑒𝑐(𝑌) = „ …. What matrix would we need to multiply 𝑣𝑒𝑐(𝑋)
1 3 4
3
by on the left in order to obtain 𝑣𝑒𝑐(𝑌)? Show that your answer gives you the correct result.
Question: From our earlier work, we know that the reflection of the image with matrix 𝑋 about the
3
3 1 4
𝑦-axis would be 𝑌 = 2 <. So, 𝑣𝑒𝑐(𝑌) = „ …. What matrix would we need to multiply 𝑣𝑒𝑐(𝑋)
4 2 1
2
by on the right in order to obtain 𝑣𝑒𝑐(𝑌)? Show that your answer gives you the correct result.
Blurring images
We can also blur images to get an effect we’re interested in, and we use linear algebra to do it! The
image on the left below is the picture, and the image on the right is the blurred version.
One way to do this is to average each entry’s “neighbors” (including the entry itself). The definition
of these neighbors can be determined by the user themselves. For example, a neighbor could be any
entry in the matrix representation that is directly left, right, above and below the original entry, along
with the entry itself.
1 1 2
Example: Consider an image whose matrix representation is 𝑋 = L2 1 1M. Suppose we define a
3 1 2
“neighbor” as an entry that is directly above, below, next to or diagonal from that entry. For
example, the entries that are neighbors of 𝑥1/ = 3 in the matrix are 𝑥2/ = 2, 𝑥22 = 1, 𝑥12 = 1, and
23/3/31 5
𝑥1/ = 3. So the entry 𝑦1/ in the new matrix would be 4
= 4.
Challenge Question: Find the 9 𝑥 9 matrix 𝐴 such that 𝑌 = 𝐴 ∗ 𝑣𝑒𝑐(𝑋). Show that your choice
indeed results in 𝑌.
*Note: the denominator of the fractions in matrix A are determined by the number of neighbors the
element has (example: element 𝑥1/ has 4 neighbors, so in matrix A row 3 all has denominators of 4).
The numerator will always be 1. Place the appropriate fraction in the location that correlates to
where the neighbors of that element are placed in 𝑣𝑒𝑐(𝑋).
40
Lesson Plan
Teacher: Subject:
This will be a teacher led activity especially if Topic/Day: Using Python to Manipulate Photos
students are not familiar with Python. If Content Objective: Use Matrices to solve real world problems.
students have previous Python programming
experience they could try the coding on their Materials Needed: Python notebook-nothing has to be
own. downloaded but you will need to allow “colab” to run as an
extension in Google Chrome to run the program.
Warm Up ~10 Write a matrix on paper of the image of the Provide the image either on
Elicit/Engage
min math symbols. the board or a copy on paper.
Build relevance through a
problem
Try to find out what your
students already know
Get them interested
Explore Explore putting the code in Python to see Provides code and
Connectivity to build
understanding of concepts ~45 how the images are created and manipulated. scaffolding.
Allow for collaboration min (Code will be provided.)
consider heterogeneous groups
Move deliberately from
concrete to abstract
Apply scaffolding &
personalization
Explain ~30 Student should ask for help on any of the Review the algorithms for
Personalize/Differentiate as
needed min previously taught matrix operations as reflecting, rotating, blurring
Adjust along needed. and combining as needed.
teacher/student centered
continuum
Provide vocabulary
Clarify understandings
41
Lesson Plan
Standard Topic/Day: Instagram Project
NC.M4.N.2.1 Execute procedures of addition, Content Objective: Use matrices to manipulate and edit a photo to post on Instagram
Language Objective:
subtraction, multiplication, and scalar Vocabulary:
multiplication on matrices; NC.M4.N.2.2 Execute Materials Needed: Instagram Project printout, stock images printed, poster board (or other
procedures of addition, subtraction, and scalar arts and craft supplies for the students)
multiplication on vectors.
Explore
Connectivity to build understanding of Go over the outline and
concepts
Allow for collaboration consider expectations with the students
heterogeneous groups
Move deliberately from concrete to abstract ~5
Apply scaffolding & Review the Instagram project as a class
personalization mins Provide the students with the
necessary arts and craft supplies for
the project to be completed
Explain
Personalize/Differentiate as needed Walk around the class listening to
Adjust along
teacher/student centered continuum ~45 the conversations of students and
Provide vocabulary Complete the Instagram project
Clarify understandings mins facilitate conversations and answer
questions as needed
Extend
Apply knowledge to new scenarios
Continue to personalize as needed N/A
Consider grouping homogeneously N/A N/A
Evaluate
Summative-like Assessment
Questions similar to final assessment
N/A N/A N/A
44
Reflect the image over the x-axis, write the new matrix, and draw the new image:
𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓
⎡ 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎤
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓⎥
⎢ ⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 ⎥
𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 ⎥
𝑨=⎢
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢𝟐𝟓𝟓 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎣𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎦
Reflect the previous image over the y-axis, write the new matrix, and draw the new image:
𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓
⎡𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 ⎤
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓⎥
⎢ ⎥
⎢ 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓⎥
𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
𝑨=⎢
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟐𝟓𝟓⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 ⎥
⎣𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎦
45
Reflect the previous image over the 45⁰ line, write the new matrix, and draw the new image:
𝟐𝟓𝟓 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟐𝟓𝟓
⎡𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟐𝟓𝟓⎤
⎢𝟐𝟓𝟓
𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ ⎥
⎢ 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟎 ⎥
𝑨=⎢
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 ⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎣𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎦
Change the brightness of the previous image by a scalar of 1/2, write the new matrix, and draw the
new image: *Note: you will use the color gray to draw the darkened or lightened image.
𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓
⎡ 𝟎 𝟎 ⎤
⎢ 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 ⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎
𝟐𝟓𝟓 𝟐𝟓𝟓
𝟎 𝟎 𝟎
𝟐𝟓𝟓⎥
⎢ 𝟐 𝟐 𝟐 𝟐 ⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ 𝟐 𝟎 𝟎 𝟎 𝟎 𝟎
𝟐 𝟐 𝟐 𝟐 ⎥
⎢ 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ 𝟎 𝟎 𝟎 𝟎
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 ⎥
⎢ 𝟐𝟓𝟓 𝟐𝟓𝟓 ⎥
⎢ 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 ⎥
𝑨=⎢ 𝟐 𝟐 ⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 ⎥
⎢ 𝟐 ⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ 𝟐 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎
𝟐 ⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ 𝟎 𝟎 𝟎 𝟎 ⎥
⎢ 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 ⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓
𝟎 𝟎 𝟎 𝟎
𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 ⎥
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎣ 𝟐 𝟎 𝟎
𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 𝟐 ⎦
Instagram Project
v The project outline is in Appendix A
v There is an example of the Instagram Project in Appendix B
48
v Bartkovich, K. G., Goebel, J. A., Graves, J. L., Teague, D. J., Barrett, G. B., Compton, H. L.,
... & Whitehead, K. (2000). Contemporary Precalculus through Applications. New York:
Glencoe/McGraw-Hill
v 9:59
v Tan, S. (2002). Finite Mathematics for the Managerial, Life, and Social Sciences (7th ed.). Boston:
Brooks Cole.
49
Appendices
A university is taking inventory of the books they carry at their two biggest bookstores.
The East Campus bookstore carries the following books:
Hardcover: Textbooks-5280; Fiction-1680; NonFiction-2320; Reference-1890
Paperback: Textbooks-1930; Fiction-2705; NonFiction-1560; Reference-2130
In order to work with this information, we can represent the inventory of each bookstore using an
organized array of numbers known as a matrix.
Definitions: A __________ is a rectangular table of entries and is used to organize data in a way that
can be used to solve problems. The following is a list of terms used to describe matrices:
• If a matrix has only one row, then it is a row ____________. If it has only one column, then
• The __________________ of a matrix, A, written AT, switches the rows with the columns of
• Two matrices are _____________ if they have the same size and the same corresponding
entries.
51
The inventory of the books at the East Campus bookstore can be represented with the following 2 x
4 matrix:
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘
𝐸= „ …
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘
Similarly, the West Campus bookstore’s inventory can be represented with the following matrix:
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘
𝑊= „ …
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘
In order to add or subtract matrices, they must first be of the same ______________________.
The result of the addition or subtraction is a matrix of the same size as the matrices themselves, and
the entries are obtained by adding or subtracting the elements in corresponding positions.
In our campus bookstores example, we can find the total inventory between the two bookstores as
follows:
𝐸+𝑊 =„ …+„ …
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘
= „ …
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘
52
Scalar Multiplication
Multiplying a matrix by a constant (or scalar) is as simple as multiplying each entry by that number!
Suppose the bookstore manager in East Campus wants to double his inventory. He can find the
number of books of each type that he would need by simply multiplying the matrix E by the scalar
(or constant) 2. The result is as follows:
𝑇 𝐹 𝑁 𝑅
𝐻𝑎𝑟𝑑𝑏𝑎𝑐𝑘
2𝐸 = 2 ∗ „ …= „ …
𝑃𝑎𝑝𝑒𝑟𝑏𝑎𝑐𝑘
53
1 0 1 0 6 −21 5
𝐴 = L 2 −4 3M 𝐵 = [2 8 −6] 𝐶 = L2 4 −9 M 𝐷 = L−2M
−6 1 8 5 −7 1 3
Find each of the following, or explain why the operation cannot be performed:
b. 𝐴 + 𝐵 b. 𝐵 – 𝐴
𝑐. 𝐴 – 𝐶 d. 𝐶 – 𝐴
e. 5𝐵 f. −𝐴 + 4𝐶
g. 𝐵 – 𝐷 h. 2𝐶 − 6𝐴
i. 𝐵# + 𝐷
54
Matrix Multiplication
The Metropolitan Opera is planning its last cross-country tour. It plans to perform Carmen and La
Traviata in Atlanta in May. The person in charge of logistics wants to make plane reservations for the two
troupes. Carmen has 2 stars, 25 other adults, 5 children, and 5 staff members. La Traviata has 3 stars, 15
other adults, and 4 staff members. There are 3 airlines to choose from. Redwing charges round-trip fares
to Atlanta of $630 for first class, $420 for coach, and $250 for youth. Southeastern charges $650 for first
class, $350 for coach, and $275 for youth. Air Atlanta charges $700 for first class, $370 for coach, and
$150 for youth. Assume stars travel first class, other adults and staff travel coach, and children travel for
the youth fare.
Use multiplication and addition to find the total cost for each troupe to travel each of the airlines.
56
It turns out that we can solve problems like these using a matrix operation, specifically matrix
multiplication!
We first note that matrix multiplication is only defined for matrices of certain sizes. For the product 𝐴𝐵
of matrices 𝐴 and 𝐵, where 𝐴 is an 𝑚 𝑥 𝑛 matrix, 𝐵 must have the same number of rows as 𝐴 has
columns. So, 𝐵 must have size ______ 𝑥 𝑝. The product 𝐴𝐵 will have size ________________.
Exercises
The following is a set of abstract matrices (without row and column labels):
2 4 1
1 −1 6
𝑀=2 < 𝑁 = L0 −1 3M 𝑂=2 <
2 0 −1
1 0 2
0 ! 4
" 3 1
𝑃=f !g 𝑄 = L1 M 𝑅=2 <
−1 −1 0
" 3
3 1 1 4 2 6 −1
𝑆=j1 0k 𝑇=j2 k 𝑈 = L5 3 1 0M
0 2 −3
−1 1 4 0 2 −1 1
List at least 5 orders of pairs of matrices from this set for which the product is defined. State the
dimension of each product.
57
We can multiply these two matrices to obtain the same answers we obtained above, all in one matrix!
= 𝑪𝒂𝒓𝒎𝒆𝒏
„ …
𝑳𝒂 𝑻𝒓𝒂𝒗𝒊𝒂𝒕𝒂
Carmen/Redwing:
Carmen/Southeastern:
Carmen/Air Atlanta:
La Traviata/Redwing:
La Traviata/Southeastern:
La Traviata/Air Atlanta:
58
Exercises2
3. The K.L. Mutton Company has investments in three states - North Carolina, North Dakota, and
New Mexico. Its deposits in each state are divided among bonds, mortgages, and consumer
loans. The amount of money (in millions of dollars) invested in each category on June 1 is
displayed in the table below.
NC ND NM
Bonds 13 25 22
Mort. 6 9 4
Loans 29 17 13
The current yields on these investments are 7.5% for bonds, 11.25% for mortgages, and 6% for
consumer loans. Use matrix multiplication to find the total earnings for each state.
4. Several years ago, Ms. Allen invested in growth stocks, which she hoped would increase in value
over time. She bought 100 shares of stock A, 200 shares of stock B, and 150 shares of stock C.
At the end of each year she records the value of each stock. The table below shows the price per
share (in dollars) of stocks A, B, and C at the
end of the years 1984, 1984 1985 1986 1985, and 1986.
Stock A 68.00 72.00 75.00
Stock B 55.00 60.00 67.50
Stock C 82.50 84.00 87.00
Calculate the total value of Ms. Allen’s stocks at the end of each year.
2 Adapted from Bartkovich, K. G., Goebel, J. A., Graves, J. L., Teague, D. J., Barrett, G. B., Compton, H. L., ... &
Whitehead, K. (2000). Contemporary Precalculus through Applications. New York: Glencoe/McGraw-Hill
59
3. The Sound Company produces stereos. Their inventory includes four models - the Budget, the
Economy, the Executive, and the President models. The Budget needs 50 transistors, 30
capacitors, 7 connectors, and 3 dials. The Economy model needs 65 transistors, 50 capacitors, 9
connectors, and 4 dials. The Executive model needs 85 transistors, 42 capacitors, 10 connectors,
and 6 dials. The President model needs 85 transistors, 42 capacitors, 10 connectors, and 12 dials.
The daily manufacturing goal in a normal quarter is 10 Budget, 12 Economy, 11 Executive, and 7
President stereos.
a. How many transistors are needed each day? Capacitors? Connectors? Dials?
b. During August and September, production is increased by 40%. How many Budget, Economy,
Executive, and President models are produced daily during these months?
4. The president of the Lucrative Bank is hoping for a 21% increase in checking accounts, a 35%
increase in savings accounts, and a 52% increase in market accounts. The current statistics on the
number of accounts at each branch are as follows:
What is the goal for each branch in each type of account? (HINT: multiply by a 3 × 2 matrix
with certain nonzero entries on the diagonal and zero entries elsewhere.) What will be the total
number of accounts at each branch?
61
In this lesson, we will discuss representations of images and methods to manipulate those images.
Matrix representations:
• A grayscale image is a 2-dimensional array of numbers. An 8-bit image has entries between
• The value ______ represents a white color, and the value ______ represents a black color.
_____________ pixels.
• For an image that has 𝑚 𝑥 𝑛 pixels (i.e., “picture elements”), we represent that image using a
matrix of size _____________. The entries of the matrix indicate the pixel value of the
! "
Exercises:
1. Write a matrix that represents each of the following images.
c.
d.
0 255 255
0 255 255
d. „ …
255 0 0
255 255 0
0 255 255
e. L0 0 255M
0 255 255
255 0 0
f. 2 <
0 255 0
64
Color Images:
Color images can be stored in a similar fashion to a grayscale image. Instead of one number (0-255)
per pixel, one stores three numbers per pixel – these three numbers denote the “amount” of red,
“amount” of green, and “amount” of blue in each pixel. These three numbers can be used to depict
a wide range of colors.
Image transformations:
Once images are represented as matrices, we can describe many transformations of those images
using basic matrix operations!
Example: Suppose we have two separate images that can be represented by the matrices 𝐴 = 9255 0
@
0 255
and 𝐵 = 9 0 0
@.
255 0
/
6. Compute 𝐶 = 0 𝐴. How would you describe the image represented by 𝐶 in relation to the image
represented by 𝐴?
65
Note: When mathematical operations on images result in entries that range outside of the integer values 0
through 255, image visualization tools treat them as 255 if the value exceeds 255, and as 0 if the value is
below 0.
Exercises:
2. a. Describe an image whose matrix representation contains entries of all zeros.
3. Let 𝐴 and 𝐵 be matrices that represent two images of the same size. Describe in words what each
of the following means.
a. 𝐴 − 𝐵 b. 5𝐴 + 𝐵
From our earlier work, we know that the image represented by the matrix 𝑋 = 9255 0
@ would
0 255
be:
2. Write the matrix that corresponds to the reflection of each of the following about the
c. 𝑥 − axis
d. 𝑦 − axis
0 255 255
0 255 255
0 255 255 255 0 0
b. „ … b. L0 0 255M c. 2 <
255 0 0 0 255 0
0 255 255
255 255 0
Question: From our work above, we know that the matrix representing the image reflected about
the 𝑥-axis is ! ". What matrix would we need to multiply 𝑋 by on the left in order to
obtain the matrix of the image reflected about the 𝒙-axis? Show that your answer gives you the
correct result.
3
(Note that these values each represent a shade of color between white and black, where 0 represents black, and 1 represents white.
While we have used only values of 0 and 255 thus far, we will use these values in this example to make the reflections clear.)
2
Question: From our work above, we know that the matrix representing the image reflected about
the 𝑦-axis is ! ". What matrix would we need to multiply 𝑋 by on the right in order to
obtain the matrix of the image reflected about the 𝒚-axis? Show that your answer gives you the
correct result.
The matrix you used above is a form of a __________________________ matrix (here referred to
as a reverse identity matrix). This matrix is always _____________, and its size is determined by the
size of the matrix it is multiplied to (i.e. in order for the matrix multiplication to be performed).
Exercises:
5. What size does the reverse identity matrix need to be to be used to reflect an image represented
by a 5 𝑥 3 matrix about the 𝑥-axis? Why?
6. What size does the reverse identity matrix need to be to be used to reflect an image represented
by a 5 𝑥 3 matrix about the 𝑦-axis? Why?
3
7. Use the reverse identity matrix of the appropriate size to reflect the images represented by the
following matrices about the 𝑥-axis.
0 255 255
a. L0 0 255M
0 255 255
0 255 255
0 255 255
b. „ …
255 0 0
255 255 0
255 0 0
c. 2 <
0 255 0
8. Use the reverse identity matrix of the appropriate size to reflect the images represented by the
following matrices about the 𝑦-axis.
0 255 255
a. L0 0 255M
0 255 255
0 255 255
0 255 255
b. „ …
255 0 0
255 255 0
255 0 0
c. 2 <
0 255 0
4
Using this method, we first convert our matrices into vectors (i.e., single column or single row
matrices).
Examples:
1 3
5. For 𝑋 = 2 <, 𝑣𝑒𝑐(𝑋) = „ ….
2 4
5
⎡ ⎤
⎢ ⎥
⎢ ⎥
1 4 7 ⎢ ⎥
6. For 𝑋 = L2 5 8M, 𝑣𝑒𝑐(𝑋) = ⎢ ⎥.
3 6 9 ⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
3
5
7. For 𝑋 = „ …, 𝑚𝑎𝑡(𝑋) = 2 <.
6
1
1
⎡ 0 ⎤
⎢ 0 ⎥
⎢ ⎥
⎢ 0 ⎥
8. For 𝑋 = ⎢ 1 ⎥, 𝑚𝑎𝑡(𝑋) = L M.
⎢ 0 ⎥
⎢ 0 ⎥
⎢ 0 ⎥
⎣ 1 ⎦
Exercises:
5 0
a. 𝐴 = 2 < 𝑣𝑒𝑐(𝐴) = „ ….
3 4
2 3
b. 𝐵 = 2 < 𝑣𝑒𝑐(𝐵) = „ ….
1 6
6
⎡ ⎤
⎢ ⎥
⎢ ⎥
8 8 8 ⎢ ⎥
c. 𝐶 = L7 7 7M 𝑣𝑒𝑐(𝐶) = ⎢ ⎥.
8 8 8 ⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
8
⎡7 ⎤
⎢6 ⎥
⎢ ⎥
⎢5 ⎥
b. 𝑌 = ⎢ 4 ⎥ 𝑚𝑎𝑡(𝑌) = L M
⎢3 ⎥
⎢2 ⎥
⎢1 ⎥
⎣0 ⎦
7
1
1 3 2
Consider the matrix 𝑋 = 2 <. We know that 𝑣𝑒𝑐(𝑋) = „ ….
2 4 3
4
Question: From our earlier work, we know that the reflection of the image with matrix 𝑋 about the
2 4
𝑥-axis would be 𝑌 = 2 <. So, 𝑣𝑒𝑐(𝑌) = „ …. What matrix would we need to multiply
1 3
𝑣𝑒𝑐(𝑋) by on the left in order to obtain 𝑣𝑒𝑐(𝑌)? Show that your answer gives you the correct
result.
Question: From our earlier work, we know that the reflection of the image with matrix 𝑋 about the
3 1
𝑦-axis would be 𝑌 = 2 <. So, 𝑣𝑒𝑐(𝑌) = „ …. What matrix would we need to multiply
4 2
𝑣𝑒𝑐(𝑋) by on the right in order to obtain 𝑣𝑒𝑐(𝑌)? Show that your answer gives you the correct
result.
8
Blurring images
We can also blur images to get an effect we’re interested in, and we use linear algebra to do it! The
image on the left below is the picture, and the image on the right is the blurred version.
One way to do this is to average each entry’s “neighbors” (including the entry itself). The definition
of these neighbors can be determined by the user themselves. For example, a neighbor could be any
entry in the matrix representation that is directly left, right, above and below the original entry, along
with the entry itself.
1 1 2
Example: Consider an image whose matrix representation is 𝑋 = L2 1 1M. Suppose we define a
3 1 2
“neighbor” as an entry that is directly above, below, next to or diagonal from that entry. For
example, the entries that are neighbors of 𝑥1/ = 3 in the matrix are 𝑥2/ = 2, 𝑥22 = 1, 𝑥12 = 1, and
23/3/31 5
𝑥1/ = 3. So the entry 𝑦1/ in the new matrix would be 4
= 4.
⎡ ⎤
⎢ ⎥
This gives us 𝑌 = ⎢
⎢
⎥
⎥
.
⎢ ⎥
⎣7/4 ⎦
Challenge Question: Find the 9 𝑥 9 matrix 𝐴 such that 𝑌 = 𝐴 ∗ 𝑣𝑒𝑐(𝑋). Show that your choice
indeed results in 𝑌.
9
⎡ ⎤
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
𝑨=⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
Reflect the image over the x-axis, write the new matrix, and draw the new image:
⎡ ⎤
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
𝑨=⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
Reflect the previous image over the y-axis, write the new matrix, and draw the new image:
⎡ ⎤
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
𝑨=⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
11
Reflect the previous image over the 45⁰ line, write the new matrix, and draw the new image:
⎡ ⎤
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
𝑨=⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
Change the brightness of the previous image by a scalar of 1/2, write the new matrix, and draw the
new image:
*Note: you will use the color gray to draw the darkened or lightened image.
⎡ ⎤
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
𝑨=⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
Blur the original image and write the new matrix (you do not need to draw the new image):
⎡ ⎤
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
𝑨=⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ ⎥
⎣ ⎦
12
Project
This Photo by Unknown Author is
licensed under CC BY-SA
This Photo by Unknown Author is licensed under CC BY-SA
You are going to edit your given image to be Instagram ready! You will need to use a combination of
reflections, blurs, and brightness changes to post this image and get LOTS of likes and comments.
Step 1:
● Come up with an Instagram handle (Note: all Instagram handles must be school appropriate and
approved by the teacher before you can choose your image for step 2)
Step 2:
● Choose an image from your teacher to utilize throughout this project. First come first serve, so be
sure to pick your image quick!
Step 3:
● As a group, decide what types of reflections, inversions, and brightness changes you would like to
complete to post your picture. You MUST use one of each type of edit!
Step 4:
● Create matrices and a new image for each edit that you complete. You will need to turn this into your
teacher at the end of the project.
Step 5:
● Once your edits are complete, you must come up with a perfect caption for this photo (Note: all
captions must be school appropriate).
o Remember, the better the caption, the more likely you are to receive more likes and
comments!
Step 6:
● Post your final image to the classroom Instagram feed on the wall and turn in all other materials and
work to your teacher.
o All other materials and work must be turned in in an organized manner with the names of
each group member on them.
14
Grading Rubric:
Potential Actual Points
What the teacher is looking for:
Points Earned Earned
Total Points: 15
15
* *
** **
** **
17
** **
** ***
*** ***
Original Image:
𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓
⎡ 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎤
⎢𝟐𝟓𝟓
𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎢ ⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓⎥
𝑨=⎢
⎢𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 ⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 ⎥
⎢𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟎 𝟎 𝟎 𝟎 𝟎 𝟐𝟓𝟓⎥
⎢ 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎥
⎣𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟎 𝟎 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓 𝟐𝟓𝟓⎦