Results 1 to 1 of 1
Thread: Blurring Image
- 10-23-2009, 03:44 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 1
- Rep Power
- 0
Blurring Image
Here's my problem:
Set the red component of the colour of each pixel in the blurred image to the average of the red component of the colour of the pixels in a neighbourhood whose size is specified by the parameter passed to the method. Compute the green and blue components similarly. And of course, i have to correct for the edge pixels for which part of the 'averaging area' would actually not be part of the calculation (eg: pixel (0,0) would only have 3 neighbours instead of 8).
So far I have this code...:
it's not really completed yet, and it's only done for the red component. Does any1 have any idea to make this work?!
public void doBlur( @ParamDescrip("neighbourhood size") int size )
{
int x, y, xsize, ysize = -size;
int avgr,sumr=0;
Pixel nextPixel;
for( y = 0; y < myPic.getImgHeight(); y++ )
{
for( x = 0; x < myPic.getImgWidth(); x++ )
{
//int sumr, avgr;
xsize=-size;
if(x+xsize >0)
for(xsize = -size; xsize <= size; xsize++)
{
for(ysize = -size; ysize <=size; ysize++)
{
Pixel myPix = myPic.getPixel( x+xsize, y + ysize );
PixelColour pcol = myPix.getColour();
int r = pcol.getRed();
sumr = sumr + r;
avgr = sumr/((2*size+1)*(2*size+1));
PixelColour bColours = new PixelColour(avgr, pcol.getGreen(), pcol.getBlue());
nextPixel = myPic.getPixel( x + size, y + size);
nextPixel.setColour(bColours);
}
}
}
}
}
Similar Threads
-
Problems drawing a section of an image onto another image.
By Cain in forum Java 2DReplies: 1Last Post: 04-17-2009, 12:44 AM -
[SOLVED] manipulating the pixel values of an image and constructinf a new image from
By sruthi_2009 in forum AWT / SwingReplies: 14Last Post: 04-10-2009, 08:46 AM -
Canvas Image popups another image (SWT)
By SpaceY in forum New To JavaReplies: 2Last Post: 11-11-2008, 01:25 PM -
Converting multiple banded image into single banded image... Image enhancement
By archanajathan in forum Advanced JavaReplies: 0Last Post: 01-08-2008, 05:29 PM -
Blurring pixels
By tim in forum New To JavaReplies: 0Last Post: 01-01-2008, 02:06 PM
Bookmarks