int num=0;
int num2=0;
int[][] maxnum = new int[width/10+1][height/10+1];
int indexwidth=0;
int indexheight=0;
for (int i = minx; i < width; i++) {
for (int j = miny; j < height; j++) {
//获得像素值
int pixel = BI.getRGB(i, j);
maxnum[indexwidth][indexheight]= maxnum[indexwidth][indexheight]+pixel;
num=num+1;
if(num==10){
num=0;
indexheight=indexheight+1;
}
}
num2=num2+1;
indexheight=0;
if(num2==10){
num2=0;
indexwidth=indexwidth+1;
//10*10区域的平均值
maxnum[indexwidth][indexheight]= maxnum[indexwidth][indexheight]/100;
}
}
indexwidth=0;
indexheight=0;
num=0;
num2=0;
//遍历 设置平均值
for (int i = minx; i < width; i++) {
for (int j = miny; j < height; j++) {
int pingjun= maxnum[indexwidth][indexheight];
BI.setRGB(i, j, pingjun);
num=num+1;
if(num==10){
num=0;
indexheight=indexheight+1;
}
}
num2=num2+1;
indexheight=0;
if(num2==10){
num2=0;
indexwidth=indexwidth+1;
}
}
图像倒是马赛克了,,但是感觉算法哪里有问题,。。因为马赛克的有点过。如下图,,原图是个风景画