SummaryDuring this lesson, students start to see the data structure they will use to store their images, towards finding a solution to this unit's Grand Challenge. Students are introduced to two-dimensional arrays and vector classes. Then they are guided to see that a vector class is the most efficient way of storing the data for their images. Grand Challenge: To write a program to simulate peripheral vision by merging two images.
Data of all kinds is often stored in arrays to make it easier to work with on a large scale. Arrays are often used in computer programming as a way to store and manipulate data. An example of this data could be the pixels in a two-dimensional image, which is the focus of this lesson. Computer science engineers also know that arrays also make it easier to retrieve stored data.
After this lesson, students should be able to:
- Initialize a two-dimensional array.
- Initialize a new instance of a vector class.
- Store RGB values in a vector.
- Read data from vector and write to a new image.
- Apply new knowledge to the unit's Grand Challenge question.
Tennessee State Standards for C++ Programming Applications (2005)
- Standard 5.0 - The student will write and document an executable program in C++ Programming Language.
More Curriculum Like This
As a part of the research and revise step of the Legacy Cycle, this lesson provides students with information they will need later on to be able to average pixels to simulate blurring in the peripheral plane of vision. Students learn why image color becomes important as we distort the outer boundari...
In this culminating activity of the unit, students bring together everything they've learned in order to write the code to solve the Grand Challenge. The code solution takes two images captured by robots and combines them to create an image that can be focused at different distances, similar to the ...
Students learn about nondestructive testing, the use of the finite element method (systems of equations) and real-world impacts, and then conduct mini-activities to apply Maxwell’s equations, generate currents, create magnetic fields and solve a system of equations. They see the value of NDE and FEM...
After a demonstration of the deflection of an electron beam, students review their knowledge of the cross-product and the right-hand rule with example problems. Students apply these concepts to understand the magnetic force on a current carrying wire. Through the associated activity, students furthe...
Each TeachEngineering lesson or activity is correlated to one or more K-12 science,
technology, engineering or math (STEM) educational standards.
All 100,000+ K-12 STEM standards covered in TeachEngineering are collected, maintained and packaged by the Achievement Standards Network (ASN),
a project of D2L (www.achievementstandards.org).
In the ASN, standards are hierarchically structured: first by source; e.g., by state; within source by type; e.g., science or mathematics;
within type by subtype, then by grade, etc.
Each TeachEngineering lesson or activity is correlated to one or more K-12 science, technology, engineering or math (STEM) educational standards.
All 100,000+ K-12 STEM standards covered in TeachEngineering are collected, maintained and packaged by the Achievement Standards Network (ASN), a project of D2L (www.achievementstandards.org).
In the ASN, standards are hierarchically structured: first by source; e.g., by state; within source by type; e.g., science or mathematics; within type by subtype, then by grade, etc.
- Use a computer simulation to model the impact of proposed solutions to a complex real-world problem with numerous criteria and constraints on interactions within and between systems relevant to the problem. (Grades 9 - 12) Details... View more aligned curriculum... Do you agree with this alignment? Thanks for your feedback!
In this lesson, you will learn how a computer image is composed. You will need to understand that a digital image is nothing more than a grid of colors. The grid can easily be stored and manipulated by using nested loops.
Lesson Background and Concepts for Teachers
- Two-dimensional arrays are used to store data. Each data point is identified by its horizontal and vertical position in the array. Think of the data as being stored in a grid.
- This address system is similar to the way points on a graph are addressed on an x-y plane, that is, the coordinate points (1, 2) would be one unit from the origin along the x-axis, and 2 units from the origin along the y-axis.
- Similarly, in an array, two subscripts are given, the first standing for the row number, the second representing the column number. By convention, rows and columns are both numbered from 0. Figure 1 shows an example 4 x 3 array and the subscripts representing each point within the array. (Note, the [a][b] notation is unique to C, most other languages refer to the same address as [a,b]).
- The following website explains the use of arrays in computer programming in more detail and gives example coding: http://www.fredosaurus.com/notes-cpp/stl-containers/vector/header-vector.html
- Two ways to pass a pointer to a two dimensional array: subscript notation and typecasting.
- Subscript notation requires that data type of the second subscript needs to match based on the function.
- Typecasting in the function call uses a pointer with offsets inside the function so that information in arrays of differing dimensions can be processed using the same function.
- A vector template class allows for a dynamic array, which can be expanded to account for input of different amounts of information.
array: A block of related data elements, each of which is identified by one or more subscripts.
subscript: Coordinate giving location in a single dimension in an array. Two subscripts together create an address of an element in a two-dimensional array.
- Putting It All Together: Peripheral Vision - In the concluding activity of the unit, students write the code to solve the Grand Challenge. The solution takes two images captured by robots and combines them to create an image that can be focused at different distances, mirroring human vision.
As homework, have students complete the Data Storage Assignment Handout, which asks them to read data from a 16 x 16 image grid and store the data in an array. Then they are challenged to see if they can flip the image around by using nested loops. Assess their learning by their completion of the 16 x16 grid manipulation code and answers to the handout questions. Then proceed to conduct the associated activity, Putting It All Together: Peripheral Vision.
"Array." Dictonary.com. Unabridged. Random House, Inc. Accessed 22 Jun. 2010. http://dictionary.reference.com/browse/Array
ContributorsMark Gonyea; Anna Goncharova; Rachelle Klinger
Copyright© 2013 by Regents of the University of Colorado; original © 2010 Vanderbilt University
Supporting ProgramVU Bioengineering RET Program, School of Engineering, Vanderbilt University
The contents of this digital library curriculum were developed under National Science Foundation RET grant nos. 0338092 and 0742871. However, these contents do not necessarily represent the policies of the NSF, and you should not assume endorsement by the federal government.
Last modified: September 7, 2017