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


This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Fall 2003 Homework 1 Questions

Got a question on Homework 1? Ask it here!


so I tried to do homework 1...I typed everything in correctly. The recipe functions properly. But then when I repaint the picture, it doesn't change at all. What am I doing wrong? -Ashley Coker
If it's not repainting, then the recipe probably isn't functioning properly. Go through each line of your code – are you sure what it's doing is what you think it's supposed to be doing? Could it be that your IF's are set up wrong, so that actually none of the pixels get changed at all? You're also welcome to show your code to your TA or me for help. Mark Guzdial

how do I attach a pic file? every time I click on the attach link on the top, it asks for the username and password, I tried my gt# but apparently that's not it.
The username and password for uploads from off-campus is "attach" (username) and "carmen" (password). Mark Guzdial

I posterized my picture and it changed, but when I opened it up with MediaTools, not all the values were what I had told them to be. For example, the red values where it was supposed to be 64 ranged from 58-70. The values for all the other colors varied as well. What on earth is going on? (I'm using WinXP– you always ask)
Can you send me your program and your picture to check, please? Thanks! Mark Guzdial
I'm still working on this one. Remember that we're actually saving the picture in JPEG format. JPEG is actually a compressed picture format that does change the picture in subtle ways. I'm wondering if it's preventing those EXACT values from being in the file. My HW1 is working the same way. I wouldn't worry about it – the TA's can tell from your program and from the look of the picture whether or not you got it right. Check out Fall2003 HW1 Posters – there's clearly a specific look to these kinds of pictures. Mark Guzdial


i am having problems uploading the picture on the HW1 poster, what does it mean by 'write to'
You should use the function writePictureTo as discussed in class. Mark Guzdial

I posterized my picture, but when i opened it with MediaTools, none of the values show up.
Did you hold down the mouse button while you were moving the mouse over the picture? Mark Guzdial


I live on campus, but I didn't know the username and password for the poster page. Can I also use 'attach' and 'carmen'? I did that and it worked fine.

Hmm, shouldn't require it, but sure, it'll work. Mark Guzdial

when i try to run the program i get this response
posterize(picture)
getPixels(picture): Input is not a picture
An error occurred attempting to pass an argument to a function.
The input to posterize isn't a picture. Try printing it. Maybe it's a filename and you haven't made it into a picture yet? Mark Guzdial

After posterizing my picture and trying to use mediatools to check it my mediatools says that there are no pictures to examine. And also, do I need to save my picture somewhere and if so how do I do it?
You can save your picture using writePictureTo. I don't know why you're being told that there are no pictures to examine. Did you try showing it first, to make sure that it's a working picture? Mark Guzdial

how do you do use the writePictureTo function? What should I input in the command area?
For example writePicture(picture,"mypicture.jpg") Mark Guzdial


my picture will posterize then repaint but wont show. it says that i am trying to acces an object that doesnt exist what am i doing?
You're executing show() on something other than a picture. Try printing it first to see what it is. Mark Guzdial

HElp.
when I type this in the command area,
>>> writePicture(picture, jessica.jpg)
It says...
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.

..so then what do I put in the editor section then? cause every writePictureTo function I have tried to load has come back as not being legal jython. I think it is the whole (picture,location) thing that has me confused.
Like the responder said. writePicture isn't defined, so it's a name that isn't found. Without quotes, jessica.jpg is also treated as a name (not a string), so Python complains when it can't find that, either. Student282

ANYONE HERE FROM NEW ORLEANS, JUST OUTA CURIOUSITY.. I KNOW THIS BELONGS IN THE COMMENTS PAGE.. BUT WHO REALY CHECKS THAT.. BYE
I do, every day. Mark Guzdial



i cannot post my newly posterized photo on the page. I'll browse and upload it but once i try to view it it comes up as ..
The requested URL /uploads/cs1315/438/_tracy.4.jpg was not found on this server
and then it gives the red x in the place of my picture.
what am i doing wrong because i can view the picture from my documents fine.

You can't have spaces or underscores in your filenames that you upload to the CoWeb. Mark Guzdial

Is there any way to resize the picture using Jes because my picture is huge and I can't resize it and get it to save in the program I'm opening it from.
Yes, you can write a program in JES to resize – we're going to be doing that starting Friday, in fact. But it's not easy to do. There are lots of programs, even shareware, that you can use to resize. You might just use a smaller picture for posting. Mark Guzdial

i am executing on a picture (it's a jpg file), so i don't understand why i'm getting the error: trying to acces an object that doesnt exist. I used the same picture last week to start the assignment, and it worked then. Why is it not working?
I don't think that there's anything wrong with the file. I'm thinking that you're not using the right variable when you're executing the repaint or posterize functions. Try PRINTing what you are sending as input before you send it as input, to see what it is. If it's not a picture, it won't work. Mark Guzdial


I'm having trouble tranferring my picture to a jpg file. I enter this in the command area:writePictureTo(mypicture,"myname.jpg")
When I enter this it says:
The error java.lang.IllegalArgumentException has occured
What do you think the problem is?
Also, what do we use as our username and password when we "attach" the pic? Thanks.
Guys, please read the above questions and comments before you ask the same thing. user: "attach" password: "carmen" Lauren Biddle

By the way, how do we get to the page that shows our TA's and our gt#'s to see if an assignment we did was turned in?
Go to http://coweb.cc.gatech.edu/cs1315turnin and select the correct TA. Then on the next page pick the assignment. Lauren Biddle

do we have to post the picture here or is it enough to just turn it in on jes???
You don't have to post it on the CoWeb Lauren Biddle

I keep getting an error message for the line
setRed(p,64)
and for each line like that(setGreen, setBlue). What am I doing wrong?
What is the error? Check what "p" is – is it a pixel? Try printing it (you can put the print statement inside your program. Mark Guzdial

when we turn in the assignment, do we have to turn it in as the finished picture, or just the recipe?
We want the recipe – that's what your grade will be based on. Student784

I am having trouble saving my picture so I can post it on the website. I try: writePictureTo(picture,"mjposter.jpg") and JES keeps telling me this: I wasn't able to do what you wanted.
The error java.lang.IllegalArgumentException has occured. I am not sure what this means. Help please!!
Whoa! Never saw that one before. Go to the Edit menu, choose Options, and turn your mode to "Expert". That will give you REMOVED information in the error message. Try again, and tell us what it says (you can email me directly). Are you sure that "picture" is a picture object? Print it to be sure. Mark Guzdial

I wrote most of them program fine, and JES has no problem resetting the > values for each pixel, but the program gives me an error message for the lower color valued pixels in red, blue and green. they are typed same as with greater than values, but JES wont re-set these. It says im trying to pass a string to a function expecting an integer, even though the same function will work two lines above. whats going on? Jason Wright
It's not the function that it's complaining about, Jason, it's the input. What are you passing as input? I'm guessing that you're passing a pixel in where it's working, but accidentaly passing a string where it's not. Mark Guzdial



I've done something wrong in writing my function. when i type in posterize(picture), it gives me the standard "a local or global name cannot be found...." so then i go to load the function again, and it gives me a "There is something wrong with the text of the file you had me try to load. You may have not have as many closing parenthesis as opening parenthesis, or you may have tried to use a jython keyword (if, def, etc...) as a function. This cannot be done."
I've looked and I have the correct number of parenthesis, and my code looks just like the one in the slides. Any idea of what I'm doing wrong? Thanks.

You can print it out to show to me or a TA. Also check for things like colons at the end of "def" and "for" lines. Mark Guzdial

PLEASE NOTE:

The name of your function is to be hw1 and it must accept a picture as input. That means that the first line of your recipe should be def hw1(picture):. (Check the Homeworks-Fall 2003 page to see this requirement.) If your function contains makePicture or pickAFile, it's wrong. Mark Guzdial

Have do you remove pictures from the Gallery? (My first upload didn't work, because I had spaces in my filename.) #12
You can't, but don't worry about it. Just upload the new one. Mark Guzdial

When I try to attach to the poster page, I am prompted for a username and password to connect to coweb...I've tried using my gt account info and that doesn't seem to work.
You only get this off campus – see FAQ. Username "attach" and password "carmen". Mark Guzdial

How do I find out what the pixels on my .jpg file are set at to begin with?
You can use MediaTools, or you can print getPixel(pict,5,10) to see the pixel at column 5 row 10. Mark Guzdial



I just had someone send me their code, where they ran the code, it worked fine (i.e., it finished with no errors), but nothing happened to the picture when you repainted. It did the same thing for me, but then I figured it out – the spacing was wrong on all the IF and setRed/setGreen/setBlue lines. I clicked on the line right after the FOR loop and saw the blue box ONLY contained the lines red=..., green=..., blue=...? That meant that ONLY those lines were inside the block of the FOR loop. The rest – all the IF statements – were spaced differently so that they are AFTER the FOR loop. That meant that the FOR loop ended up not changing ANY pixels.
The lesson is: Check your spacing. There should be 4 spaces before each IF (2 for the DEF, 2 for the FOR) and 6 spaces before each setRed/setGreen/setBlue (2 for DEF, 2 for FOR, 2 for IF). Mark Guzdial

I'm on campus, and I did have to enter the username and password to attach. But "attach" and "carmen" worked fine.
It all depends on how the Web server defines "on campus." I think that some of Resnet is considered "off-campus" in terms of the network. Mark Guzdial

i tried to writePictureTo and JES came back with this message....
I wasn't able to do what you wanted.
The error java.lang.IllegalArgumentException has occured
in file E:\WIN\JES\Sources\media.py, on line 871, in function writePictureTo
in file E:\WIN\JES\Sources\media.py, on line 477, in function writeTo
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: output == null!

whats wrong??
We've seen this once before. Print your picture. Do you get -1 for the height and width? If so, you have an old version of Java installed on your computer. Go to http://www.java.sun.com and install Java Runtime Environment (JRE). It's free. There's one on our CD, but if you have your own Java installed already, JES will try to use that. Mark Guzdial

I attatched the posterized picture to the gallery ok, but I was wondering what was that swiki attach part below? do we need to worry about it?
You don't NEED to attach your picture to the Swiki – it's totally voluntary. Don't worry about attaching at all. Mark Guzdial


Even though I live on campus, I had to use the off-campus username and password. Just thought that might be of interest to you.

I think I am misunderstanding the "accept a picture as input" what does that mean exactly?

Declare hw1 like this def hw1(picture): not like this def hw1():. Use it like this hw1(mypicture) not like this hw1() Mark Guzdial


I am having problems loading my function. It tells me that there is an error in the setRed(p,64). I completely erased the "red" part of the function and it told me that there was an error in the setBlue(p,128). So the error always occurs in the last line of the "paragraph" of function. The error is, "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 made sure that my p was a pixel.

Why don't you email me your program and I'll take a look at it. Mark Guzdial

I turned in my HW1, but realized that I had typed in some wrong numbers, so I rewrote the function and sent it back in, but it looks like it didnt overwrite the original HW1 that I sent in. Is that ok? My TA is REMOVEDmmer and my account is gte320n
It did overwrite. Go to the Attach view of the page – you'll see that your turnin has an "(R2)" (second revision) next to it. Mark Guzdial

for the person having an error with their setRed and setBlue type lines, make sure that they are two spaces over underneath the if statement, because that happened to me when i had them all in the same line with the if statements.
YUP! That was the problem. The setRed and setBlue lines were seen as outside the function, so "p" wasn't defined. Mark Guzdial


In response to the person who wanted to resize his/her image: download windows powertoys (google for it) and install image resizer.

I forgot to name my function hw1 and had to go back and change it. Do I just resubmit through JES to upload my updated hw1.py file?
Yes, that's fine. Your TA will be able to see which one was submitted second and they will grade that one. Student117

When I posted my picture, the picture did not show up- just a box with a "red X" Is there a way to fix this?

You can't have spaces or _ in your file name.

I am working from a computer at school. When I try to open any jpgs, from mediasources or ones that I save to this computer myself, whenever I try to see them by typing "picture=makePicture(file)" after defining file, the program responds with
"exceptions.TypeError
loadImage(): expected 0 args; got 1
[('C:\\JES\\Sources\\media.py', 433, 'loadImage', 'if self.pic.loadImage(filename) == 0:')]
Was unable to load the image in C:\mediasources\desert.jpg"
WHAT DOES IT ALL MEAN??

I did the function right, but I can't get my picture to posterize and then reprint? What command should I be using to posterize my picture?
If you mean it isn't showing the new posterized version of the picture, instead of showing the picture before you posterize, you can show it afterwards and then all you see is the posterized version. I know sometimes my computer will only change part of a picture of not at all if I already have the picture displayed.

I get this same error:
"am having problems loading my function. It tells me that there is an error in the setRed(p,64). I completely erased the "red" part of the function and it told me that there was an error in the setBlue(p,128). So the error always occurs in the last line of the "paragraph" of function. The error is, "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 made sure that my p was a pixel. "
Your problem there is probably spacing. Make sure that you have everthing within that line spaced out how it needs to be. For instance, you should have included spaces after your commas. Remember JES can be very sensitive sometimes. Student117

I made sure there were two spaces before the if statements, but how do I make sure that the pixel is really a pixel?
thanks




I've gotten the program to work, but whenver I put hw1(picture) and it posterizes it, then when I type show(picture) the picture still looks the same and nothing has changed. Am I missing something?


I was wondering if the pre-quiz that is going to be handed out during the 1 o clock class will be the same as the the one as the 3 o clock lecture?, I have a doctors appointment tommorow afternoon and can't come to the 1 oclock. Please let me know as soon as possible, Thanks.
Just pick up the prequiz at the 3 pm section Student56
But don't on the prequizzes being the same at 1 pm and 3 pm in the future! All the dates for pre-quizzes and quizzes are on the Syllabus. Mark Guzdial

I am working from a computer at school. When I try to open any jpgs, from mediasources or ones that I save to this computer myself, whenever I try to see them by typing "picture=makePicture(file)" after defining file, the program responds with
"exceptions.TypeError
loadImage(): expected 0 args; got 1
[('C:\\JES\\Sources\\media.py', 433, 'loadImage', 'if self.pic.loadImage(filename) == 0:')]
Was unable to load the image in C:\mediasources\desert.jpg"
WHAT DOES IT ALL MEAN??
Never saw that one before! Did you install JES on the computer yourself? Mark Guzdial


when I type def hw1() at the begining of my program and when I try to run it in command area, it shows the picture repainted. But, when I try to type def hw1(picture) as you mentioned at earlier, I can't repaint the picture due to local or global definition can't be found. would you help me out here.
Look carefully at your variables. If all you changed was the placeholder name, then you're redefining picture inside your function, so your input picture is never getting changed. Mark Guzdial

This is what happens when I try to save my picture, similar to above situations, but I'm not using an old form of java b'c the height/width were OK
>>> print(picture)
Picture, filename C:\Documents and Settings\Katy Jo Schroer\My Documents\My Pictures\tn0231-3168_IMG.jpg height 319 width 240
>>> writePictureTo(picture, "katyjoboats.jpg")
I wasn't able to do what you wanted.
The error java.lang.IllegalArgumentException has occured
in file D:\Win\JES\Sources\media.py, on line 871, in function writePictureTo
in file D:\Win\JES\Sources\media.py, on line 477, in function writeTo
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: output == null!
>>>
Is "D:" your CD? If you're running from CD, you can't save like that, because you can't write to a CD. Try writePictureTo(picture,r"C:\katyjoboats.jpg") and see if the picture shows up on your C: drive. Mark Guzdial




I cannot get my homework to turn in....
I did everything correctly and add the file and then hit turnin but I never get a pop up saying it was successful or not and it is not showing that it has been turned in on my TA's page...what is the problem?

There's a list of things to check on the Announcements page – did you check all those? You are NOT supposed to add your .py file. Instead, it should be open in the Program Area. Mark Guzdial

You can't turnin when running from CD!

If you're running JES from the CD (i.e., you didn't copy it to your hard disk), you won't be able to turnin. JES needs to be able to write out some temporary files that it can't do on a CD. Mark Guzdial


How can you stop running JES from the CD. I have my homework done and thought I had turned it in last night but realized in class I really had not and I keep trying to turn it in. Please advise. gte434p
Copy it to your hard disk. Follow the directions for installing that are on the CD and that we went over in class. Mark Guzdial

by "If your function contains makePicture or pickAFile, it's wrong" do you mean that we shouldn't have makePicture or pickAFile in the program area at all?
Yes, that is correct. Mark Guzdial


i am trying to look at a picture online, but it is just a red x. what do i do?


Ok, I have a similar problem with the writePictureTo function that people have been complaining about with one difference. I don't get an error message I just get an empty file at the end that contains 0 bytes. I typed in exactly writePictureTo(pic,"name.jpg"). I checked, the picture looks fine, pixels changed and everything and I spelled the variable name correct, yet all I get is an empty file called name.jpg.



PLEASE STOP ATTACHING YOUR PICTURES TO THIS PAGE!

Link to this Page