}
double average = total / (height * width);
double gamma = (average - min) / (max - average);
Palette palette = new CorrectedMonochrome (min, max, gamma);
for (int row = 0; row < height; ++row) {
for (int col = 0; col < width; ++col) {
Color color = palette.getColor (samples[row][col]);
g.setColor (color);
g.drawLine (col, row, col, row); // putpixel
}
}