Python

Moderators: None (Apply to moderate this forum)
Number of threads: 400
Number of posts: 1055

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
I could use some help with my python program. Pretty PLease!!?? Posted by jessicajj92 on 2 Dec 2009 at 8:05 PM
ok so this need to be a program that take to pictures ( that are the same size ) and slowly fades the two into a newPic. this is what i have so far, but i am having major issues. I am totally new with programming and we are using JES.
def main():
  showInformation( "Pick two pictures of the same size." )
  pic1= makePicture( pickAFile() )
  pic2= makePicture( pickAFile() )
  
  w=getWidth( pic1 )
  h=getHeight( pic1 )
  assert w == getWidth( pic2 )
  assert h == getHeight( pic2 )
  newPic= makeEmptyPicture( w,h )
  
  printNow( "working..." )
  for x in range (0,w) :
    for y in range (0,w) :
    
      totalRed= 0
      totalGreen= 0 
      totalBlue=0
      mixingLevels= x /(float(w-1)) # I totally mess things up here
      int( mixingLevels*
      for mixingLevels in range( 0, w-1 ):
        px= getPixel( pic1, 1-mixingLevels, y)
        totalRed= totalRed + getRed( px ) 
        totalGreen= totalGreen + getGreen( px )
        totalBlue= totalBlue + getBlue( px )
        
      avgRed= totalRed / (w - 1)
      avgGreen= totalGreen / (w - 1)
      avgBlue= totalBlue / (w - 1)
      
      #px1= getPixel( pic1, x, y )
      #px2= getPixel( pic2, x, y )
      pxNew= getPixel( newPic, x, y )
      setRed( pxNew, avgRed )
      setBlue( pxNew, avgBlue )
      setGreen( pxNew, avgGreen )
      
  printNow( "...done" )
  show( newPic )
      


I think that i need to use a function called crossfade. here is a bit more info about the program, mixingLevel= x/ float(w-1) and int( mixingLevel*r2 + (1-mixingLevel) * r1) where r1 and r2 and the red levels from both picture.

please please please help!!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.