我正在尝试在彩色图像上实现直方图/图像均衡。我不确定我是否正确实现了它,因为每次我将它应用于位图图像时屏幕都会变黑。该算法称为histogram equalization
。
我的代码中进行直方图均衡计算的部分:
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
A = (pixels[index] >> 24) & 0xFF;
R = (pixels[index] >> 16) & 0xFF;
G = (pixels[index] >> 8) & 0xFF;
B = pixels[index] & 0xFF;
R = Math.round(((R - cumR[minR]) / (cumR[maxR] - cumR[minR])) * 255);
G = Math.round(((G - cumG[minG]) / (cumG[maxG] - cumG[minG])) * 255);
B = Math.round(((B - cumB[minB]) / (cumB[maxB] - cumB[minB])) * 255);
returnBitmap.setPixel(x, y, Color.argb(A, R, G, B));
++index;
}
}
应用我的代码后,图像显示为黑色,为什么不显示均衡图像?