Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Spring 2006 Homework 2 Questions

Post your Homework 2 Questions Here:
i have finished my code and it makes the correct picture on my computer but when i tried to post it on the collage page, only one of the pictures shows up instead of 8.

when I submit my zipped picture file to webwork the folder seems to contain a thumbs.db, does this happen when i zip the folder?


I have tried to post my picture to the gallery, but it doesn't show up, although at the bottom it says something like missing file:my gtg. What am I doing wrong?


When grading our homework, will the TA type in "show(collage())" or "show(makeCollage())" ?

The TA will type show(collage()) -Albert d'Heurle

How do you make a canvas using makeEmptyPicture?
you can make a an empty canvas by saying canvas = makeEmptyPicture(400, 600) This will create an empty picture that is 400 x 600. -Albert d'Heurle


I have written my code and done various things with my picture step by step and the last thing I did was to flip it but it did not do it for all the four pictures i had created. How do I get it to mirror everything that I have done?
If you are trying to flip everything, you need to pass your finished canvas through the mirror function, not each picture individually. -Liz Helms

Do I have to program anything different when mirroring an entire picture and only mirroring half a picture over the other? I got the half and half program from the power point and took off the "1/2", but an error occurs.

I'm not sure what you're asking, but two kinds of mirroring that ARE different are the following... (1) Show what you see in a mirror (i.e. the pixels on the left appear now on the right, and vice versa). (2) Copy the left-hand side onto the right-hand side so that the picture is laterally symmetrical about the vertical midline (i.e. like Santa in class). Colin Potts

I have fully functioning code written already. I set the media path in the command area, and my code is set to accept the media path. When I type show(collage()) in the command area, my program runs fine, but it prompts me with the folder that I set my media path to. When prompted, I must hit enter before the function continues to run. Is this normal, and if not, is there a way I can avoid this?
You can take the setMediaPath() line out of your code. However you must set the media path before you run your code. You can do that in the command area by typing setMediaPath(). -Albert d'Heurle

Is it necessary to include return(canvas) at the end of the main program?
Yes. The instructions say to -Albert d'Heurle

I have a question on the writePictureTo function is not working. I keep getting an error message.
Are you sure you are passing the writePictureTo function your canvas, make sure it is in this form: writePictureTo(canvas, r"c:\gtxxxx.jpg") -Albert d'Heurle

Are these functions all acceptable and different enough:
deleting blue
gray scale
negative
or should I include a function that does something besides changing the color?
Also, I'm a little confused about getMediaPath and setMediaPath. Right now I have:
pic1=makePicture(getMediaPath('KESCS1315HW2-pic1.JPG')
pic2=makePicture(getMediaPath('KESCS1315HW2-pic2.JPG') etc...
My function works on my comp, and I know I will be sending the pics to you, but will the program be able to get the media path for the picture on a different computer?


Those are all fine. Yes, we will use the function setMediaPath() on our computers to the folder that we get when we retrieve your assignment. You can see how it would work by putting all of your pictures in a folder on something like, your desktop, and saying >>> setMediaPath() in the black area...then running your code. But, anyways, what you've shown should work (just make sure all of your parenthesis are closed)! Amanda Bennett

Are we allowed to grayscale the picture?
Yes. -Albert d'Heurle

look ^^^

I have set the media path for my pictures, but every time I exit JES open and it again, it gives me an error message when I try to load the collage
"Note: There is no file at C:\JES\Fish.jpg
makePicture(filename): There is no file at C:\JES\Fish.jpg
An error occurred attempting to pass an argument to a function.
Please check line 2 of C:\JES\CS1315\collage.py"
How do I change it so I don't have to set the media path every time?
You have to set the media path each time. -Albert d'Heurle

Now that I have taken all the show() commands from my code and added return canvas at the end, the program runs fine but tells me "A local or global name could not be found..." when I type show(canvas) in the command line.
Now that you have return in your code you can say picture = collage(). then after the program finishes you can say show(picture). -Albert d'Heurle

I am having trouble initially creating file. I have made a canvas with >>>show(makeEmptyPicture(1200,300))
how do I refer back to this canvas.. ive tried with makePicture or writePictureTo.
Use canvas = makeEmptyPicture(1200, 300). Now when you want to refer to the empty picture you can use canvas -Albert d'Heurle

I am working on my homework, and whenever I try to load the code JES returns: There was a spacinng error in the program. It might be from a previous line, but I think the error is in the line x. No matter what I do to the code JES returns this, but never for the same piece of code but always around the same line number. How can I fix that?
See a TA -Albert d'Heurle

I am confused by the statement, "you must mirror the ENTIRE canvas..." in the instructions. Am I allowed to place the mainpulated pictures on one half of the canvas, then mirror that half to the other half? or do I need to create another blank picture,place the original canvas on to it, and then flip the canvas?
All of the Homework 2 Collages that are posted will show you what to do. You put pictures on half of the canvas then mirror it. Amanda Bennett

I am doing a negative, grayscale and decreasing red...are these considered different modifications?
yes. Amanda Bennett


I have titled my program Collage but saved it collage like it said in the directions is that ok?
If that's what it said in the directions. Don't forget the &star.jpg on the end of the filename Amanda Bennett

Do you want us to turn in all the functions that modify the pictures, or just the main collage on the canvas?
All of the functions that you write should be saved in the same file, collage.py. Your whole code should produce changed pictures on our computer when we test your code. Amanda Bennett

I am having the same problem as the guy above. I get a spacing error on line X ("but it might be a previous line") no matter what code is in that spot.Help!
It could be a non-spacing error issue. Check your parenthesis and make sure they're all closed...and also that you aren't missing any colons. If you still can't solve the problem, come see a TA. Amanda Bennett


HOW DO YOU POST YOU COLLAGE ON-LINE???
HOW DO YOU POST ANYTHING ON THE WEBPAGES
Username: attach
password: carmen
-Blake O'Hare

ok, so i have a code that works, all except the mirroring part. i "borrowed" a mirroring code from the textbook, pg 78, and adjusted it by taking off the /2, thinking it would mirror the whole image, not just half like the santa. why isn't it working and how can i modify the code to mirror the whole image?
that is hard to answer however a TA can help you in their office hours -Albert d'Heurle


so when we are turning in our homework, do we also have to send a folder of all our modified pictures along with our collage.py?
Just upload each individual file into Webwork. Please give us your orginal pictures. -Albert d'Heurle

Can we manipulate all four pictures, and for the extra credit do they have to be four different pictures that have the same theme?
Probably to have a thematic collage you will need to have 4 different pictures -Albert d'Heurle

In my mirroring code I'm getting the error "A local or global name could not be found. You need to define the function or variable before you try to use it in any way." It points to the line of code in my nested for-loop where I wrote "col=getColor(pLeft)" (setting the color of the left pixel equal to the variable "col" so I can "setColor(pRight, col)" in the next line). How do I fix that error?

What is pleft. Make sure you have defined the pixel pleft -Albert d'Heurle

can anyone be nice and explain me step-by-step how to use writePictureTo() comand cuz i have tried everything and i doesnt work. i have spend 1hr trying to figure it out and it doesnt work.
thanks a lot
writePictureTo can be used in the following way: writePictureTo(canvas, r"c:\gtgxxxxhw2.jpg"). Make sure you are using the right object as the canvas. -Albert d'Heurle

when i use writePictureTo() comand it saves only part of the collage not the entire collage!why?
Make sure you are using the right canvas. -Albert d'Heurle

Do we just submit our pictures with our collage.py on webworks? or do we have to something else?
That should be it. Make sure you send the orginal pictures -Albert d'Heurle

i have written my 4 individual codes for the picture manipulations and now i am trying to piece it all together. this is what i have, but it says the "copy" line is an error. one TA said i need to write a copy function, but i thought thats what i did. i am confused as to how to continue. thanks.
def Collage():
canvas= makeEmptyPicture(1152,436)
picture1 = makePicture(getMediaPath('iluvsnowboy.jpg'))
picture2 = makePicture(getMediaPath('iluvsnowboy.jpg'))
picture3 = makePicture(getMediaPath('iluvsnowboy.jpg'))
c= copy(picture1,canvas,1,1)
So you need to define the a fucntion called copy that takes in 4 inputs. the picture you want to copy from, the picture you want to copy to and the startx and y. Hope this helps -Albert d'Heurle

a friend and i were comparing functions and we noticed that when i manipulate my pictures, they all come from the original. but my friend only defined one pic and so when executing the second manipulation, it takes the first manipulated picture as its input. do the 4 picture changes have to occur from the original? or does it not matter?
All changes should be from the original picture. -Albert d'Heurle


Just to clarify, is it ok to put the makePicture inside my function when defining the picture. I received a "(-2) don't put makePicture() inside the function" on my last homework project, but I'm assuming you would still need to add it before running. Basically, which will you want me to do:
picture1 = makePicture(getMediaPath("picture1.jpg"))
|This is correct -*Albert d'Heurle*|
or 

picture1 = getMediaPath("picture1.jpg")

This is defining the path to a file and does not make a picture out of the file -Albert d'Heurle

I have one picture that is half the width of the three other pictures on the canvas. When I mirror the canvas, only the smallest picture is mirrored while the other ones are mirrored from the center. Is it okay if the original pictures aren't completely mirrored or is there a way I can fix this problem? Thanks!

My code works, and I've submitted it, but I can't get the whole picture to load when I use the writePictureTo function. Each of the four pictures comes up by itself and I can't load it onto the website. The only thing that loaded was my original picture.

Hey i have done every thing but posting it on coweb ive tried to attach it but every time i hiit the Upload button a page comes up with a yellow unhappy face saying i did not enter the lock password...... i know about "attach" and "Carmen" but this is after that.....help
have you tried a lower case c in the carmen -Albert d'Heurle

I can't get the writePictureTo function to work. I have done what it says above but it still doesn't work. Please help!

I cant get the writePictureTo function to work on my computer. In JES I wrote writePictureTo(canvas, "C:\JES\MediaSources\flower2") there was no erro that occured but for some reason it won't save

Everything is working except it's not mirroring - it shows me the canvas with pics but not mirrored. Here is my code, do you see anything wrong with it?
 
 def mirrorHorizontal(canvas):
     mirrorpoint = getHeight(canvas) / 2
     for yOffset in range(1, mirrorpoint):
         for x in range(1, getWidth(canvas)):
             pbottom = getPixel(canvas, x, yOffset + mirrorpoint)
             ptop = getPixel(canvas, x , mirrorpoint - yOffset)
             setColor(ptop, getColor(pbottom))

Also, my canvas is black, is this OK?

I just posted the mirroring question w/code - nevermind, I fixed it.

I'm trying to use the writePictureTo() and getMediaPath() commands together so that my program will write its image to the previously designated media folder. I tried using
writePictureTo(getMediaPath("finalcollage.jpg"))
but that wouldn't work. Any help?

I have a working code that loads but when I put in setMediaPath() and go to mediasources were my pictures are located, there's only like 4 pictures there and none of them are the picture I need. I tried to put them on my desktop and C:// but I can't find the pictures anywhere?? I don't know whats wrong, also can I writePictureTo w/o setting the media path??

my picture isn't coming up at the end, what's going on?

is it ok to alter an already altered image? Can I posterize after making grayscale to result in 2 images, a grayscale, and then a posterized grayscale?

Ummmm It appears as though my computer does not like the fact that my canvas is larger than my computer screen, I can only see two of my pictures. They are 450px wide each, and I have made my canvas 1800 pixels wide. Please Help!

Everything seems to be going well until i come to the point in the code that says .
I got this directly from Mark Guzdial's code in the book and it isn't working. the error message that pops up is talking about
an array index being out of bounds. i've tried changing my dimensions for my blank canvas but it still doesn't seem to work.
thanks.

why are people posting pictures to this page? Can't they read?

my HW would load fine, but not return a picture or save it using writeTo()?


Uploaded Image: gth696ahw2.jpg
Uploaded Image: gth868kHW2.jpg
Uploaded Image: gtg827wHW2.jpg

Link to this Page