ExifTool Forum

ExifTool => Newbies => Topic started by: RSenior on January 23, 2015, 11:42:18 AM

Title: Exporting pixel temperatures from FLIR images
Post by: RSenior on January 23, 2015, 11:42:18 AM
Hello,

I apologise in advance for being a complete amateur here.

In the not-to-distant future I'm going to have really quite a lot of images taken with a FLIR E40 camera, and I would really like to avoid having to open each image in FLIR tools in order to export the temperature measurement of each pixel to a csv, where I can actually see and analyse the data. I've been trawling through the internet (mostly this forum!) to see if it would be possibly to speed up this process. I got as far as these equations here: https://exiftool.org/forum/index.php/topic,4898.msg23944.html#msg23944 and I seem to be able to extract all the variables required using ExifTool, except the actual raw data! I'm sure I'm being an idiot, but if I try to extract the "RawThermalImage" I get lots of gibberish.

I would love to try the script in that link, but I'm using Windows so not sure how to proceed. My brain is frazzled - I'm only a mere biologist! Please help  :o
Title: Re: Exporting pixel temperatures from FLIR images
Post by: Phil Harvey on January 29, 2015, 07:12:16 AM
You should extract the RawThermalImage to a file, which may be done like this:

exiftool -rawthermalimage -b -W %d%f_thermal.%s DIR

Where DIR is the name of a directory containing the original images.

- Phil
Title: Re: Exporting pixel temperatures from FLIR images
Post by: Tatuy on February 02, 2015, 11:52:19 PM
You hare the best, Phil.
But... where is the color?   :(
Title: Re: Exporting pixel temperatures from FLIR images
Post by: Phil Harvey on February 03, 2015, 07:35:10 AM
Adding a colour palette to the image is fairly involved.  I think you may find some details about this in this thread (https://exiftool.org/forum/index.php/topic,4898.0.html).

- Phil
Title: Re: Exporting pixel temperatures from FLIR images
Post by: edgar_eacg on June 24, 2016, 11:15:53 AM
Hello. First of all: Congratulations for your Development! It's a great Job.

Following the discussion of this thread, please... help me with a couple of questions
about getting row data.

1) Raw Data.
I've generated the same file contents with the command inthis thread (exiftool -rawthermalimage -b -W %d%f_thermal.%s DIR) and in https://exiftool.org/forum/index.php/topic,4898.msg23859.html#msg23859 (https://exiftool.org/forum/index.php/topic,4898.msg23859.html#msg23859) thread (exiftool Flir_Movie.seq -b -RawThermalImage > seq.tif, but the output was for my own purposes i.e. 'raw.dat').
But the numbers doesn't match according to my understanding. Let me explain:
a) When I input the command exiftool Flir_Movie.seq -flir:all -H -G I read the following in one line:
       [APP1] 0x0010 Raw Thermal Image: (Binary data 153804 bytes, use -b option to extract)
b) When I try to analyze the rawthermalimage with exiftool Flir_Movie.seq -b -RawThermalImage | exiftool -

ExifTool Version Number : 10.20
File Type : TIFF
File Type Extension  : tif
MIME Type : image/tiff
Exif Byte Order :Little-endian (Intel, II)
Subfile Type  :Full-resolution Image
Image Width : 320
Image Height : 240
Bits Per Sample : 16
Compression : Uncompressed
Photometric Interpretation      : BlackIsZero
Strip Offsets : 204
Samples Per Pixel : 1
Rows Per Strip : 240
Strip Byte Counts : 153600
X Resolution : 72
Y Resolution : 72
Planar Configuration : Chunky
Resolution Unit : inches
Image Size  : 320x240
Megapixels : 0.077

c) The quantity Strip Byte Counts: 153600 (which I understand as the raw data) makes sense to me since:
   16 (bits per sample/pixel) * 320 columns * 240 rows = 153600 (bytes of thermal image raw data)
d) The above quantity differs from the
    [APP1] 0x0010 Raw Thermal Image: (Binary data 153804 bytes, use -b option to extract) which in turn equals to the file size in the file properties with right-click within windows file explorer.
   So, 153804 - 153600 = 204 difference bytes
e) I opened the raw data file in a hex editor and observed that the first 204 bytes in the file are kind of heading information, so that I assume the above difference bytes are precisely this first 204 bytes in the file (please, see the output below, Am I right?
Offset(h)   00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 49 49 2A 00 08 00 00 00 0E 00 FE 00 04 00 01 00     
00000010 00 00 00 00 00 00 00 01 04 00 01 00 00 00 40 01     
00000020 00 00 01 01 04 00 01 00 00 00 F0 00 00 00 02 01
00000030 03 00 01 00 00 00 10 00 00 00 03 01 03 00 01 00
00000040 00 00 01 00 00 00 06 01 03 00 01 00 00 00 01 00
00000050 00 00 11 01 04 00 01 00 00 00 CC 00 00 00 15 01
00000060 03 00 01 00 00 00 01 00 00 00 16 01 04 00 01 00
00000070 00 00 F0 00 00 00 17 01 04 00 01 00 00 00 00 58
00000080 02 00 1A 01 05 00 01 00 00 00 BC 00 00 00 1B 01
00000090 05 00 01 00 00 00 C4 00 00 00 1C 01 03 00 01 00
000000A0 00 00 01 00 00 00 28 01 03 00 01 00 00 00 02 00
000000B0 00 00 00 00 00 00 10 00 10 00 10 00 48 00 00 00
000000C0 01 00 00 00 48 00 00 00 01 00 00 00 D4 45 D1 45
000000D0 CA 45 BD 45 B4 45 B3 45 B9 45 BE 45 BC 45 AC 45
000000E0 A5 45 B6 45 C9 45 C3 45 B7 45 B6 45 BD 45 C6 45
000000F0 CB 45 C5 45 BC 45 B7 45 BA 45 C0 45 C4 45 BB 45
00000100 B5 45 BC 45 C9 45 CE 45 CD 45 C8 45 C4 45 C9 45
00000110 C9 45 B5 45 A7 45 B1 45 C4 45 C6 45 C1 45 C0 45
f) Therefore the first pixel raw data is 45 D4 (because of the little endianess)
Please, help me with these ideas.

2) Frames in the .seq video
As you can see I'm using your file samples in the https://exiftool.org/forum/index.php/topic,4898.msg23859.html#msg23859 (https://exiftool.org/forum/index.php/topic,4898.msg23859.html#msg23859) thread (specifically talking about 'Flir_Movie.seq). You pointed this video is a short movie stream of 14 frames with 30 frames/sec (0,467 sec) in flir stream format *.seq. I verified the .seq file size and it is 2,278,792 bytes. Therefore, if I suppose the raw data obtained in 1) is that of just one frame then:
   153804 bytes (for just 1 frame) * 14 frames = 2153256
and
   2278792 bytes (seq file) - 2153256 = 125536 difference bytes
I think the above difference bytes are meta data of the seq file.
My question. How can I selectively get raw data from one specific frame in this sequence, say the eighth frame?

Title: Re: Exporting pixel temperatures from FLIR images
Post by: Phil Harvey on June 27, 2016, 07:45:40 AM
Quote from: edgar_eacg on June 24, 2016, 11:15:53 AM
e) I opened the raw data file in a hex editor and observed that the first 204 bytes in the file are kind of heading information

Yes.  This is a TIFF header.  Use the ExifTool -htmldump feature to reveal the structure of this file.

Quote2) Frames in the .seq video

I took a quick look at the FLIR code, but didn't see immediately how to step through a SEQ file.  There must be a length word somewhere that you can use to step to the next frame.  Currently ExifTool doesn't do this.

- Phil