Introduction to Computer Programming / JES
Introduction to Computer Programming / JES
Filtering Pictures (Time: 1 hour)
GADOE Standards:
• BCS-BP-6. Students will design solutions for simple programs using basic programming techniques and constructs.
• BCS-BP-4. Students will explore different representations of images and music in a computer.
• BCS-BP-5. Students will design algorithms and programming solutions for a variety of computational problems.
• BCS-BP-11. Students will write programs that process lists.
Lesson Objectives:
To create and show pictures.
To modify a picture.
To create functions.
To recognize different types of data.
To sequence operations in a function.
To explore, print, and write statements.
|Terminology |Definition |Python Code |
|Define a function |Defines a function that will run in |def name(): |
| |the program | |
|Block |A collection of commands | |
|Write |Writes the strings to a file |write () |
|Loop |Repeats the function for time |for (variable) in |
| |specified. | |
|Nested Loop |A loop within a loop |for (variable) in |
|Show |Shows the output of the function |show() |
|Explore |Shows the output of the function |explore() |
|pickAFile |User selects a file |Filename=pickAFile() |
|makePicture |Creates a picture from the file |myPicture=makePicture(Filename) |
|pickAFile |User selects a file. |File=pickAFile |
|Print |Shows code of function |print () |
Program Functions
|Decreases the red in the picture |def decreaseRed(pict): |
| |for p in getPixels(pict): |
| |value = getRed(p) |
| |setRed(p,value*0.5) |
|Decreases the red on the top half of the picture |def decreaseRedTopHalf(pict): |
| |for x in range(getWidth(pict)): |
| |for y in range (getHeight(pict)/2): |
| |p=getPixel(pict,x,y) |
| |value=getRed(p) |
| |setRed(p,value*0.5) |
|Clears the blue from the picture |def clearBlue(pict): |
| |for p in getPixels(pict): |
| |value=getBlue(p) |
| |setBlue(p,0) |
|Test the picture function |def test(): |
| |myFile=pickAFile() |
| |myPict=makePicture(myFile) |
| |explore(myPict) |
| |decreaseRedTopHalf(myPict) |
| |explore(myPict) |
Assignment:
Find or take a digital picture and write a program that will perform the following output:
• Increase green in the top half of the picture
• Clear red in the whole picture
• Increase blue in the bottom half of the picture
• Explore, print and write the program
• Test and run the program
Save the code in JES “filterpicture.py”
Make sure that you save the picture before filtering the image and save the picture after running the program.
Name the pictures “Filter1.lastname.jpeg” and “Filter2.lastname.jpeg”
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- 1 introduction to computer tripod
- cse 240 introduction to programming languages
- introduction to computer programming in c and apps
- csci 101 introduction to computers and information
- introduction to computer programming jes
- midterm exam of cs005 introduction to computer
- introduction to computers and programming
- cis 110 intro to computer logic and programming
- ge209 introduction to computer programming
- course outline fall 04 cs 113 introduction to computers
Related searches
- introduction to computer systems pdf
- introduction to java programming pdf
- introduction to computer studies pdf
- introduction to computer science
- introduction to computer packages pdf
- introduction to computer pdf notes
- introduction to computer science free
- introduction to computer network pdf
- introduction to java programming and data structures
- introduction to java programming 10th
- introduction to java programming liang
- introduction to java programming ppt