Elektor_Mag_-_January-February_2021

([email protected]) #1
lektor January & February 2021 13

utive readings to avoid jumps in the colour mapping. Alternatively,
it could handle the dynamics of the manner in which hot spots and
the background are separately displayed to bring the hot spots out
more clearly. There is plenty of scope for experts in machine learning
to deploy AI algorithms for pattern recognition, noise reduction and
data analysis.

As Figure 9 shows, the TFT display on the M5StickC shows the origi-
nal thermal image with the colour map that is used in the upper half of
the screen, while below the readings for the minimum and maximum
temperatures over all the pixels of the image (tMin and tMax) are
shown, as well as the calculated average value. These are shown in
hundredths of a degree (without a decimal point).

WiFi and server
So far everything has been running locally on the M5StickC without
any external connection. However, if we want to show the results on
a remote portable device or process the readings further, we need to

and L parameters remain constant. The HSL value is then converted
to RGB for output on the display.


The numerical values corresponding to temperatures from 0°C to 80°C
ranging from 0 to 8000 in steps of one-hundredth of a degree. We want
to normalise these to hue angles to values between 0 and 359. Since
the colour blue is naturally associated with cold and red with hot, it
seems that the sector of the colour wheel from 255° (a blue-green for
minimum temperature) to anticlockwise 315° (a dark red for maximum
temperature) would be ideal for the display. Shades of purple are not
generally associated with temperature, so we avoid using this sector of
the wheel. Of the possible 360 colour values we use 300 and skip 60.


The handy map() function used in Listing 2 first converts the tempera-
ture value into an angle in the 300° sector of the colour wheel anticlock-
wise from 315° to 15°. It then rotates this angle anticlockwise by 60°
in order to reach the desired range from 255° anticlockwise to 315°.
In order to reduce the rather high apparent noise level in areas of
constant temperature without hot or cold spots, a minimum offset
between both the minimum temperature and the maximum tempera-
ture relative to the average temperature of 500 units is enforced. This
means that the displayed colour range (the ‘magnifying glass’) has a
minimum range of 1,000 units, or 10 K. If this range were allowed to
become very small then tiny changes in the readings would show up
as violent changes in colour.


Apart from thi,s the full range of colours is always used to represent
the temperatures in the image. 255° on the colour wheel represents
the minimum temperature, running round (anticlockwise, don’t forget!)
to 315° for the maximum temperature.


Presentation on the display
In order to implement the magnifying glass function that converts the
actual range of readings to the available range of colours, the colour
conversion function takes the values tminRange and tmaxRange as
parameters (Figure 8). This only gives a relatively crude level of control
over the colours used in the display. A specialised algorithm could be
implemented to make the magnifying glass function more sophisticated.
This could adaptively adjust the range values over multiple consec-


Figure 8: The range of measurements is stretched to cover the spectrum of
available colours.

Figure 9: Thermal image as displayed on the first prototype.

Figure 7: The HSL colour wheel and the sector used for our display.

Free download pdf