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);
}
}
}
}
}