PureEngineering/LeptonModule — pull request #3 by adgriff2 (2014-10-04 16:04:46+00:00)
Title: Corrected implementation of PGM image format that seemed incorrect 

Pardon any errors - first time using github

The previous implementation of the PGM image format had a hard coded 255 max val in the header. However, the lepton can output an unsigned 14 bit int. (0..16383) This resulted in some image viewers refusing to open the file, but others displayed the image but rolled over every 255 counts. This rollover is why cool backgrounds appeared hot.

![image_rotate](https://cloud.githubusercontent.com/assets/7536356/4516044/01cd387e-4bdf-11e4-9430-09882f095202.png)

Instead of hard coding the real upper limit of 16383 (which would normally have very low contrast), I chose to scan the image and find the min and max values. The minimum is subtracted from the image and the max-min is set as the new max. This allows for a high contrast image without rollover. I believe I remember reading somewhere that the lepton already calculates the min/max and it's available over I2C, but scanning the image myself seems to work fine.

Transfer function now returns frame number
Replaced 5000 for loop with a while loop that exits when frame number 59
Removed printing image integers to the terminal (very slow)