I have unraveled the fix that Seek put in to correct for the edge gradient problem.

Essentially they use any shot of a flat surface to calibrate a correction matrix which is applied to all subsequent images.

This is done by taking blocks of sixteen pixels and calculating the average value.

These average values are again grouped into blocks of sixteen and the range between the highest and lowest value determined. This range is used to determine if the image is a flat surface to be a basis for updating the calibration.

The blocks of average values are again averaged, to get a relatively crude map of the image.

To create the correction matrix a full image is created by interpolating out the crude double averaged values. 7/8ths of the correction matrix is the previous value, 1/8th is the new interpolated values. This low pass filter prevents any glitches from having too much impact.

The corrected image is created by subtracting the correction matrix from the original.

To properly document this I have created an Octave/Matlab script. The script is not an exact reproduction of Seek's code but shows the algorithm which was used.

To get data into Octave I adjusted Seek_2.0.py by Cynfab to export a Matlab data file, I couldn't figure out how to work with the generated PNG images.

Source code, including invocation instructions, are on github:

https://github.com/lod/seek-thermal-documentation/tree/master/scripts/thermal_gradient