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 Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Spring 2006 Homework 1 Questions

In the directions it only assumes the red value is between 70 and 150. What if the red value is greater than 150? Then what do you set it to?

for the last clause of the homework is it asking for:
a) the average of the green and red –> ((green + red) / 2) or
b) the average of the green and the average of the red –> (green / 2) + (red / 2)?
Remember that the green and red variables here refer to the red and green components of the color of a single pixel, so interpretation (a) is the only one that makes sense. In fact, I'm not sure what you mean by (b). Colin Potts BTW, if you use the box at the bottom of this page instead of editing the page itself, your question will always appear last and be answered by TAs.

for some reason, when i try to attatch my picture for the extra credit, it asks me to log in and i cannot seem to find the right username and password. is it our gt# or our 901#?
Once again, read other students questions and their answers before you ask a question. And to answer your question again... read the FAQ page. Liz Helms

When it says to write a function that accepts a picture as input, does it mean that whoever calls the function will write changeColor(C:\\blahblahblah)?

Pretty much, yes. A few syntactical differences, though. -Blake O'Hare

Should the function display the changed picture when it's done?
When you turn your function in it should not include show() or writePictureTo(). However when you are writing your code feel free to use show to test your program and see the results. Also you need to use writePictureTo to recieve the extra credit. Just make sure to take out those lines before you turn your function in -Albert d'Heurle

Should we include pickAFile()? Can we do it in a separate function?
No! (to the first question) Of course! (to the second) -Blake O'Hare

Are we assuming that the person running the program will define the picture themselves (so we are turning in a general template of sorts)?
Yes. -Blake O'Hare
Also, I would like to inquire as to the password and username I need to post my poster on coweb for extra-credit. Thanks for your time!
Read the FAQ. -Blake O'Hare

Umm...Nevermind on the posting picture question...
I answered them anyway. Someone else may have the same question. -Blake O'Hare

How do you find out what values the red, green, and blue pixels of the picture are? I know I go to mediatools and then picture tools, but what function do you write first to find out the pixel values before you change them? thanks.
The functions getRed, getGreen, and getBlue take in a pixel and return the numerical value of the color value. -Blake O'Hare

In the homework we are suppose to change the entire picture but in the example with barbara we only changed the pixel with brown. In the example when the code says brown=makeColor(57,16,8) what will we replace it with in the hw since we want all the pixels?
Well, the brown assignment just creates a color (or names the color (57, 16, 8) 'brown'). That's nothing to do with which pixels get changed. We happened to use that in deciding which pixels needed to be made redder because that made sense when reddening someone's hair. The visual effect in the homework is decidedly freakier. (Check out some of the posters to see this.) To decide which pixels you need to make bluer or greener or whatever in the homework example, just follow the five conditions in the bullet points in the homework statement. Colin Potts

My program is taking an incredibly long time to change all the pixels in the photo I'm using for my example. Is this normal? I've been waiting almost 5 mins. and it's still running...
If you're using a large picture, or one with lotssss of pixels (say, one straight from a digital camera), then yes, it's going to take FOREVER! Try scaling down your picture using a picture editing program first and then run it. Hopefully it'll run faster. Amanda Bennett

What exactly is meant in the homework question when they refer to "taking in" a value? Is it just refering to taking given information, processing it, and returning something else? (in essence is this a good answer for the question? Thanksfor your time!
It's the INPUT to your function. This will be gone over more in recitation this week. It's a variable that is some value (or in this case a picture) that will somehow be used or manipulated in the function. Amanda Bennett

This is kind of a website question, but every time I try to go to the extra credit page and upload my picture, it gives me a sign in pop-up when I click attach. I've tried signing in, but it doesn't work, and then a screen comes up that says access denied. Should I just try on another computer?
Check the FAQ Liz Helms

when i load the program and when pick up a picture i enter changeColor i receive message "". what could posibely be wrong? my picture doesnt change the collor!
You need to show() your picture for the colors change to become visible. The message you receive is not an error message. We will cover return values from functions in class soon. Colin Potts

When saving the photo for the extra credit, the Prof. recommends using writePicureTo. In the help section of JES, it says writePictureTo(picture,path). Is the picture the name of the picture such as : C://blah,blah,blah.jpg? What goes in the path, and how do we know where to save the file?

When you use the writePictureTo(x, path) the x is whatever your input is. In this homework, it should be titled picture, pic or some variation there of. So in the end, your writePictureTo should look like this: writePictureTo(inputted/altered picture, path). Does this make sense?? Liz Helms

Sort of. How do I give my new picture a title?
When saving it, with the writePictureTo function, the last part, the C://blah,blah,blah.jpg, replace the blah blah blah with whatever you want your picture to be named, in this case, your gt#### number. Liz Helms

How do you write less than or equal to, and greater than or equal to?
This is in the slides and in the textbook. I covered it in my lecture yesterday. The answer is <= and >= respectively. Colin Potts

How do we write out the "average of the original red and green values" in our function?? Ashley Anderson
Perhaps im misinterpreting your question but.... You dont write out the "average of the original red and green values". Instead, you set the blue value of a pixel to be the average of the original red and green values. Larry Olson

yeah now that i re-read that it makes no sense. i understand that that is what the blue is supposed to be set to. but how do we get that value?
Well, how would you calculate an average of your grades for a Math class? Take that exact same method and combine it with knowledge of how to get the Red value, Blue value, or Green value from a given pixel. (Note: Have a look at the Table on pp.71 of the text and also at pp. 47 of the text.) Larry Olson

I have the homework completed, but everytime I upload my picture to the posters page it won't display and I get messages saying there are errors in the picture...? Shannon Townsend
What's the exact error you're getting? I just uploaded a picture to the page and it worked fine. Do you have the correct username and password? Check the FAQ if that's what's incorrect. Amanda Bennett

Any idea when the grades from Lab 2 will be posted for section B3 of Andrew H?
They should probably be posted before Saturday, but you should email him to make sure. Bobby Mathew #2
They will be posted as soon as possible. I will try to have them done before recitations but that won't always be possible. Either way, they will always be done by the Friday the week after they are due. Andrew Hardin

When I tried uploading my picture, I can see my picture on the attachment page but I can't see the actual picture on the uploaded page. I wanted to reload my picture and delete the pictures that I already uploaded, is it possible? I named by picture gth731q.jpg and when it was uploaded it became gth731q.jpg.jpg

Deborah Nam

i saved my hw as changeColor.py and i submitted it already but when i try to retrieve it, it won't open saying that windows cannot open the file.

You have to open the file from inside JES. Amanda Bennett

setBlue(p,(originalRed + originalGreen)/2) is there something wrong with this line. I keep getting an error.

An attempt was made to call a function with a parameter of an invalid type. This means that you did something such as trying to pass a string to a method that is expecting an integer. What does this error mean?

This looks fine to me (but I sometimes miss errors that are staring me in the face). Are you sure that in your function p is really a pixel and that originalRed and originalGreen are really integers representing intensity values? Colin Potts



do we need to set the program to remember the original colors in the begining of the program or can we do that in the if loop?

There's no such thing as an if loop. If you mean 'for loop', then setting original values inside it is going to re-set them each time the program goes through it. That may or may not be what you want. If you are talking about an if statement, then setting original values inside it will set them only if the if condition is true and won't set the values otherwise. Colin Potts

I tried to load my program but it says that I have a syntax error in line 6. Line six reads: if (green>=150). What should I change?

Add a : after the )


I uploaded my changed picture to the posters with the wrong filename, how do I delete the picture or can I just upload another one to replace that one?
Just upload the picture you want with the correct filename. We'll worry about the rest. Larry Olson


I submitted my hw1 to webworks and was able to retrieve and download the file but it won't let me open it and view the program???
So you got back the .zip file and couldnt open it? If that is the case then download a program like WinZip or IZarc and use that to open the zipped file. Note: If you are using Windows XP then this should not be an issue. Otherwise I am assuming that you have the file unzipped already but are having issues opening it in JES. If this is the case, then start JES first and then try to open the file from within JES. Hope this helps. More info would be good. Larry Olson


I did get the .zip and do have windowsXP, I opened the file and extracted the file, the file didn't have the jes snake icon but the e thing. I tried to open it with the open with pull down and chose jes but it just looks like its about to open jes and then nothing happens. I can open ot manually in jes though
That will suffice. -Blake O'Hare

Ok, I have read all of the comments.. I cannot get my picture to save period. I see it all changed right on my screen but i cant get the writePictureTo to work.. here is what im putting..and my errors..
>>> writePictureTo(pic,"C:\\Documents andSettings\\Holly\\Desktop\\image.jpg")
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.
Everything on this line looks correct by itself, so therefore the problem is that pic is not defined. You must use the same variable that you passed into your changeColor function. -Blake O'Hare
and..
>>> writePictureTo(r,"C:\Documents andSettings\Holly\Desktop\gth829k.jpg")
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. Thanks guys!!
...and the problem in this case is the r is supposed to go in front of the string (without the comma) when you don't use double backslashes. Which also means you're not passing in a picture at all. It was correct in your previous example. -Blake O'Hare

Thank You Blake and Larry, girl with the retreival issues

When I try to retrieve my submission via webwork it downloads and unzips fine, BUT then when I try to open it, jes looks like it is starting up but then stops.(the jes image pops up for a second then disappears)
I tried resubmission as well as having jes open when I try to open it.
it's even named as changecolor.py. Help!!!
First try opening JES first, then opening the .py file from inside JES. But it does sound like you have a serious problem here. If you try to open JES on its own and the splash screen is all you see before it just goes *poof*, then something else is wrong. If that's the case, see a TA. -Blake O'Hare

My serious problem becomes not so serious if I name the program simply changecolor not changecolor.py
That way I can use another program such as internet explorer to retrieve it. Will I get taken off for that? Previous question said no problem, but I just want to make sure since I know that it's because I didn't name it right.

Make sure the final version you turn in ends with .py. -Blake O'Hare

after I perform the writePictureTo() function, it saves the picture to the specified location but it saves it as 0 bytes. I am confused as to why it appears in my folder but doesn't exist?

Two random suggestions: (1) Say your picture is called 'pic', try putting 'print pic' before your line 'writePictureTo(pic, ...)'. This gives you some diagnostic information. How big is pic? If it's zero pixels, maybe you're not creating the picture correctly. (2) Are you sure that the saved picture really is 0 bytes long? Instead of believing the file browser, try pickAFile() to re-load your written picture file and then show it. Does it appear correctly? Colin Potts

When I try to post my altered pic to the page for extra credit, when I click attach it askes for a username and password.

–ignore that last post.– sorry

When I attach my picture its size is 0 and is blank. What am I doing wrong?
The picture isn't being written to file. Double check your writePictureTo code and that you're passing it a valid picture. Also make sure the file you're uploading is, in fact, the file you wrote out from JES. -Blake O'Hare

>>> changeColor()
An attempt was made to call a function with a parameter of an invalid type. This means that you did something such as trying to pass a string to a method that is expecting an integer.

I get this message when I try to type changeColor() in the command section...help????
Because you didn't pass in the picture. -Blake O'Hare

I cannot understand why JES refuses to let me past my second line of code. I have a valid picture file as input but when it tries to run through " for p in getPixels(picture): " (which is indented properly), it keeps telling me the input is not a picture. I don't get it, it's a JPG file copied directly from pickAFile() on my computer. I've tried other pictures with the same result. What could be wrong?
Did you use makePicture? -Blake O'Hare

No, how would that help if the input was a picture already? How would you impliment it if you needed to?

wait, I think i see what you're saying, thanks.

File paths that you get from pickAFile are nothing more than strings of characters that represent the address of the file, not the actual contents. -Blake O'Hare

Should writePictureTo be in the white section or the black section? I was trying to do that in the black section (unsuccessfully) after the program had run... and when I include it at the end of the program in the white section it highlights it as an error.
The easiest way to writePictureTo is in the white section. Are you making sure that whatever variable you are using for your input you are also using for the writePictureTo function? Once you write the picture to your computer you can then delete the line and turn in the function. -Albert d'Heurle

This is what I get when I try to run my program on a picture: "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." I have the def changeColor picture at the beginning of my program...so what could be wrong?

in addition...that is what happens after i type in changeColor (picture) in the command area
are you making sure to click the load button? -Albert d'Heurle

How do you make a discrepency between the ORIGINAL green and red colors instead of the new red and green colors the pixel may have already taken on?
This is not going to be an issue, once you change the color of the pixel you are going to move onto the next pixel until there are no more pixels to change. -Albert d'Heurle

for some reason when i try to attach a filename such as my filename i am usinf in the writePictureTo, it says it is not a valid filename. what's happening?

I asked the question about the picture saving as a 0 byte image and I tried to open the picture with another program and I get the message, "couldn't display 'gtg879q.jpg' because a suitable graphics importer could not be found" What should I do?

when i try to upload my picture i get a message from microsoft C++ that says runtime error... what's going on?

Should we include show or return picture in the code we write and save or should it just change the picture and require you to show the picture later?

Can someone please tell me what is illegal about this/ why it is a syntax error???
if(red > 70):

AND what if you get to the end, you arent getting ANY errors, you have a lovely string of program, and the picture doesnt change??? AND its the last minute? Eh? What then?

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. Please check line 14 of C:\Documents and Settings\Desktop\jes-216\changeColor.py
can someone please tell me why it would say this and highlight this line?
"setGreen(p,20)"

first of all I think there should be a space, setGreen(p, 20), could be wrong...



Links to this Page