Presentation is loading. Please wait.

Presentation is loading. Please wait.

Test 2 on Wed, 11/9 On image processing

Similar presentations


Presentation on theme: "Test 2 on Wed, 11/9 On image processing"— Presentation transcript:

1 Test 2 on Wed, 11/9 On image processing
Allowed to use JES to test your code, but discouraged Last day to withdraw with W: 11/15

2 Picture Functions ppp =makePicture(pickAFile())
ppp.getWidth(), ppp.getHeight() xxx=ppp.getPixel( , ) xxx.getColor(), .getRed(), .getGreen(), .getBlue() xxx.setColor(), .setRed(), .setGreen(), .setBlue() makeColor(), pickAColor()

3 Some Utility Functions
If you know the name of the file, searching for it with pickAFile() is boring You can set and get a media folder (path) in order to remember the folder where your media files are coming from (or going to) setMediaPath() lets you pick your media folder and remember it getMediaPath(“\test.jpg”) lets you generate a complete path of the filename from only the last part

4 Example >>> setMediaPath() New media folder: C:\mediasources\
>>> getMediaPath("barbara.jpg") 'C:\\mediasources\\barbara.jpg' >>> barb=makePicture(getMediaPath("barbara.jpg"))

5 Additional Picture Functions
setMediaPath() – fix a path to media files getMediaPath(filename) file = makeEmptyPicture(100,100) – creates a blank picture of size 100x100 writePictureTo(file, getMediaPath()+“\100x100.jpg”) – save file with name “100x100.jpg” canvas=makePicture(getMediaPath(“100x100.jpg”))

6 Picture Copy copy.py with Two pictures
‘pictA’ to copy to ‘pictB’ (pictB has to larger than pictA) def picCopy(fromPic, toPic): # for every pixel in fromPic, copy its colors to the same pixel location in the toPic def main(): setMediaPath() picA = makePicture(getMediaPath(“ “) # get the width of picA # get the height of picA # create an empty picture, called picB, with the same dimension picCopy(picA, picB) repaint(pictB)

7 Copy flower1 to lower left corner
sourceX sourceY flower1 targetX = sourceX targetY = sourceY + ? ? : getHeight(canvas) – getHeight(flower1)

8 Copy flower2 targetX = sourceX + getWidth(flower1)
sourceY flower2 flower1 targetX = sourceX + getWidth(flower1) targetY = sourceY + ? ? : getHeight(canvas) – getHeight(flower2)

9 Lab_1104 Create a large empty picture, called ‘canvas’
Modify picCopy() so that it has four arguments: picCopy(fromPic, toPic, toX, toY) where toX and toY are coordinates in toPic from where pixels in fromPic have to be copied over updated copy.py to


Download ppt "Test 2 on Wed, 11/9 On image processing"

Similar presentations


Ads by Google