![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Through webwork. You'll need to register and create an account (it's free). This is where grades will be posted as well. Your TAs should go over how to turn stuff in and do a walk through in your next recitation. -poof #10 |
| It would be best to leave that out and only use it while you are writing the code for the assignment. -Albert d'Heurle |
| You can certainly TEST your program with showing before and after, but remove those lines before turning it in. Think about the TA testing 25 programs – she really doesn't want 50 pictures opening up when she's trying to test them in a big batch. Mark Guzdial |
| Yes, you can use if/else Toni Walden |
| It's difficult without seeing all of your code. Do you have semicolons after getPixels(picture)? If not, that's your error. See a TA at office hours or online for more specific help. Amanda Bennett |
| You can use any word there. You can call it banana if you'd like. It is just a variable. But everytime you want to refer to the input, you need to use the same word. -poof #10 |
| No. Posterize takes the average of the colors that surround the pixel. It would just posterize it even more. -poof #10 |
if(green<100):
setRed(p, green) and setGreen(p, red)| First of all, i'd be careful using the word 'and' in my code (particularly when you aren't using it as part of the if statement). Second, if possible, I wouldn't use "green" and "red" as variable names in JES, simply because they're already defined. Third, should your picture change if red is pure red with this statement (what would the value of the green value be if only red were in your picture)? Keep thinking. You're getting there Amanda Bennett |
| Trace through your code and see if you made a mistake. You can also look on the homework gallery to see how other people's picture turned out. Amanda Bennett |
| That line of code is correct (assuming you've defined picture as your input). What does the code look like before this point? Check over all of your code to find the error. Amanda Bennett |
| Make sure it's indented correctly. -poof #10 |
>>> abs(65) 65 >>> abs(-65) 65 |
| Absolute value works with numbers. What gives you a number when dealing with pixels? If you subtract 2 color values, you still have a value, correct? We just don't want that value to be negative, so you put it inside of the abs function. Amanda Bennett |
| Perhaps I am misunderstanding your question, but it is impossible to change a picture without changing its pixels, and to change the pixels you need to get at them. Have a look at a few examples from the slides and book to remind yourself how this is done. It's basic to all the picture manipulations you will be doing, so you need to master these ideas. Colin Potts |
| try taking it a piece at a time. Make sure you have the orignal color values saved as variables. Write the if statement, and then just do setRed like you normally would but instead of setting it to a number set it to the absolute value of original green-original red, hope that helps -Ally Chase |
| There is no way for us to tell you if your code is creating the correct picture without physically looking at it. If you are unsure, I would suggest taking your homework to a TA and have them look over it. Just because you see a picture posted doesn't necessarily mean that it is correct. -poof #10 |
| There doesn't seem anything obvious wrong with either of these two lines so I can't help you right now. It's possible that your indentation is wrong, that you misspelled something (possible if you retyped the lines above correctly rather than cutting and pasting them from JES), or that there is an error on the previous line that is confusing JES into locating the error on the (correct) line below it. There's really no such thing as "an" error message. There are lots of types of error messages. The text of the message may tell you more than you realize. What does it say? Colin Potts. BTW, Charlie, you put your name in asterisks as though you had a who's who page, but you haven't created one for yourself yet. |
| Strange. Your numbers are off by small amounts but the discrepancies aren't systematic. This suggests to me that you're probably looking at pixels adjacent to the ones that you set. Actual pixel indices go from 0, but the pixel numbers in getX and getY go from 1. You may think that you're looking at the pixel at (30,30) when you're really looking at the one at (31, 31). It's confusing if you use both methods to access pixels. (Disclaimer: I may be completely wrong about the pixel addressing scheme in MediaTools, and I try not to use it.) Try printing out the value of getPixel(pic, x+1, y+1) and see if that coincides with the value that MediaTools is giving you for (x, y). In any event, getPixel(pic, x, y) should return the correct value – the value that you set. If it doesn't, then there really is something wrong with your program. Colin Potts |
| Somebody may have accidentally overwritten the link to your file when they added their own. I've put the link back at the end of the page. BTW well done with the series completion puzzle last week. Colin Potts |
| I assume that the function generating the error message is writePictureTo() (although, I don't understand in that case what it is that is working in JES, but anyway....) Make sure that you are calling writePictureTo() with two arguments. The first is the picture; the second is a string that represents the path to the file you are writing the picture to. If you get these two in the wrong order you will get this error message. Colin Potts |
| setRed() takes two inputs. The first is a pixel and the second is a number. You are only supplying the number. -poof #10 |
| If you are trying to post your picture for the extra credit, just go here. Make sure that your file is named according to your prismID or your TA won't be able to find it. Examples: gtg561q.jpg or cholder3.jpg -poof #10 |
| Please supply the line of code that is giving you the error or come by my office hours from 5PM-6PM in the library and/or 6PM-7PM in Skiles 318 (the library closes at 6 on Friday's so I have to leave) -poof #10 |
| It should be posterizeMe(picture). The picture should be passed in as a parameter. - Bobby Mathew |
Make sure the first line of your function is def posterizeMe(picture). Then in your code, you shouldn't have anything like pickAFile() or makePicture() etc. When you run it, type the commands under the 'How the TA will grade part' and it should work. If its still not working, email a TA. - Bobby Mathew |
| Everything you need to know about naming the file is on this page. -poof #10 |
| No. Parameters are explained on pages 32-33 of the textbook. Colin Potts |
| An example of parameter passing is show(pic). The function show() takes ONE parameter/input, a picture. You put the parameters inside the ()'s. iF there are multiple parameters you seperate them by commas. You should be using parameters all the time. getPixels(pic), getRed(px), and posterizeMe(pic), all take in parameters. If a function needs input or a parameter, that means that something else is supplying the data that it's going to work with. -poof #10 |
| If you would like to then you can as long as your homework does all of the correct color value checks and the end result is correct. But it is a lot simpler than using 3 for loops. -poof #10 |
| Make sure that return in not inside your for loop. When JES gets to the word 'return' it exits the function. -poof #10 |
| Maybe, personally, I don't look at the pictures, I grab the HTML and searrch for gtg numbers. But if you really want it to show up, make sure it's in the correct format. Look at a few of the other linked pictures. If it still won't show up, I would just send your TA an email. And make sure they can see that you tried to post it BEFORE the homework is due. -poof #10 |