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.
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.
|NGSS Performance Expectation
HS-ETS1-4. 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)
Do you agree with this alignment?
|Click to view other curriculum aligned to this Performance Expectation
|This lesson focuses on the following Three Dimensional Learning aspects of NGSS:
|Science & Engineering Practices
|Disciplinary Core Ideas
|Use mathematical models and/or computer simulations to predict the effects of a design solution on systems and/or the interactions between systems.
|Both physical models and computers can be used in various ways to aid in the engineering design process. Computers are useful for a variety of purposes, such as running simulations to test different ways of solving a problem or to see which one is most efficient or economical; and in making a persuasive presentation to a client about how a given design will meet his or her needs.
|Models (e.g., physical, mathematical, computer models) can be used to simulate systems and interactions—including energy, matter, and information flows—within and between systems at different scales.
Use computers and calculators to access, retrieve, organize, process, maintain, interpret, and evaluate data and information in order to communicate.
Do you agree with this alignment?
Use various approaches to communicate processes and procedures for using, maintaining, and assessing technological products and systems.
Do you agree with this alignment?
Worksheets and AttachmentsVisit [ ] to print or download.
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. Following the lesson, students can complete the associated activity Putting It All Together: Programming Robotics Peripheral Vision.
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.
- Putting It All Together: Programming Robotics 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.
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.
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: Programming Robotics Peripheral Vision.
SubscribeGet the inside scoop on all things TeachEngineering such as new site features, curriculum updates, video releases, and more by signing up for our newsletter!
More Curriculum Like This
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 ...
"Array." Dictonary.com. Unabridged. Random House, Inc. Accessed 22 Jun. 2010. http://dictionary.reference.com/browse/Array
Copyright© 2013 by Regents of the University of Colorado; original © 2010 Vanderbilt University
ContributorsMark Gonyea; Anna Goncharova; Rachelle Klinger
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: June 14, 2019