![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Look up "greater-than-or-equals" in the index of the textbook. Colin Potts |
| Do it in stages: Find out the red and blue values, giving those quantities names. Then set the new blue and red values accordingly. Colin Potts |
| Check your indentation. Spacing errors often happen when you have a for, if or else that isn't followed by an indented block. Getting the indentation wrong may also have been the reason for the program not working the first time. You may, for example, have been changing the color of only the very last pixel in the picture (which is hard to notice) rather than all of them. Colin Potts |
| When you use writePictureTo, the 'picture' argument needs to be the variable in the code you used to hold the picture (so likely 'pic', or somesuch), the 'path' argument needs to be a directory path, plus the filename you want to save it to. So for instance, you could have a path of "C:\PosterizedPic.jpg". Make sure to include the quotes. If I'm understanding your problem correctly, chances are good that you have one of those listed incorrectly. Chris Phillips |
| Thanks, Chris. And I will be covering writePictureTo in class on Friday. Colin Potts |
| The link was broken, and I have corrected it. Sorry about that – and also for missing this question earlier. Colin Potts |
writePictureTo(picture,"C:\\Users\\JayBoyyyy\\Desktop\\jcollins6.jpg\\")_ Jay Collins
Do not add the \\ at the end of the string then it should work. Your string should look like "C:\\Users\\JayBoyyyy\\Desktop\\jcollins6.jpg" |
| No, it shouldn't. It'll work, though. Noah Witherspoon |
| You submit it on T-square. Thanks! Brittany Duncan |
| Make sure that you have extracted them. The media sources come as a zip file, which requires you to extract its contents before you can access it. If you need help with extracting the files, have a look at http://eee.uci.edu/help/zip/how-to/#winunzip Chris Phillips |
| Check the JES Dictionary - Picture Manipulation Commands page for the writePictureTo method. Noah Witherspoon |
| You can combine expressions using the keywords and, or and not. I will be talking about this in class tomorrow. Colin Potts |
| Just send a note to your collaboration statement to your TA, explaining that you forgot to add it to the submission itself. Colin Potts |
| You should be saving your homework as a draft, and -not- clicking submit. Once you click submit, you can never submit again. You'll have to email your TA if you realize you forgot something. If you save as a draft, however, then you can update it as often as you like until the due date. At the due date, T-Square will automatically submit your saved draft for you, so you don't need to worry about it. Chris Phillips |
| Could you post the "writePictureTo" line from your code, so that we can see what might be wrong? Remember to enclose it in code tags as explained at the top of this page Colin Potts |
writePictureTo(picture, "C:\Users\Owner\MyDocuments\posterizedpic.jpg")
(picture, r"path.jpg")
writePictureTo(picture, r"C:\DocumentsandSettings\Owner\MyDocuments\MyPictures\posterizedpic.jpg")
| Well, there's your problem. C:\DocumentsandSettings and C:\Documents and Settings are different from each other. (Think spaces.) Computers are very, very stupid and they do what you say, not what you obviously mean. Colin Potts |
if getRed(pixel)>80 and <=167:
even if something seems repetitive, it's still neccessary getRed(pixel)>80 and getRed(pixel)<=167:And you might want to check your parathesis too, you don't have enough. |
Red = getBlue(pixel)
Green = getGreen(pixel)
Blue = getRed(pixel)
http://server6.theimagehosting.com/image.php?img=cat.456.JPG
| That's looking like something that is going to take some code examination to rectify, since nothing immediately comes to mind that could cause that, short of some rather interesting code weirdness. Come by someone's office hours with a copy of your code, or email your TA and ask if you can submit it to them through email to receive comments on it. |
setRed (pixel,abs (Blue - Red))
| The spacing does not matter. Colin Potts |
| Are you really getting that banding on the image? I.e. the color shifts change abruptly part way down the image? (That's the way your image looks in my browser.) If so, send me your code by email and I can comment on it. Colin Potts |
| You can put any number of spaces between things but not inside them. The symbol >= is one logical operator that means "greater than or equal to", so if you put a space between the two symbols that is like putting a space in the middle of a variable name. I'm surprised that the program even ran. Spaces between names and symbols do not matter – so a>=b and a >= b are the same. Colin Potts |
if 80<Red<=167:
i.e. a < x < b
if (80 < Red) and (Red <= 167)
temp = a a = b b = temp
| It means that you are using it as if you had already given it a value, but you haven't. Colin Potts |
| Try sticking in two '\\'s at the end of the path, before the 'bigben.jpg'. See if that does it. With the code I have for this, I got an error, as it seemingly tried to interpret '\b' as being an escaped character, rather then part of the path. Chris Phillips |
| I don't believe that the SAME program will give an error for one picture and not for another. (There are many situations where this can occur, but these situations will not arise with the template you should be using.) What is almost certainly what is happening is that you are tinkering with your program to see what happens so that the different behaviors you are observing and that are puzzling you are really coming from (slightly) DIFFERENT programs. This is very confusing for you, and since it means that you are unable to state precisely what is going on, nobody else can help you either. I can't tell what the problem is with your program right now, but if, say, the very LAST error message you got was that "redness" is not being bound to a value, work out why redness doesn't have a value. There should be a line above the point of the error that starts "redness = ....", and the error message suggests to me that that line is missing. So ask yourself what the value of redness should be and give it that value. Colin Potts |
| Yes. Put it in a comment. Colin Potts |
| If they actually helped you in some way (rather then just glanced over it and nodded), go ahead and throw in "I worked on this homework with the aid of a CoC/athletic department assigned tutor, Soandso". I suspect that'd still fall under the same clause as "Colin and the TAs", in people you can leave out of your collaboration statement, but barring something by Colin or Brittany (and with the deadline coming up), it's probably best to just err on the side of caution, and provide full disclosure. Chris Phillips |
| For the keywords, look at some examples of code from the book (pick some from anywhere) and ask what keywords appear on the line immediately preceding an indented block. The keywords are the ones that would be highlighted in blue if you type the example into JES. We have encountered four of these words so far. For passing parameters, see the last two paragraphs of p. 32. Colin Potts |
| Are you sure about this? I ran my version of the program twice to see what would happen. I get a very blue picture after running posterizeMe a second time. Interestingly, the third time, it looks a bit like it should, and then the fourth time is is v. blue again. Obviously, if you posterize a posterized picture, weird things are going to happen. I think you're accidentally doing the posterizing twice before looking at your results and then when you do it again, it looks nearly right. Colin Potts |
| It may be possible that you need to do a repaint(pic) before showing it. -Buck Scharfnorth |
| Yes you do need to find the exact values, but you do not necessarily need to use the program to find it. I find it simplest to solve by tracing your code and deriving your answer mathematically. You cannot have more than 1 value for any single R,G, or B value. The value will between 0 and 255, and because the red, green, and blue are not related, you can have any of the 16 million possible colors (256^3) with 256 possible values for each red, green, and blue. -Buck Scharfnorth |
| There are no steps. Assuming that you have a picture called pic, just say show(pic) or openPictureTool(pic) in the command area. Experiment with the picture tool by clicking on the picture. Colin Potts |
| On mine it is "/Users/potts/Desktop/" (Note the capitalization.) The second folder in the path could be anything, but its name should appear in the left panel of the finder next to a home icon. Colin Potts |
| Even better: Go to the Macintosh HD icon in the finder and navigate from there. |
| Well, if you read the line of code carefully, this looks like a case of sloppy cutting-and-pasting! Colin Potts |
| There are two problems. The second one, which you haven't hit yet is that you should really give your file a sensible name – something like "gtg139y.jpg" (a name followed by the dot-jpg extension.) The first error, which is giving you the error message is that you are trying to save a picture object called picture that doesn't exist. You must have called your picture something other than "picture". That is what "The error was:picture" is telling you. Colin Potts |
| Just send him or her a note explaining what has happened and that you can supply the file by email if necessary. It probably won't be. Colin Potts |
| If your program generated and saved them, sure. Why not? Colin Potts |
| No. Saving files is quite basic and necessary. You won't be able to do the movie homework (#3) at all if you don't get this. If the Coweb were not responding so that you couldn't upload a file that you had successfully saved, that would be a different story. But you have to have a file to upload. Colin Potts |
| Big mistake - but you know that now, and it's a valuable lesson. Run and debug as you go. Colin Potts |
| Well, that's a reasonable hypothesis. If it runs slow, try it on a faster computer. But as you found out, it is probably the program itself. My guess is that you are doing LOTS and LOTS of computation for every pixel. Do you have one for loop? There should just be one loop. The block inside the loop should consist only of if statements and their blocks – no more for loops. (You can email me your code now for a quick sanity check.) Colin Potts |
| There is no try; there is only do ;) Seriously. It's doing what you tell it to do, so let's work out how come you're telling it to save the original file, not the changed one. (1) The posterizing does actually work? I assume it does. (2) You're calling posterizeMe(pic) from the command area? (3) You're doing writePictureTo(pic, "blahblah.jpg") also from the command area? (Are the same names [pic in my example] being used for both posterizeMe and writePictureTo? Colin Potts |
| If you say something like r=getRed(pixel) r will be the original red value of the pixel. Even if you later change the red value using setRed, r won't change. Colin Potts |
| They don't. Your program should work for ANY picture. That's why functions have parameters. Colin Potts |
| No. The parentheses make it clearer for many people, but they aren't necessary. Colin Potts |
| I think that the autosubmissions don't happen until midnight after the 5-hour grace period expires. T-Square flags them as late, but don't worry about it. Colin Potts |
When swapping values, you need to be able to do it in a way that won't overwrite needed variables. For instance - a = 5 b = 3 a = b b = a What's wrong with this? Well, you start out with a being 5, and b being 3. In the first step, a = b, you're making it so a now stores the value 3. The 5 is lost. So in the second statement, when you say b = a, you're just reassigning b the value of 3, because that's what a now holds, the 5 is gone. This (can) apply in the homework, depending on how you do it, because your comparisons are all the -original- values, of the original pixel. You don't want your assignment statements to interfere with those, because you could accidentally change the original value, which'll mean you've lost your original value, in the same way we lost the 5 up above. And if you lose the original value, then your later comparison statements may not evaluate properly. If you're still not understanding, swing by someone's office hours soon, so you can be brought up to speed before the next homework.Chris Phillips |