Docsity

CS 110: Introduction to Computer Science - JES Image Manipulation Tutorial - Prof. David W, Assignments of Computer Science

Toggle sidebar
bg1
CS 110: Introduction to Computer Science Spring 2008
Media Computing with JES
Introductory Tutorial
JES is a development environment for Python that allows you to
write Python programs which can do photoshop like manipulations
of images.
JES can be accessed from your CS account. Your instructor will let
you know how.
Loading JES might take a few seconds. After it comes up, Click on
Help | Table of Contents.
This will get you to some information and tutorials on how to create
images, sound, and movies with JES. For now, just follow the
instructions below.
JES has two main windows. The top one is a text editor in which you
can create python programs in files with .py extensions. The
bottom one is a python interactive interpreter. After creating or
opening a python file in the top window, you can click 'Load' and it
the program will be executed in the interpreter (bottom window).
JES provides some library methods of its own that are not part of
the standard Python library. One is pickAFile() which pops up a file
choosing dialog. In the interactive interpreter, enter the following:
>>> fileName= pickAFile()
When the file chooser appears, choose some file (for now it doesn’t
matter which one).
>>> print fileName
This should print out the full path of whatever file you chose.
Now let's view a picture.
1. Open a web browser and find an image. Right-click the image
and save it to your home directory.
pf2

Partial preview of the text

Download CS 110: Introduction to Computer Science - JES Image Manipulation Tutorial - Prof. David W and more Assignments Computer Science in PDF only on Docsity!

CS 110: Introduction to Computer Science Spring 2008

Media Computing with JES

Introductory Tutorial JES is a development environment for Python that allows you to write Python programs which can do photoshop like manipulations of images. JES can be accessed from your CS account. Your instructor will let you know how. Loading JES might take a few seconds. After it comes up, Click on Help | Table of Contents. This will get you to some information and tutorials on how to create images, sound, and movies with JES. For now, just follow the instructions below. JES has two main windows. The top one is a text editor in which you can create python programs in files with .py extensions. The bottom one is a python interactive interpreter. After creating or opening a python file in the top window, you can click 'Load' and it the program will be executed in the interpreter (bottom window). JES provides some library methods of its own that are not part of the standard Python library. One is pickAFile() which pops up a file choosing dialog. In the interactive interpreter, enter the following:

fileName= pickAFile() When the file chooser appears, choose some file (for now it doesn’t matter which one). print fileName This should print out the full path of whatever file you chose. Now let's view a picture.

  1. Open a web browser and find an image. Right-click the image and save it to your home directory.

CS 110: Introduction to Computer Science Spring 2008

  1. Call pickAFile and this time pick the image file you just downloaded.

filename= pickAFile()

  1. Create a picture object with the 'makePicture' function provided by JES

pic = makePicture(filename)

  1. Show it:

show(pic) The image should appear in a window.

  1. Now let's manipulate the picture. There's a list of functions that can be executed on pictures. To see what exists, select Help! Understanding Pictures | Picture Functions in JES. For now, let's just draw a line on our picture. Try the following:

addLine(pic,0,0,500,500) repaint(pic) Do you see the line on the picture?

  1. Draw some text on the picture:

addText(pic,100,100,'HELLO')

  1. Note that the manipulations take place on an in-memory (RAM) version of the picture. If you want to modify the actual picture file you loaded, you must call

writePictureTo(pic,filename) After doing this, go into the folder where the pic is and double- click it. Whatever application opens it should show it with the line. Good Job! Next, we'll learn how to manipulate images pixel by pixel.