I am trying to blur the image
int radius = 11;
int size = radius * 2 + 1;
float weight = 1.0f / (size * size);
float[] data = new float[size *
If you frequently deal with pictures in your application, you may want to consider using the ImageJ API: It packs functionality on quite a lot of image processing tasks, including blurring.
Their Gaussian Blur filter will blur right to the edge of the picture, by making the following assumption
{...} it assumes that out-of-image pixels have a value equal to the nearest edge pixel {...}
Even if you don't want to change your code to use the ImageJ API, you may still find the above assumption useful to solving your problem.
For more info, check out the GaussianBlur filter in the API documentation: http://rsb.info.nih.gov/ij/developer/api/ij/plugin/filter/GaussianBlur.html