Normal map from a height map
Builds a normal map with an own 3×3 Sobel operator over a height map: two kernels give the Gx and Gy slopes, a normal vector is formed from them, normalised and encoded into RGB as (n·0.5+0.5)·255. Edges can be clamped or wrapped. The grid size, average and maximum slope, flat pixel count, the centre pixel, the blue-channel histogram and the first map rows are shown, and the map itself is returned as PPM P3.