所以我试图将图像划分为64个块,但是索引超出范围。
到目前为止,这是我的代码:
double matrix[][] = new double[8][8];
int height = (int)(img.getHeight() / 8d);
int width = (int)(img.getWidth() / 8d);
for(int i = 0; i < 8; i++)
{
for(int j = 0; j < 8; j++)
{
int color = 0;
for(int x = 0; x < height; x++)
{
for(int y = 0; y < width; y++)
{
color += img.getRGB(i * x, j * y);
}
}
matrix[i][j] = color / (height * width);
}
}
我应该如何处理奇数大小的图像?