对于我的项目,我正在尝试创建一个ImageThumbNail类,它可以获取任何图像并将其缩小到50x50。我的代码只会缩小图像,但它不能将像素缩小到50x50。
private static int[][] thumbNailSingleChannel(int[][] pixelArray) {
int rows = pixelArray.length/2;
int columns = pixelArray[0].length/2;
int[][] answer = new int[rows][columns];
for (int r = 0; r < rows; r++) {
for (int c = 0; c < columns; c++) {
answer[r][c] = pixelArray[r*2][c*2];
}
}
return answer;
}