+ Reply to Thread
Results 1 to 2 of 2

Thread: Python and JES

  1. #1
    Junior 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 )

  2. #2
    THE Gimp Clown Fish! nemowolf's Avatar
    Join Date
    Jun 2007
    Location
    Bay Area
    Posts
    4,936
    you may want to ask to have this moved to the coding section and not the certification section; we dont do homework here.

    TechIMO Folding@home Team #111 - Crunching for the cure!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Python?
    By endrien in forum General Tech Discussion
    Replies: 1
    Last Post: September 25th, 2008, 06:47 AM
  2. Python?
    By Amr in forum Webmastering and Programming
    Replies: 0
    Last Post: February 18th, 2006, 09:55 AM
  3. Python
    By joker_927 in forum IMO Community
    Replies: 10
    Last Post: August 26th, 2004, 01:26 AM
  4. Need help with Python....
    By couch potato in forum Webmastering and Programming
    Replies: 1
    Last Post: February 8th, 2003, 07:43 PM
  5. Perl before C, except after Python....
    By couch potato in forum Webmastering and Programming
    Replies: 6
    Last Post: October 30th, 2002, 09:23 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews