Pixelation Program... trying to pixelate an image in Jython

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vanaa
    New Member
    • Apr 2013
    • 3

    #1

    Pixelation Program... trying to pixelate an image in Jython

    Code:
    def pixalated():
      myFile = pickAFile()
      myPicture=makePicture(myFile)
      n=requestInteger("Please enter an (integer) for pixelation")
      width = getWidth(myPicture)
      height = getHeight(myPicture)
      canvas = makeEmptyPicture(width,height)
      for x in range(0,width,n):
        red = 0
        blue = 0
        green = 0
        for y in range(0,height,n):
          red = getRed(myPicture)
          blue = getBlue(myPicture)
          green = getGreen(myPicture)
        averagered = (red/(n*n))
        averageblue = (blue/(n*n))
        averagegreen = (green/(n*n))
        red = averagered
        blue =averageblue
        green = averagegreen
        newColor = makeColor(red, blue, green)
        setColor(myPicture,newColor) 
        y=y+1
      x=x+1
      show(canvas)
    Last edited by bvdet; Apr 29 '13, 02:54 PM. Reason: Please use code tags when posting code [code]....[/code]
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Do you have a problem with your code or a specific question?

    Comment

    • vanaa
      New Member
      • Apr 2013
      • 3

      #3
      I have problem with my code

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        And the problem is........

        Seriously - What is your code supposed to accomplish? Does your code error when run? If so, please post the complete traceback.

        I'm not familiar with Jython, so I'm at a disadvantage.

        Comment

        • vanaa
          New Member
          • Apr 2013
          • 3

          #5
          the code supposed to open an image with pixelated effect. Yep the code has error when i load it .

          Comment

          Working...