ok, this is the "section" ok code..
for(int x = intMatrixHalfX; x < inputImage.image.getWidth() - intMatrixHalfX; x++)
{
cp.jpbProgress.setValue(x * inputImage.image.getHeight());
for(int y = intMatrixHalfY; y < inputImage.image.getHeight() - intMatrixHalfY; y++)
{
r = 0; g = 0; b = 0;
for(int xx = 0; xx < mb.getMatrixWidth(); xx++)
{
for(int yy = 0; yy < mb.getMatrixHeight(); yy++)
{
r += inputImage.RGBarray[x + xx - intMatrixHalfX][y + yy - intMatrixHalfY][0] * matrix[xx][yy];
g += inputImage.RGBarray[x + xx - intMatrixHalfX][y + yy - intMatrixHalfY][1] * matrix[xx][yy];
b += inputImage.RGBarray[x + xx - intMatrixHalfX][y + yy - intMatrixHalfY][2] * matrix[xx][yy];
}
}
if(r < 0) r = 0;
else if(r > 255) r = 255;
if(g < 0) g = 0;
else if(g > 255) g = 255;
if(b < 0) b = 0;
else if(b > 255) b = 255;
bi.setRGB(x, y, new Color((int)r,(int)g,(int)b).getRGB());
}
}
Basically it applis a matrix. Now, to apply a Gaussian filter over it, you need a matrix. With testing (using the program this came from) a 3x3 is about right, 2x2 looks good too..
a 3x3 has these values:
0.0625, 0.125, 0.0625
0.125, 0.5, 0.125
0.0625, 0.125, 0.0625
Now basically, you have a 3x3 template you put over each pixel. Take all the R values for pixel P.
you have (0.0625*P(x-1)(y-1)) + (0.125*P(x)(y-1)) + (0.0625*P(x+1)(y-1))... and so on. Thats just the top row.
Am I making sense? The matrix is just a weighted average of the surrounding pixels. The problem is, when you get to the edge.. The easiest way to get around it is lose 1 pixel off the edge of the image.. There are techniques but I dont know them.
If you want a better explanation, lemme know!