Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 609221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:32:34+00:00 2026-05-13T17:32:34+00:00

Trying to blur a picture in Jython. What I have does run but does

  • 0

Trying to blur a picture in Jython. What I have does run but does not return a blurred picture. I’m kinda at a loss of what is wrong with it.

FINAL (WORKING) CODE EDITED IN BELOW. THANKS FOR HELP GUYS!

def main():

pic= makePicture( pickAFile() )
show( pic )
blurAmount=10
makeBlurredPicture(pic,blurAmount)
show(makeBlurredPicture(pic,blurAmount))

def makeBlurredPicture(pic,blurAmount):

w=getWidth(pic)
h=getHeight(pic)
blurPic= makeEmptyPicture( w-blurAmount, h )
for px in getPixels(blurPic):
  x=getX(px)
  y=getY(px)
  if (x+blurAmount<w):
     rTotal=0
     gTotal=0
     bTotal=0
     for i in range(0,blurAmount):
         origpx=getPixel(pic,x+i,y)
         rTotal=rTotal+getRed(origpx)
         gTotal=gTotal+getGreen(origpx)
         bTotal=bTotal+getBlue(origpx)
     rAverage=(rTotal/blurAmount)
     gAverage=(gTotal/blurAmount)
     bAverage=(bTotal/blurAmount)

     setRed(px,rAverage)
     setGreen(px,gAverage)
     setBlue(px,bAverage)
return blurPic

The pseudo-code was as such : makeBlurredPicture(picture, blur_amount)
get width and height of picture and make an empty picture with the dimensions
(w-blur_amount, h ) call this blurPic

for loop, looping through all the pixels (in blurPic)
    get and save x and y locations of the pixel
     #make sure you are not too close to edge (x+blur) is less than width 
            Intialize rTotal, gTotal, and bTotal to 0
             # add up the rgb values for all the pixels in the blur
             For loop that loops (blur_amount) times
                    rTotal= rTotal +the red pixel amount of the picture (input argument)               at the location  (x+loop number,y)     then same for green and blue
             find the average of red,green, blue values, this is just  rTotal/blur_amount (same for green, and blue)
             set the red value of blurPic pixel to the redAverage  (same for green and    blue)
return blurPic
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:32:34+00:00Added an answer on May 13, 2026 at 5:32 pm

    The problem is that you are overwriting the variable px from the outer loop which is the pixel in the blurred image with a pixel value from the original image.
    So just replace your inner loop with:

    for i in range(0,blurAmount):
        origPx=getPixel(pic,x+i,y)
        rTotal=rTotal+getRed(origPx)
        gTotal=gTotal+getGreen(origPx)
        bTotal=bTotal+getBlue(origPx)
    

    In order to show the blurred picture change the last line in you main to

    show( makeBlurredPicture(pic,blurAmount) )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a blur event to some form elements which will run
I am trying to calculate the days on Blur method of End Date. But
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
Trying to perform a single boolean NOT operation, it appears that under MS SQL
I'm trying to blur a depth texture by blurring & blending mipmap levels in
I'm trying to mash in a simple blur on an image I'm rendering in
I'm trying to use Firebug to debug some Javascript that entails blur and focus
So what I am trying to do is to have a set UI with
I'm trying to achieve the following functionality. Within a form I have multiple fields
I'm trying to call a blur function on a variable assigned to a jquery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.