我原本期望输出应该仍然是黑白(应用灰度后的图像),但模糊效果......我现在正用红橙色图像...任何建议?
public void applyGaussianBlur(int[][] rgb){
int kernelWidth = 3, kernelHeight = 3;
float kernel[][] = new float[kernelWidth][kernelHeight];
float sigma = 3.5f, radius = 1.0f;
float sum = 0;
for(int x = 0; x < kernelWidth;x++){
for(int y = 0; y < kernelHeight; y++){
kernel[x][y] = (float)((1/(2*radius*sigma*sigma)) * Math.exp((-(x*x+y*y))/(2*sigma*sigma)));
sum+=kernel[x][y];
}
}
for (int j = 1; j < width-1; j++){
for (int m = 1; m < height-1;m++){
sum += (rgb[j-1][m-1] * kernel[0][2]);
sum += (rgb[j-1][m] * kernel[0][1]);
sum += (rgb[j-1][m+1] * kernel[0][0]);
sum += (rgb[j][m-1] * kernel[1][2]);
sum += (rgb[j][m] * kernel[1][1]);
sum += (rgb[j][m+1] * kernel[1][0]);
sum += (rgb[j+1][m-1] * kernel[2][2]);
sum += (rgb[j+1][m] * kernel[2][1]);
sum += (rgb[j+1][m+1] * kernel[2][0]);
rgb[j][m] = Math.round(sum/9);
sum = 0;
}
}
}