Thread: Python and JES
-
February 11th, 2010, 12:45 PM #1Junior Member
- Join Date
- Feb 2010
- Posts
- 1
Python and JES
Hi,
Im learning Python and having trouble with this psuedo code. Can anyone help with this?
A. Your first function is fadeDownFromBlack. It takes a picture, and transforms it as shown below. Each pixel within a row is faded by the same amount, and by half way down it is fully faded in
multiply by 0.0 …
multiply by 1.0
multiply by 0.5 . . .
No change from here on ….
To darken a pixel you multiply the red, green and blue levels by an appropriate fraction. Specifically, if y is in the top half of the picture, all the pixels in row y have their RGB levels multiplied by y*(2.0/h), where h is the height of the picture. The pixels in the bottom half of the picture are not changed. It really helps to have some understanding of the formula above, try plugging in several numbers and see what the result is.
B. Your second function is mysteryEffect. It takes a picture and changes it as follows. For each pixel px it gets the red, green, and blue levels; call them r,g,b. It then does the following (type in this code verbatim):
setRed( px, 64*(r/64))
setGreen( px, 64*(g/64))
setBlue( px, 64*(b/64))
But wait, doesn’t 64*(r/64) just equal r? (Same with g and b.) So this function should not change the picture at all. But it does! Study the resulting picture, and put a comment in explaining how and why this actually changes the picture.
Here is my main:
def main():
pic1= makePicture( pickAFile() )
pic2= duplicatePicture( pic1 ) # this JES function makes a copy for you
fadeDownFromBlack( pic1 )
show( pic1 )
mysteryEffect( pic2 )
show( pic2 )
-
February 11th, 2010, 03:05 PM #2
you may want to ask to have this moved to the coding section and not the certification section; we dont do homework here.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Python?
By endrien in forum General Tech DiscussionReplies: 1Last Post: September 25th, 2008, 06:47 AM -
Python?
By Amr in forum Webmastering and ProgrammingReplies: 0Last Post: February 18th, 2006, 09:55 AM -
Python
By joker_927 in forum IMO CommunityReplies: 10Last Post: August 26th, 2004, 01:26 AM -
Need help with Python....
By couch potato in forum Webmastering and ProgrammingReplies: 1Last Post: February 8th, 2003, 07:43 PM -
Perl before C, except after Python....
By couch potato in forum Webmastering and ProgrammingReplies: 6Last Post: October 30th, 2002, 09:23 PM



LinkBack URL
About LinkBacks



Reply With Quote

That's hilarious GZ! Nothing like a little controversy to get people stirred-up. This will be fun to watch :)
Xbox One Announced