Thursday, 13 March 2014

Choosing the appropriate colour palette for thermal imaging in animals

This might sound like a strange thing to write about, the choosing of a colour palette for a thermal image. Why be concerned about which colour to use? Isn't it just for presentation? It happens to be one of my pet peeves with thermal imaging and how people new to the field do not appreciate how a colour choice might enhance small differences in temperature and overemphasize something rather minor.

My reasons will be illuminated below, but suffice it to say it relates ultimately to contrast and detectability of different temperatures through the use of colour itself.

From a computational perspective these concerns are not important. Almost all thermal imaging devices actually provide a proper temperature estimate for each pixel on the screen and as the images are typically stored in proprietary format in 12 or 14 bit files, this is not a concern from a quantitative perspective.

However, images captured are eventually converted into a digital format that is easily visualized by others, typically a jpg, png, tiff or bmp file. When presented online, then, you have a colourised rendition of temperature that is essence a filter of the real data mapped onto a pre-existing spectrum. This spectrum of colours is referred to as a palette in most graphical software.

There are a number of palettes that you might find available on your thermal imaging camera:

Grey Gradient Iron Gradient Rain gradient Glowbow gradient Yellow gradient

From left to right, these palettes are described as: Greyscale, Iron, Rain, Glowbow and Yellow (terminology comes from FLIR™). Each palette 'translates' temperature into a specific colour, with cold colours at the bottom (typically darker colours) and warm colours at the top (typically lighter colours).

At first glance it might be tempting to choose the funkiest colours, since it looks 'pretty' (this is a common reaction I get from people when I show them thermal images). Indeed, for some purposes this is entirely appropriate. Some palettes were designed specifically to create a large contrast in colour intensity across a narrow range of temperatures.

People generally do not believe me until i demonstrate it, but I often prefer to use the greyscale palette when imaging animals in the field for the simple reason that it is easier to focus on edges. Although greyscale might not offer a large degree of contrast between similar temperatures, it is a simple, natural scale of intensity where black is the lowest intensity, white is the highest intensity and greys provide a gradient of intensities in between.

For presentation purposes and for publication purposes, however, a visually appealing colour might be appropriate (instead of greyscale). My own favourite palette is the Iron palette, as demonstrated in the following image of Yellow Crowned Night Heron from Galapagos:

Yellow Crowned Night Heron 22 to 32 Iron

Note how I have set the temperature range to go from 22 to 32C, where 22 is the lowest colour on the gradient and 32 is the highest. This maximizes the potential contrast of temperatures within the visible colour palette without saturating or eliminating any potential temperature.
So, why all the fuss about palette choice? Let's consider the same image as I've shown you above, but this time using 5 different palettes. I have purposely rescaled the image to range from 5 to 32C, which actually masks some of the potential colour differences but it also shows how the different palettes may obscure potential temperature differences.


Thermal Image Comparison

The picture above shows the yellow crowned night heron depicted using 5 different palettes. Inset line graphs depict the "intensity" of the gradient scale used in common units. All I did was import the images into ImageJ and drew a line down the gradient to obtain the "grey intensity" as a function of the colour palette. All palettes are compared in the lower right-hand graph to show how these different palettes translate "intensity" differently.

Although the human eye can certainly detect chromatic signals (i.e. different colours), the achromatic signals are what I am trying to highlight above. See how the different palettes show varying degrees of linearity and non-linearity. Clearly the greyscale gradient shows a monotonic decline in intensity, as you would expect for an achromatic response.

The other palettes however are not all the same as the greyscale. Sadly, my own favourite palette is shows a slightly curvilinear function with some intensities rising before falling again. The palette that comes closest to a greyscale, slightly monotonic decreasing palette is FLIR's Yellow palette.

Note how weird the Rain palette looks. The intensity rises and falls along the gradient itself. What this means is that your eye may be drawn to changes in achromatic signals in the colour palette and mistakenly consider them to be an incorrect temperature change. The Rain palette is an example of one of those favoured by people who initially play with thermal cameras. The images look striking, but my pet peeve about it is that it creates unnatural contrasts in colours that do not correspond to the actual temperature gradient. It also does not help that the beak and the back feathers look 'warm' because I am accustomed to yellow colours being warmer than red colours.

To drive home this point more clearly, I have converted every single image above to a greyscale image in Photoshop using the default greyscale convert tool:

Thermal Image Comparison Greyscale

For most of the palettes chosen (the first 4), the conversion to greyscale does not really obscure the image too much, but it still transforms the images. In other orders, darker greys clearly correspond to cooler colours, lighter greys to warmer colours. The exception is the Rain palette. When converted to greyscale it appears saturated in some places, the bird's image is nicely delineated (due to the steep contrast in intensity in places), but certain greys are repeatedly used that correspond to different temperatures. In other words, it is difficult to tell for certain what colour corresponds to what temperature.

So, the morale of the story? This may not be a problem if you have a colour printer or access to a computer screen to view your colour images, but not all journals will publish in colour, and not all people will view the work in colour (e.g. referees of your papers like myself who are given black and white versions of your manuscript and are left scratching their heads wondering what the images mean!), so I think it pays to consider the effect of palette choice on how others may interpret (or get confused by) your thermal images.

Personally, I usually use the Iron palette and it turns out to have a non-monotonic change in intensity along the gradient of temperatures, which means that there may be some error in a greyscale conversion from this particular choice. I guess I could choose a more forgiving palette, but I still like the colour option for presentations myself.

You could always opt for greyscale straight from the thermal imaging device itself, and then generate boring looking images! To each their own.

Saturday, 1 March 2014

Thermal Imaging Advice

It seems that about once a month, I am asked by colleagues, their students, strangers, or even my family about thermal imaging. Typically these requests come as a email for help in selecting a thermal camera, or simply in whether they could use a camera to address a question they are interested in. Given the length of time it takes to respond to every request, I am putting some advice on my blog here for future linkable reference (future edits may be employed). I struggled myself when I started this technique but I had the advantage that I had a camera to use and experiment with. Nevertheless, yet I am still far from being an expert in optics, electronics and the physics of imaging. However, I am going to write some commonly asked questions and answers below. This is by no means an advertisement for the company mentioned below. Indeed, given how unhelpful some sales reps have been from leading thermal imaging companies, I would not want this post to be construed as an advertisement for a particular company or device. Furthermore, perhaps in 10 years we will have infrared sensing contact lenses which might make much of this blog seem out of date!

What is thermal imaging?
Ok, well, no one really asks this question, but let's start with that. Thermal imaging makes use of a camera that uses a special kind of lens that is transparent to infrared wavelengths. An image of the environment the lens captures is detected by an electronic sensor and this digital sensor converts the image into a visual digital image, typically in a pseudo colour palette. See this wiki entry for an introduction: When I refer to infrared thermal imaging, I am usually referring to a camera based technology that capitalizes on the fact that all objects that are greater than absolute zero emit some form of radiation. As a biologist, I am lucky on multiple fronts. I am usually studying objects that are warm (between -20C to 40C), which is a relatively narrow range of radiative flux and thus works well with most instruments. Given this range of temperatures, I use cameras that sense long-range infrared wavelengths (8 to 12 μm) and have a camera capable of assessing ~0.03 to 0.04C differences. Realistically, this is a very small change in temperature that might not be biologically meaningful, but if used carefully, it is helpful to have such thermal resolution in the camera to ensure that images are as 'crisp' as possible:
IR 2009 06 08 0056
Another advantage to working with organisms is that most biological tissues have emissivities that are close to 1 (i.e. ~0.95-0.98). Unlike many metal objects that are 'shiny' and reflect infrared radiation, biological tissues behave in a manner that makes it easier to estimate temperature without having to be too worried about this mathematical correction. Yes, emissivity should be considered, but if you are measuring the same animal over time, the emissivity is not going to change since it is a fixed property of the object. Finally, as biologists, we're usually reasonably close to our animals so the effects of atmospheric attenuation of the infrared signal will be far less than a volcanologist who wants to stay 1 km away from an erupting volcano!

How much does a thermal imaging camera cost?
Many people ask me this same question when they seek to purchase a camera, and I rarely know what to say. We have purchased only two cameras in my lab, but I have used others in colleagues' labs around the world. I am most familiar with the FLIR SC 640 and my old Mikron 7515. Prices can range from as low as $2000 (for point and click cameras that have a very low image size of 60 pixels x 60 pixels) to as high as $50K for cameras with all the bells and whistles (640x480 pixels, great image capture capacity, software for analysis, ability to capture video etc)

Are they supposed to be so expensive?
Best to ask the sales reps. Personally, I think that sales reps are making a mint on thermal imaging cameras, and there are so many options out there where a difference of $20k doesn't seem to make much sense to me (i.e. cameras both have the same specifications in terms of physics and sensing, but one camera is more ergonomically appealing). My advise is to make sure sales reps let you try the camera out, take a picture of yourself at a distance that you might normally use the camera in the field and send it to me if you want my advice.

Can I zoom in to view objects?
Standard thermal cameras are sold with a default lens with a fixed FOV. Due to the extreme cost of building the infrared transparent lens, it is not often you will see a telephoto lens, and when you can get your hands on one, they typically provide you with an ability to change the telephoto range by 2X or 4X. This is a true optical zoom, so it definitely has an advantage in the field to have a telephoto lens, but it is difficult to find lenses that are adjustable in FOV, so once you put it in place you have to image your environment with the new lens on and cannot quickly go back and forth between the two lenses. Prices of these lenses are incredibly expensive. Usually above $4000, sometimes as high as $10000. I don't have one for my FLIR. Maybe one day I will. You can't just put any old telephoto on the camera. Normal digital camera lenses will not work since they are made with normal glass that is transparent to visible light, but absorb infrared radiation. Also, the camera software needs to know what lens is attached as it does influence the focal length and IFOV calculations which influence the estimated pixel temperature and final image.

Can I rent one?
Some companies will rent them to you. You'd have to contact sales reps. Usually rental gets pricey. With a month of renting, you'd be almost able to buy a cheap camera on your own.

Can I borrow your camera?
I have often joked that my motto is, "Have thermal camera, will travel". So far, I have done this a lot and it is fun and intellectually fulfilling. What that really means is that I won't loan it out, unless it is used by myself or my students/collaborators. Sorry.

Can I see through glass or plexiglass with the thermal camera?
No. Thermal Cameras cannot view through glass or plastics that are transparent in the visible range. In fact this presents some challenges when trying to use aquaria or image at a zoo. Just because our eyes can see an object, doesn't mean that the infrared radiation is passing through. You can, however, look into purchasing a IR transparent window of material from certain optics manufacturers. I recently purchased one from a very friendly and helpful company in China. They grew up the germanium tetrachloride crystal, polished and cut it into a 10 cm wide circular window of glass (~4mm thick) and coated it with a material that further helps ensure most IR passes through it.



How close should I be in order to detect a bird or small animal of interest?
Realistically, it is best to simply borrow a camera and try this out empirically to see what you can capture. However, you can do some quick calculations if you have certain critical information from the camera manufacturer, such as the IFOV (instantaneous field of view). With this value, you can calculate a maximum distance to target to detect a 'spot' in space of a certain size:

Distance to Target (D) X IFOV (R) = Measurement Spot Size (S) ( Source)

So, let's say you want to measure an entire songbird, which we will just approximate as a 10 cm high object. Input the 10 cm as the minimum spot size (S) and look up the IFOV for your thermal camera (mine is 0.00065 radians), and you can calculate the maximum distance to the target (D):

D = S / R = 10 cm/0.00065radians = 15384 cm or 153 metres!

Wow. That's a long way away. Unfortunately what this solves is the distance required to reach the spatial resolution ability of the thermal imager, and essentially your bird would occupy the equivalent of 1 pixel on the camera's sensor!

So, instead let's define the spot size represent an object that is 1/40th the size of the object of interest. Practically speaking, the bird would now occupy 40 pixels high which would look like a computer sprite from 1980s video games, but at least some aggregate temperature could be measured and possibly even regional parts of the body surface could be examined.

Solving D for this would lead to 3.8 metres, which means that you could be ~4 metres away from a bird and it would occupy a space on the detector of your imager 40 times higher than the minimum spot size.

Of course, the image still needs to hit the sensor and be converted into an image for storage and analysis purposes, so now the concept of digital resolution becomes important.

A 640x480 pixel thermal imaging source is an excellent resolution at present, but many of the inexpensive options for thermal imaging provide only 60x60 or 120x120 pixels for the image captured. Since the field of view is determined by the lens, a lower digital resolution captures the same image as a camera with a high resolution, but the final image created is far lower in quality.

Thus, if you think back to the bird in the field on a tree, with the 640x480 camera, it might occupy ~40 pixels high at that distance, which at least you can zoom in and analyze on a computer. Not very pretty, but minimally workable. If you had only a 60x60 resolution camera (nice and cheap), the image would be much more pixelated, since there would be approximately 10 fewer pixels per spot area.
Mouse 640x480
A mouse imaged with a FLIR SC660 (24o lens, distance 0.5 m, IFOV 0.65 mead)
Mouse 80x60
Same image above converted to a lower resolution, but blown up to the same size for comparison. One advantage of the higher digital resolution is that you can rely occasionally on simply digital zoom to focus in on an animal in the field, since the higher overall resolution affords you the chance to do that. Realistically speaking, I prefer to be no more than 3 metres away in the field, and 1 metre away if making measurements with domestic or laboratory animals.

What problems would I encounter with using a thermal camera in the field?
Fast moving animals are difficult to image. The minimum response time of my thermal camera is 8ms (this might be related to restrictions on the non-military use of cameras? see http://en.wikipedia.org/wiki/Infrared_imaging#cite_note-23), which would be the equivalent of a shutter speed setting of 1/125th on an SLR camera. Anyone who has tried to capture fast moving objects knows the value of a fast shutter speed, and usually you want to have capture settings >1/500 or 1/1000. So, for example, say you wish to capture the wing beat of a hummingbird using a video frame rate of 1/30th second, here is what it would look like:
Hummingbird 30
In contrast, pushing the camera to the max by capturing at 120 frames/second yields:

Hummingbird 120
In both cases, you still do not obtain a sharp depiction of the wings, which appear as blurry streams as the wing beat frequency of the hummingbird is not that much slower than the frame capture rate of the thermal camera. Related to the time limits is the challenge of focussing. My thermal camera doesn't have instantaneous focus, so when objects are moving quickly within the field of view, it is difficult to keep things in focus. Sometimes you have to anticipate where the animal will be and focus on that area and simply move the camera until the bird is in focus. A poorly focussed image isn't just an inconvenience, but it can affect your temperature estimates, primarily because focusing changes the focal plane and assumptions involved in the estimate of temperature depend on knowledge of the spatial resolution of the image in focus.

What about time lapse?
Time lapse is good if you have access to a tripod and software for capturing images. The typical software that can do this will be ~$5000 from the company. The occasional camera has built in capacity to capture images at intervals, but this is usually very slow when in the field. When capturing time lapse, it is still essential to capture images in appropriate file format. It might be tempting to use the 'camera' option that allows you to capture what is really a video (NTSC, PAL). The problem with this is that any temperatures become very difficult to analyze or assess, since this video file is not digitized any longer and pixels in the video do not retain the digitized thermal information required for adequate analysis.

Why would I use a thermal camera?
To estimate heat loss and thus use the imager to estimate total metabolic expenditure in the field? - requires some time spent investigating physical equations and models to calculate heat loss. To estimate the use of certain parts of the body as thermal windows (vascular thermal radiators). - might only require you estimate the temperature of the surface of interest, along with surfaces that are not expected to change. Usually requires you have a good measurement of air temperature, wind speed, relative humidity, solar radiation. To find animal roosting sites at night - many birders ask me about this. I haven't actually tried this too much, but it should be possible, provided you have a good idea of where to start and you can get within the minimal distance required to see an individual bird. Use of information above comes with a warning: these are estimates, and 'ball park' impressions. Potential users of infrared thermal imaging should always consult with the manual for their particular imager for specific information regarding the use and utility of their camera.

Monday, 21 October 2013

Tears for Galapagos

I did not have much chance to post anything while I was away this trip, probably because I was having too much fun seeing sights I didn't see the last time. However, as I am on the long trip back home, I thought I'd post tears for departing Galapagos. This was a site on Isabela island. Earlier in the 20th century, the ecuadorians used to have a penal colony on Isabela island where they had prisoners build and rebuild a pointless wall of stones. I can't imagine the frustration and agony they went through carrying and laying stone after stone in the heat of the tropical sun.

DSC 0654

DSC 0661

Saturday, 19 October 2013

Holy Lekking Lizards!

I haven't had much time to get near an internet connection this past week. However, about 900 images on my new camera, and about 300 thermal images has given me a lot to sift through on this trip. I thought this was funny. The sign below points to the Playa del Amor (Lover's Beach).

DSC 0375 Evidently, marina iguanas can read signs since this is where all the lekking males hang out:

DSC 0599 I can't really post any videos (since it's not breeding season here anyway, but I also can't upload large files), so I will cross post to someone who has written blogs on this: http://zoologyweblog.blogspot.com/2012/07/marine-iguana-lek.html I can see why my host here is fascinated with marine iguanas. Easy to approach and fascinating to watch for hours at a time. Unfortunately, my tourism trips got in the way of iguana watching.

Monday, 14 October 2013

Mission Impossible

So, I am currently being hosted by the wonderful folks at the Isabela Oceanographic Institute (picture below).
DSC 0421

The purpose of the trip here is primarily for fun, but my idea of fun involves observing nature. So, I've brought the toys to help me do so (i.e. thermal camera). The IOI serves as the base of operation for a semester long field course where students from the University of Miami get credit for learning herpetology, ecology, conservation, community involvement and basic research techniques. The coordinator of the course was kind enough to allow me to 'tag along' provided I share some thermal images for the sake of education. Sounds like a good deal to me. The location is a former catholic mission, so the accommodation for the profs is quite nice. The director of the IOI has completely refurbished the place and we have a kitchen, classroom, dive room (where all the diving gear is stored) as well as easy access to the beach and the marine iguanas. The impossible part of this mission? I just left my 3rd year students back in Canada for their reading week (where they are furiously working on a lab report for my course), but I have to mark a part of their midterm while I am down here. That's rather impossible to do with all the wildlife distractions…I wonder if I'll be grading them on the plane ride home.

Sunday, 13 October 2013

Arrived in Isabela

Long distance flight is for chumps. I don't know how birds do it. Not to sound like I'm complaining, but it really is a long journey to get to Isabela Island from Toronto. Not helped when bird gets sucked into the plane engine at JFK airport and causes a delay in your flight…I would like to take a moment to reflect on that poor bird and what happened to it. Honestly, though…take a look at where JFK airport is located! It's right on the ocean near a wildlife refuge!! Duh, of course there will be birds flying nearby. Anyhow, I think the theme of some future blog posts will be the stupidity of human/animal interactions, and I'm not talking about the animals. We build things right in front of natural animal corridors and expect animals to change? Anyhow, that delayed me a day in NY, then I arrived in Guayquil, Ecuador and had another overnight delay to catch the morning flight to Baltra, Galapagos. At this stage, I lucked out…took the bus, then boat, then taxi, then another boat and arrived 5 hours later in Isabela.

DSC 0125

Once I saw the Pelicans, I knew I was in the right place! I'm also trying out my new camera, a Nikon 5200D with 18-55 and 55-300 mm lens. So far, amazing pics!! Stay tuned, I might be able to upload them, assuming the internet works here.

Thursday, 10 October 2013

Wish me luck!

Starting up the blog again here…just a brief post, but I am heading back to Galapagos, so what better time to write. I don't think anyone wants to hear about what I have to say about zoology and physiology in Niagara region on a regular basis. Anyhow, I'll be spending 11 days with the Isabela Oceanographic Institute tagging along a field course run by the University of Miami. I'll try to post pictures or musings. The (slightly) comical aspect of this trip is that I found out before my trip that my status in Galapagos is uncertain. Apparently the authorities at the airport did not have a record that I left in May, which implies that I have been hiding out somewhere on the Galapagos without permission. As I sit here in the airport at Toronto waiting for my flight, I have just had word from the officials in Galapagos that my paperwork has finally reached the authorities. It's déjà vu all over again. This is precisely what our last trip was like, when we received our visas via email on the flight down. Brinkmanship is the name of the game here. Anyhow, wish me luck. Hopefully my next post will be from near the equator.