Lesson 8: Modifying Images
45 minutes
Overview
How can I modify standard algorithms to create image filters?
Students practice working with 2D arrays and modifying standard algorithms to create new image filters using The Theater. Students explore an example of a new image filter and then write pseudocode to create a grayscale image filter. Students implement their algorithm in Java and create additional image filters by modifying Pixel
objects stored in a 2D array.
Agenda
Objectives
Students will be able to:
- Modify standard algorithms to perform manipulations on 2D arrays of objects
Preparation
- Print copies of the Grayscale Image handout (one for each pair of students)
- Create code review groups if you are not reusing the same groups
- Check the Teacher's Lounge for verified teachers on the CSA Forum to find additional strategies or resources shared by fellow teachers
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the students
- Grayscale Images - Handout
- U5L8 Extra Practice - Handout
Teaching Guide
Warm Up (10 minutes)
CS Pyramid
Remarks
We have learned a lot of new terms so far! Let's review some of these terms through a game of CS Pyramid.
Group: Place students in pairs.
Do This: Review the instructions for playing CS Pyramid.
Do This: Play the music clip to cue the CS Pyramid activity, and direct students to play CS Pyramid. Click through the animated slide to display each pyramid, and direct students to switch roles with each new pyramid.
Activity (30 minutes)
Planning the Algorithm (15 minutes)
Remarks
In the previous lesson, we learned how to manipulate pixels in an image to create some image filters. Let's explore some additional ways we can manipulate pixels and create more image filters.
Do This: Review the lesson objectives.
Do This: Direct students to Level 1 on Code Studio to investigate the program with a partner. Students make the changes to the program as prompted.
Discuss: Click through the animated slide to display the prompts.
- What do you notice about the code in this program?
- What do you wonder about the code in this program?
Discussion Goal: Students notice that the color of each pixel is modified by calculating new values for the red, green, and blue values. Students may wonder about other ways they can manipulate colors or make connections to image filters they might have seen in other apps and programs.
Do This: Click through the animated slide to explain how grayscale images are created.
Group: Place students in pairs.
Distribute: Give each pair a copy of the Grayscale Images handout.
Do This: Have students write pseudocode for an algorithm to create a grayscale image.
Remind students about how they implemented standard algorithms to find the average of values in a 1D array. Ask students to consider how this algorithm would be modified to create the grayscale effect.
Do This: Have students compare their algorithms with another group and make revisions as needed.
Creating Image Filters (15 minutes)
Remarks
Let's implement our algorithms to create our grayscale image filter! We can also use and modify other standard algorithms to create additional image filters and effects.
Do This: Direct students to Level 2 on Code Studio to complete Levels 2, 3, and 4. Students complete a Check for Understanding, then continue to Level 3 to implement their algorithm. On Level 4, students complete a choice level to create an image filter.
Do This: Click through the animated slide to have students participate in the Code Review Call and Response.
Do This: Direct students to complete a code review on Level 5.
Wrap Up (5 minutes)
Software Engineering Skills
Remarks
You have made a lot of progress in developing your software engineering skills. We have seen how these skills are useful to solve a variety of problems and create programs like what we have used in our daily lives.
Discuss: Click through the animated slide to display the prompts.
- How has your perception of software engineering changed in this unit?
- How have your software engineering skills improved in this unit?
Discussion Goal: Students share how their perception of software engineering has changed, including how computer science influences different industries and decisions. Students identify the software engineering skills and characteristics they feel they improved in this unit.
Do This: Review the concepts covered in this lesson.
Assessment: Check for Understanding
Check For Understanding Question(s) and solutions can be found in each lesson on Code Studio. These questions can be used for an exit ticket.
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.