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

Summer 2006 Homework 1 Questions

Post your questions here and a TA will try to answer them:


When I complete the function and test it with a picture on my computer, the picture doesn't automatically come up. I have to view it with the picture tool, where it has already been posterized. Is this OK?

Yes, that's fine. If you put a show(picture) at the end of your code, it will automatically come up, but you're not required to do that. - Bobby Mathew

Is there any chance that Homework 1 could be scheduled for turn in on Thursday instead? As it stands, it conflicts with our recitations, and does not allow us to get help during recitation if needed prior to turning it in.
Webwork accepts submissions till midnight (grace period), so you can still get help after recitation and still have a few hours left to turn it in without losing any points for turning it in late - Bobby Mathew

for homework one,does the wedsite (c:\Doc...) need to be in the top, white part of jes???
You don't need that line at all. You are using pickAFile(), so you don't need to specify any path. - Bobby Mathew

what is the best way to swap colors
You can set the red value of the pixel to the blue value of that pixel and vice-versa. - Bobby Mathew

could it just be written in code as setGreen(p, red == blue, blue == red)
That wouldn't work because its not right syntax. Also, you don't have to setGreen to anything. Only change the red and blue values of the pixels. - Bobby Mathew

how do you write a swap in jython
In general, if you want to swap 2 values, you can do it 2 different ways:

def swap1():
value1 = 3
value2 = 5
value1, value2 = value2, value1 # Swaps the values
print value1
print value2

def swap2():
value1 = 3
value2 = 5
temp = value1 # Storing value1 in a temporary variable called temp
value1 = value2 # Taking the second value and putting it into the first one
value2 = temp # Putting the temp value (which is value1) into value2
print value1
print value2

Use the swap statements from either of the above functions in your PosterizeMe function.

- Bobby Mathew

I don't mean to be dense, but I do not understand the above swap statement. My notes from class and recitation said to swap values I should setRed(p,green) and setBlue(p,green)under the if statement of green100. I am not sure how this translates into the def swap shown above or where this def should be placed in our program.

I just wrote 2 functions so you can see how it works. In your code, just use the statements that actually switch the values. Don't worry about def, value1, value2, print etc. - Bobby Mathew

Oops, I forgot the complete statement...I had setRed(p,green) SetBlue(p,green) setGreen(p,red) setRed(p,blue). Is that wrong?

Swapping the red and blue values mean taking the blue value of the pixel and doing setRed to that value and vice versa. You don't need to use setGreen at all. - Bobby Mathew

so is it safe to say that we can define red or blue to be value1 or value2 and work it out form there...

Yes, you can do that. - Bobby Mathew

I think the confusion is from the statement "if green...then swap red and blue for THAT pixel", which implies to me the green pixel, instead of just switching blue to red with each other. Thanks for clarifying.

The term 'green pixel' doesn't exactly make sense. Every pixel has 3 color components - red, green and blue. - Bobby Mathew

do you want us to use repaint(pic)at the end, or are you going to use show(pic) again.. I know it doesnt really matter as for the code to work, but I just wanted to clarify.

Don't repaint(picture). When we grade it, we'll use show(picture) from the command line. - Bobby Mathew

Whenever I attempt to save a picture that I've posterized, a un-posterized picture will appear in the folder that I've specified. I'm using the 'writePictureTo()' function. Does this need to be in the top?

Try putting a show(picture) statement at the end of your code. If the original picture shows up instead of the posterized one, it means that your code isn't correct. Also, when you do writePictureTo, make sure you're copying the correct picture over, although this shouldn't be a problem because there's only one picture in the entire function. - Bobby Mathew

So when I go into my media sources area the picture i saved is posterized, but when I went to put it on the site it wasnt posterized...obviously. A)can that get taken off, and B)i dont really understand how it is posterized in one place and not the other? -Abby Showers

We can take off the other picture later. We'll only check the new one when grading it. I'm not sure what the exact problem might be but make sure you did the following: Using writePictureTo(picture, "C:\.................\gtXXXX.jpg"). If you did that correctly, try saving it in another folder instead of mediasources. Once you save it, open up the image, make sure its posterized and then put it on the site. If you still have problems, email one of the TA's with your code. - Bobby Mathew

I'm so confused about getting my picture to be where it's supposed to be, how to get it, etc. For personal reasons I was unable to complete lab2 and now I am lost. I have the program and I can go to pickAFile, but creating my function just keeps saying that I have an error or does nothing at all? Please help!

When you do pickAFile(), you have to pick a jpg image and then use that in your function. You have to be more specific with the error. Since the assignment is almost due, email/IM me if you need help. - Bobby Mathew



Links to this Page