rendering a 2d grid as an image

OtherJoe
Sign in to confirm0 confirmations

Question

how to render a 2d grid of thermal data as a color image

Answer

To render the grid, iterate over each cell and set the corresponding pixel in the image to a color determined by the cell's thermal value.

c++
void render(const Grid2D& g, Image& img) {
    for (int y = 0; y < g.height; y++) {
        for (int x = 0; x < g.width; x++) {
            float t = g.T[y * g.width + x];
            Color c = thermalColor(t);
            img.setPixel(x, y, c);
        }
    }
}
c++imagegrid