Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
salaak
salaak's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Blur issues with pixels
[1 Reply]
22-Feb-2013 09:48 AM
Forum:
Programming Questions
Hello all.
I'm pretty new to Processing and programming in general and taking a class on Processing.
Professor is asking that we apply a motion blur on an image.
I tried using the filter(BLUR); function but turned out that it couldn't do a motion blur effect.
Looked up on the Processing topic site and used the code there and came up with this.
The problem is that the coder used a greyscale picture and I need it in color and then apply motion blur.
And then save that image to use in another assignment.
PImage bBall;
float v = 1.0/9.0;
float[][] kernel = {{v, v, v},
{v, v, v},
{v, v, v}};
void setup()
{
size(534*2, 346);
bBall = loadImage("BasketballBorder.png");
noLoop();
}
void draw()
{
image(bBall, 0, 0);
bBall.loadPixels();
PImage edgeBBall = createImage(bBall.width, bBall.height, RGB);
for (int y = 1; y < bBall.height-1; y++)
{
for (int x = 1; x < bBall.width-1; x++)
{
float sum = 0;
for (int ky = -1; ky <= 1; ky++)
{
for (int kx = -1; kx <= 1; kx++)
{
int pos = (y + ky)*bBall.width + (x + kx);
//Having trouble here for the color values since it's using only the red(), it's making everything grey
float val = red(bBall.pixels[pos]);
sum += kernel[ky+1][kx+1] * val;
}
}
edgeBBall.pixels[y*bBall.width + x] = color(sum);
}
edgeBBall.updatePixels();
}
image(edgeBBall, width/2, 0); // Draw the new image
}
Also how do I create a motion blur?
I was thinking either changing the values in the kernel and have them weighted differently which didn't work.
Or do I change something within the for loops and to have them change multiple pixels at once in a certain direction.
Or is there a common way that I'm not aware of?
«Prev
Next »
Moderate user : salaak
Forum