Teaching Programming to Everyone through Media Computation Mark Guzdial College of Computing/GVU Georgia Institute of Technology.

Slides:



Advertisements
Similar presentations
Providing a Context to Motivate Non- Majors Into Computing Mark Guzdial College of Computing/GVU Georgia Institute of Technology.
Advertisements

Sound, Part 2 Using range to manipulate samples by index number.
Tracking an Innovation in Introductory CS Education from a Research University to a Two-Year College Allison Elliott Tew and Mark Guzdial Georgia Institute.
1 CS 177 Week 6 Recitation Slides Scaling Drawing on images Vector-based Vs. Bitmap graphical representation.
Copying and Transforming Pictures. First, finding the min or max… Next homework asks you to write a function to find the darkest and lightest shade of.
Computing with Digital Media: A Study of Humans and Technology Mark Guzdial, School of Interactive Computing.
Computer Science Curricula Computer Science Major Computer Systems Concentration (CSC) Software Engineering Concentration (SEC) –New for Fall 2005.
Picture Color Manipulation. Using a Loop Our first picture recipe def decreaseRed(picture): for p in getPixels(picture): value=getRed(p) setRed(p,value*0.5)
Introduction to Media Computation: Inventing a new approach to computing education at Georgia Tech Mark Guzdial Associate Professor College of Computing/GVU.
CS 0.5: A Better Approach to Introductory Computer Science for Majors Bob Sloan, Pat Troy University of Illinois at Chicago SIGCSE 2008.
CS 101: Introduction to Computing Programming picture manipulations Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by.
Constructing Media as a Context for Teaching Computing and Motivating Women and Non-Majors: Inventing a new approach to computing education at Georgia.
Georgia Tech’s Three CS1’s CS1321: Introduction to Computing Based on How to Design Programs and the TeachScheme Project Was the only CS1 course, on a.
Media Computing Instructor Byung Kim Olsen 231 Office hours – MWF 9:00-10:00 AM or by appointment.
Towards Collaborative Dynabooks In Alan Kay’s vision, the computer’s greatest purpose is to facilitate learning through creation and exploration of multimedia.
02-RangesInPictures1 Barb Ericson Georgia Institute of Technology Oct 2010 Working with ranges in pictures.
Contrasting Women’s Experience in CS at Different Institutions Mark Guzdial College of Computing/GVU Georgia Tech Our Goal: Ubiquitous Computing Education.
A CS1 Course Designed to Address Interests of Women Lauren Rich¹*, Heather Perry, and Mark Guzdial* College of Computing/GVU Georgia Tech *Presenting¹Now,
CS1315: Introduction to Media Computation Referencing pixels directly by index number.
CS2984: Introduction to Media Computation Using Loops for Pictures Conditionals Copying images.
“Introduction to Media Computation” A New Core Area B Course Mark Guzdial, 18 July 2002.
CS1315: Introduction to Media Computation Making sense of functions.
Georgia Institute of Technology Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Sept 2005.
Constructing Media as a Context for Teaching Computing and Motivating Women and Non-Majors: Inventing a new approach to computing education at Georgia.
Program Design and Debugging. How do programmers start? How do you get started with a program? “Programming is all about debugging a blank piece of paper.”
1 CS 177 Week 5 Recitation Slides Mirroring and copying images, Using for Loop, if statement, and range.
Making and Manipulating Media for Learning Mark Guzdial College of Computing/GVU Georgia Institute of Technology.
Chapter 4: Modifying Pixels in a Range (partial slide deck)
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 4: Modifying Pixels in a Range.
CS1315: Introduction to Media Computation How to design and debug a program: Top-down, bottom-up, and debugging. Using background subtraction and chromakey.
Design Process for a Non- Majors Computing Course Mark Guzdial & Andrea Forte College of Computing/GVU Georgia Institute of Technology With thanks for.
CS 101: Introduction to Computing Color replacements and targeted color replacement (if statement) Developed by Mark Guzdial, Georgia Institute of Technology,
Constructing Media as a Context for Teaching Computing and Motivating Women and Non-Majors: Inventing a new approach to computing education at Georgia.
Great Principles of Computing: Computing for Everyone Mark Guzdial College of Computing/GVU Georgia Institute of Technology.
CS 102 Computers In Context (Multimedia)‏ 03 / 30 / 2009 Instructor: Michael Eckmann.
Introduction to Media Computation: Inventing a new approach to computing education at Georgia Tech Mark Guzdial Associate Professor College of Computing/GVU.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 6: Modifying Sounds Using Loops.
CS1315: Introduction to Media Computation Color replacements and targeted color replacement (IF)
ACM SIGCSE 2003: Multimedia Construction Projects Mark Guzdial College of Computing Georgia Institute of Technology
Movies Barb Ericson Georgia Tech.
Intro-Sound-part1 Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Oct 2009.
“But it looks right”: Bugs in non-majors media programs Mark Guzdial College of Computing/GVU Georgia Institute of Technology.
CS1315: Introduction to Media Computation Using Loops for Pictures.
A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Changing colors in an area Part 3: Chromakey.
CS 0.5 A New Approach to Introductory Computer Science for Majors Supported by NSF Grant DUE
A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Advanced Image Manipulations, e.g., changing.
CS1315 Introduction to Media Computation Introduction: Why study computer science at all?!?
CS 101: Introduction to Computing Programs that change Pictures Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by Robert.
Examples from Georgia Tech’s CS 1315: Introduction to Media Computation Class examples and student work.
Media Computation: Introducing Computing Contextualized in Video and Audio Processing Mark Guzdial and Barbara Ericson.
1 CS 177 Week 8 Recitation Slides JES Sound functions and Modifying Sounds Increasing/Decreasing Volume Maximizing (Normalizing) Splicing Reversing Mirroring.
Session 18 The physics of sound and the manipulation of digital sounds.
CS1315: Introduction to Media Computation Transforming pictures by index number.
1 CS 177 Week 7 Recitation Slides Modifying Sounds using Loops + Discussion of some Exam Questions.
CS1315: Introduction to Media Computation Introduction to Course & Administrivia.
Media computation as a context for learning computing Mark Guzdial College of Computing/GVU Georgia Institute of Technology.
Introduction to Media Computation: A new CS1 approach that addresses women’s interests Mark Guzdial College of Computing/GVU Georgia Institute of Technology.
Working with Sounds Barb Ericson College of Computing Georgia Institute of Technology
Chapter 8: Making Sounds by Combining Pieces
Media as a Context for Learning Computation
Media as a Context for Learning Computation
CS1315: Introduction to Media Computation
CS1315 Introduction to Media Computation
Media as a Context for Learning Computation
A Media Computation Cookbook
CS 177 Week 9 Recitation Slides
CS1315: Introduction to Media Computation
CS1315: Introduction to Media Computation
CS1315: Introduction to Media Computation
Presentation transcript:

Teaching Programming to Everyone through Media Computation Mark Guzdial College of Computing/GVU Georgia Institute of Technology

Story Perlis’ challenge: Computer science is more important than calculus Evidence that we’re not there yet  And what the solution might look like Our attempt: Introduction to Media Computation  Potential tie to mathematics classes Results so-far

Computer science is more important than Calculus In 1961, Alan Perlis argued that computer science is more important in a liberal education than calculus  Explicitly, he argued that all students should learn to program. Calculus is about rates, and that’s important to many. Computer science is about process, which is important to everyone

How close are we to being able to teach everyone CS? Not very  CS1 is one of the most despised courses for non-majors At many departments, CS retention rates are lower than the rest of campus  At Georgia Tech: 65% for 1995 cohort, vs. 73% for Engineeering Drop-out rates near 50% at many institutions Female enrollment in CS has been dropping nationally

Why? Several recent studies and books claim that CS instruction tends to dissuade anyone but white males  “Tedious,” “taught without application relevance,” “boring,” “lacking creativity,” “asocial”

The best uses for computing technologies will come from others Thomas Edison vs. D.W. Griffith  Suggestion: D.W. Griffith knew things that Edison didn’t.  Consider George Lucas today If we want computing technologies to become useful, they have to get out of our hands. It can’t be just through applications. Computer science will never have the potential that it might, if future practitioners hate our introductory course!

The Challenges We need to motivate CS, potential CS, and non-CS students to care about computing We need to make it social, creative, relevant, exciting, and not tedious  Which is how many of us already see Computing, but that’s not getting communicated

Our Attempt: Introduction to Media Computation A course for non-CS and non-Engineering majors  International Affairs, Literature, Public Policy, Architecture, Management, Biology, etc. 120 students this semester, planning in the Fall  2/3 female in this semester’s CS1315 Focus: Learning programming within the context of media manipulation and creation

Motivating the Computing As professionals, these students will often the use the computer as a communications medium. All media are going digital, and digital media are manipulated with software. Knowing how to program, then, is a communications skill.

Programming as a Communications Skill Knowing how to program means to understand one’s tools.  Maybe means can transfer tool skills more easily  Students tell us that they’re excited to learn how PhotoShop works. And it means that, if you have to, you may be able to grow your own

Python as the programming language Huge and contentious issue Use in commercial contexts legitimizes the choice  Industrial Light & Magic, Google, Nextel, etc. Minimal syntax Looks like other programming languages  Potential for knowledge transfer Actually using Jython ( for Java class librarieshttp://

def negative(picture): for px in getPixels(picture): red=getRed(px) green=getGreen(px) blue=getBlue(px) negColor=makeColor(255-red,255-green,255-blue) setColor(px,negColor) def clearRed(picture): for pixel in getPixels(picture): setRed(pixel,0) def greyscale(picture): for p in getPixels(picture): redness=getRed(p) greenness=getGreen(p) blueness=getBlue(p) luminance=(redness+blueness+greenness)/3 setColor(p, makeColor(luminance,luminance,luminance))

def chromakey(source,bg): for x in range(1,getWidth(source)): for y in range(1,getHeight(source)): p = getPixel(source,x,y) # My definition of blue: If the redness + greenness < blueness if (getRed(p) + getGreen(p) < getBlue(p)): #Then, grab the color at the same spot from the new background setColor(p,getColor(getPixel(bg,x,y))) return source

Use a loop! Our first picture recipe def decreaseRed(picture): for p in getPixels(picture): value=getRed(p) setRed(p,value*0.5) Used like this: >>> file="/Users/guzdial/mediasources/barbara.jpg" >>> picture=makePicture(file) >>> show(picture) >>> decreaseRed(picture) >>> repaint(picture) original

Recipe to Increase the Volume def increaseVolume(sound): for sample in getSamples(sound): value = getSample(sample) setSample(sample,value * 2) Using it: >>> f="/Users/guzdial/mediasources/gettysburg10.wav" >>> s=makeSound(f) >>> increaseVolume(s) >>> play(s) >>> writeSoundTo(s,"/Users/guzdial/mediasources/louder-g10.wav")

A Sunset-generating function How do we turn this beach scene into a sunset? What happens at sunset?  Tried increasing the red, but that failed. New Theory: As the sun sets, less blue and green is visible, which makes things look more red.

A Sunset-generation Function def makeSunset(picture): for p in getPixels(picture): value=getBlue(p) setBlue(p,value*0.7) value=getGreen(p) setGreen(p,value*0.7)

SlowSunset def slowsunset(directory): canvas = makePicture(getMediaPath("beach-smaller.jpg")) #outside the loop! for frame in range(0,100): #99 frames printNow("Frame number: "+str(frame)) makeSunset(canvas) # Now, write out the frame writeFrame(frame,directory,canvas) def makeSunset(picture): for p in getPixels(picture): value=getBlue(p) setBlue(p,value*0.99) #Just 1% decrease! value=getGreen(p) setGreen(p,value*0.99) Not showing you writeFrame() because you know how that works. Just one canvas repeatedly being manipulated

SlowSunset frames

Introducing IF: Making Barb a redhead def turnRed(): brown = makeColor(57,16,8) file = r"C:\Documents and Settings\Mark Guzdial\My Documents\mediasources\barbara.jpg" picture=makePicture(file) for px in getPixels(picture): color = getColor(px) if distance(color,brown)<50.0: redness=getRed(px)*1.5 setRed(px,redness) show(picture) return(picture) Original:

Generalizing Algorithms We talk about algorithm complexity later in the course, after the media is done. We talk about different approaches to the same problem, where the criteria might be aesthetics or correctness, instead of speed or size  For example, generating greyscale During the media, we point out similar themes in different functions.  We refer to them as “sub-recipes”

Scaling the picture down def copyBarbsFaceSmaller(): # Set up the source and target pictures barbf=getMediaPath("barbara.jpg") barb = makePicture(barbf) canvasf = getMediaPath("7inX95in.jpg") canvas = makePicture(canvasf) # Now, do the actual copying sourceX = 45 for targetX in range(100,100+((200-45)/2)): sourceY = 25 for targetY in range(100,100+((200-25)/2)): color = getColor(getPixel(barb,sourceX,sourceY)) setColor(getPixel(canvas,targetX,targetY), color) sourceY = sourceY + 2 sourceX = sourceX + 2 show(barb) show(canvas) return canvas

Scaling the picture up def copyBarbsFaceLarger(): # Set up the source and target pictures barbf=getMediaPath("barbara.jpg") barb = makePicture(barbf) canvasf = getMediaPath("7inX95in.jpg") canvas = makePicture(canvasf) # Now, do the actual copying sourceX = 45 for targetX in range(100,100+((200-45)*2)): sourceY = 25 for targetY in range(100,100+((200-25)*2)): color = getColor(getPixel(barb,int(sourceX),int(sourceY))) setColor(getPixel(canvas,targetX,targetY), color) sourceY = sourceY sourceX = sourceX show(barb) show(canvas) return canvas

Recipe for halving the frequency of a sound def half(filename): source = makeSound(filename) target = makeSound(filename) sourceIndex = 1 for targetIndex in range(1, getLength( target)+1): setSampleValueAt( target, targetIndex, getSampleValueAt( source, int(sourceIndex))) sourceIndex = sourceIndex play(target) return target This is how a sampling synthesizer works! Here’s the piece that does it

Compare these two def half(filename): source = makeSound(filename) target = makeSound(filename) sourceIndex = 1 for targetIndex in range(1, getLength( target)+1): setSampleValueAt( target, targetIndex, getSampleValueAt( source, int(sourceIndex))) sourceIndex = sourceIndex play(target) return target def copyBarbsFaceLarger(): # Set up the source and target pictures barbf=getMediaPath("barbara.jpg") barb = makePicture(barbf) canvasf = getMediaPath("7inX95in.jpg") canvas = makePicture(canvasf) # Now, do the actual copying sourceX = 45 for targetX in range(100,100+((200-45)*2)): sourceY = 25 for targetY in range(100,100+((200-25)*2)): color = getColor( getPixel(barb,int(sourceX),int(sourceY))) setColor(getPixel(canvas,targetX,targetY), color) sourceY = sourceY sourceX = sourceX show(barb) show(canvas) return canvas

Both of them are sampling Both of them have three parts:  A start where objects are set up  A loop where samples or pixels are copied from one place to another To decrease the frequency or the size, we take each sample/pixel twice In both cases, we do that by incrementing the index by 0.5 and taking the integer of the index  Finishing up and returning the result

Ties to Mathematics I don’t know how to exploit them yet, but significant mathematics issues do arise here.  Integration, in understanding how to digitize sound (and pictures, to an extent)  Discrete representations of motion and curves.

Digitizing Sound: How do we get that into numbers? Remember in calculus, estimating the curve by creating rectangles? We can do the same to estimate the sound curve  Analog-to-digital conversion (ADC) will give us the amplitude at an instant as a number: a sample  How many samples do we need?

Nyquist Theorem We need twice as many samples as the maximum frequency in order to represent (and recreate, later) the original sound. The number of samples recorded per second is the sampling rate  If we capture 8000 samples per second, the highest frequency we can capture is 4000 Hz That’s how phones work  If we capture more than 44,000 samples per second, we capture everything that we can hear (max 22,000 Hz) CD quality is 44,100 samples per second

Simple Motion def movingRectangle(directory): for frame in range(0,100): #99 frames canvas = makePicture(getMediaPath("640x480.jpg")) if frame < 50: #Less than 50, move down # Generate new positions each frame number addRectFilled(canvas,frame*10,frame*5, 50,50,red) if frame >= 50: #Greater than 50, move up addRectFilled(canvas,(50-(frame-50))*10,(50-(frame-50))*5, 50,50,red) # Now, write out the frame # Have to deal with single digit vs. double digit frame numbers differently framenum=str(frame) if frame < 10: writePictureTo(canvas,directory+"//frame0"+framenum+".jpg") if frame >= 10: writePictureTo(canvas,directory+"//frame"+framenum+".jpg")

A Few Frames frame00.jpg frame02.jpgframe50.jpg

The trick here is all mathematics if frame < 50: #Less than 50, move down # Generate new positions each frame number addRectFilled(canvas,frame*10,fr ame*5, 50,50,red) if frame >= 50: #Greater than 50, move up addRectFilled(canvas,(50-(frame- 50))*10,(50-(frame-50))*5, 50,50,red) When frame = 1,  addRectFilled(canvas,10,5,50,50,red) When frame = 2,  addRectFilled(canvas,20,10,50,50,re d) When frame = 49,  addRectFilled(canvas,490,285,50,50, red) When frame = 50,  50-(50-50) = 50  addRectFilled(canvas,500,250,50,50, red) When frame = 51,  50-(51-50)=50-1=49  addRectFilled(canvas,490,285,50,50, red) When frame = 99,  50-(99-50)=50-49=1  addRectFilled(canvas,10,5,50,50,red)

Can we move more than one thing at once? Sure! def movingRectangle2(directory): for frame in range(0,100): #99 frames canvas = makePicture(getMediaPath("640x480.jpg")) if frame < 50: #Less than 50, move down # Generate new positions each frame number addRectFilled(canvas,frame*10,frame*5, 50,50,red) if frame >= 50: #Greater than 50, move up addRectFilled(canvas,(50-(frame-50))*10,(50-(frame-50))*5, 50,50,red) # Let's have one just moving around addRectFilled(canvas,100+ int(10 * sin(frame)),4*frame+int(10* cos(frame)),50,50,blue) # Now, write out the frame # Have to deal with single digit vs. double digit frame numbers differently framenum=str(frame) if frame < 10: writePictureTo(canvas,directory+"//frame0"+framenum+".jpg") if frame >= 10: writePictureTo(canvas,directory+"//frame"+framenum+".jpg")

addRectFilled(canvas,100+ int(10 * sin(frame)), 4*frame+int(10* cos(frame)),50,50,blue) What’s going on here?  Remember that both sine and cosine vary between +1 and -1.  Int(10*sin(frame)) will vary between -10 and +10  With cosine controlling y and sine controlling x, should create circular motion  frame=1 x is 108, y is 9  frame=2 x is 109, y is 4

Frames from two motions at once

Using your personal pictures

And messin’ with them

Data-first Computing Real users come to a user with data that they care about, then they (unwillingly) learn the computer to manipulate their data as they need. CS1315 works the same.  We use pictures of students in class demonstrations.  Students do use their own pictures as starting points for manipulations.  They started doing this in the second week How often do students use their second week of CS1 on their own data? How does that change the students’ relationship to the material?

Rough overview of Syllabus Defining and executing functions Pictures  Psychophysics, data structures, defining functions, for loops, if conditionals Sounds  Psychophysics, data structures, defining functions, for loops, if conditionals Text  Converting between media, generating HTML, “flattening” media and saving to a database Movies Then, Computer Science

Computer science as a solution to their problems “Writing programs is hard! Are there ways to make it easier? Or at least shorter?”  Object-oriented programming  Functional programming and recursion “Movie-manipulating programs take a long time to execute. Why?”  Algorithmic complexity “Why is PhotoShop so much faster?”  Compiling vs. interpreting  Machine language and how the computer works

Tools to support media computation JES: Jython environment for students MediaTools for exploring media

Assignments encourage collaboration Homework are all collaborative Quizzes are preceded by nearly-identical, collaborative pre-quizzes Two “take-home exams” (programming assignments) are non-collaborative “Lablets” on application software are collaborative

Assignments encourage creativity For several homeworks, the task is to manipulate media in some way, but we don’t care what media  For example, creating a collage or building an animation Encouraging homework results to be posted to CoWeb (collaborative website) in galleries

First Homework assignment Homework 1: Write a program named hw1 to accept a picture as input, and change its pixels as follows: Set the green component to 125% of its current value Decrease the blue by 25% Decrease the red by 75%

Solutions shared in the CoWeb

Grade distribution Much better than anticipated.

Homework #3: Make a collage with images that you modify by code only—any images you want

Grades on Homework #3

Take-Home Exam #2 Given a folder with images and sounds in it, create an index HTML page with links to each image and sound. You will write a function called indexPage that takes a string which is the path to a directory. You will create a page in that directory named index.html. Index.html should be an HTML page containing a link to every JPEG file and every WAV in the directory. At the top of the page, put a heading (level 1) with the phrase "Directory listing of sounds and images in " and then the directory, e.g., "Directory listing of sounds and images in C:\Documents and Settings\Mark Guzdial\mediasources" The links should be each an item in an unordered ( ) list. The anchor text in each link should be the filename of the image or sound. The destination (href) should be the same filename. For each image, on the same line as the filename, list the horizontal and vertical size (in pixels) of the image. For each sound, list the length of the sound in seconds. This is a NON-COLLABORATIVE ACTIVITY! You may not talk to anyone about their code, nor look at anyone else's code, nor allow anyone to see your code. This is a TAKE HOME EXAM. It is an "open book" exam. You may use your book, any slides, any material in the CoWeb, and any programs you've written (even with others) that you already have direct access to. When you turn in your exam, you are to enter into the Comment area the statement: "I did not provide nor receive any aid on this exam." IF YOU CANNOT MAKE THAT STATEMENT TRUTHFULLY, DO NOT SUBMIT YOUR EXAM! ANY EXAM WITHOUT THAT STATEMENT WILL NOT BE GRADED.

Take-Home Exam Results

Assessment results so-far Of the 120 students who started, only two dropped the course. 97% of the students on a midterm survey answered Yes to “Are you learning to program?”  Compared with 88% in our traditional CS1

What do you like about the class? “I like the feeling when I finally get something to work.” “Very applicable to everyday life.” ‘I dreaded CS, but ALL of the topics thus far have been applicable to my future career (& personal) plans- there isn't anything I don't like about this class!!!” “When I finally get a program to work like I want it to.” “The professor answers questions in class and online and is concerned about our success in the class. He also seems to understand that most of us are not engineers and most likely won't do straight programming in the future- just the way of thinking is important.”

What have you learned that you found interesting or surprising? “The most useful things I have learned are the basics about computers and pictures/sound. I think when we learn HTML- that will be interesting and useful to real life applications.” “Just general concepts about programming. It's pretty logical, sort of like in math, so it's understandable.” “Programming is fun and ANYONE can do it!”

Summary Perlis’ challenge suggests that CS is more important than Calculus  But need to update our pedagogy to make it happen Media Computation may be a useful context to motivate student performance Our class is aimed at addressing the challenges we’ve identified, and we’re trying it this semester The approach right now is aimed at non-majors, but certainly could be used with majors, too.

Acknowledgements Course materials development: Jason Ergle, Claire Bailey, David Raines, Joshua Sklare, Adam Wilson, Andrea Forte, Mark Richman, Matt Wallace, Alisa Bandlow. Assessment: Andrea Forte, Rachel Fithian, Lauren Rich Thanks to Vice-Provost Bob McMath and the Al West Fund, to GVU and CoC, and the National Science Foundation

For further information Course CoWeb: Where we planned the course:

Course Objectives Students will be able to read, understand, and modify programs that achieve useful communication tasks  Not programming from a blank piece of paper Students will learn what computer science is about, especially data representations, algorithms, encodings, forms of programming. Students will learn useful computing skills, including graphing and database concepts

Data structures Some data structure discussions come naturally  Sounds are in arrays  Pictures are matrices of pixels, each of which has red, green, and blue components  Files are stored in trees Much of our discussion of data structures comes in the form of encodings comparisons  RGB vs. CMYK for encoding color  22.1 Khz vs Khz for audio sampling rates