enhancement: extract binary data from FLIR radiometric jpg

Started by tomas123, March 20, 2013, 12:49:46 PM

Previous topic - Next topic

bobdebaumeister

#165
Hello everyone
I'm new to this topic and therefore read and learned a lot in this forum, thank you for your hard work! Sorry for posting in this old topic but I think my question matches good here.

I work with a radiometric DJI Zenmuse XT which is based on the Flir Tau 2 I guess. My goal is to convert radiometric JPG files to RAW data and then calculate the temperature for every pixel (in the end I think with a python software).

I managed to calculate the temperatures according to posts:
Quotehttps://exiftool.org/forum/index.php?quote=27546;topic=4898.105;last_msg=44144
and
Quotehttps://exiftool.org/forum/index.php?quote=23972;topic=4898.60;last_msg=44144
from the raw values (counts exported as csv with ResearchIR Software) in excel and I get the same temperatures as the ResearchIR software shows.

My problem is that I could not export the raw values with exiftool according to post
Quotehttps://exiftool.org/forum/index.php?quote=24992;topic=4898.90;last_msg=44144
I tried:
.\exiftool -b -RawThermalImage DJI_0040.jpg | .\convert - gray:- | .\convert -depth 16 -endian lsb -size 640x512 gray:- raw40.png
where I get the following warnings but the file raw40.png is generated:
convert.exe: Unknown field with tag 63 (0x3f) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/994.
convert.exe: Unknown field with tag 6656 (0x1a00) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/994.
convert.exe: Unknown field with tag 6912 (0x1b00) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/994.
convert.exe: Unknown field with tag 7168 (0x1c00) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/994.
convert.exe: Unknown field with tag 10240 (0x2800) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/994.
convert.exe: Bogus "StripByteCounts" field, ignoring and calculating from imagelength. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/994.

and then:
.\convert raw40.png  -compress none raw40.pgm
But the raw40.png has some errors and therefore also the raw40.pgm file has wrong values compared to the count export from the ResearchIR Software.

I also tried to export the png directly with exiftool according to post
Quotehttps://exiftool.org/forum/index.php?quote=26101;topic=4898.90;last_msg=44144
.\exiftool DJI_0040.jpg -rawthermalimage -b > out.png
But then I'm not able to open the PNG or convert it.

It would be great if someone could help me with exporting the raw values. I used exiftool-10.75 and ImageMagick-7.0.7-22-portable-Q16-x64. The files are in the attachment.

Thank you.

Phil Harvey

Your attached version of out.png is corrupted somehow (did you use PowerShell? -- it can not be used for piping binary files).

But when I extract the RawThermalImage from DJI_0040.jpg I get a tiff file, not a png:

> exiftool ~/Desktop/DJI_0040.jpg -rawthermalimage -b | exiftool - -filetype
File Type                       : TIFF


The TIFF file does contain a thermal image that looks reasonable in GraphicConverter, but very dark in other utilities, and probably needs to be converted using a different technique.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bobdebaumeister

Thank you very much for your fast answer.
Yes I used PowerShell which was the problem. With cmd it works like it should and I get exactly the same raw data (out2.png and out2.pgm) as I can export from ResearchIR.

The image is directly out of the camera (set to rjpg) without any change. When I read all metadata exiftool -k DJI_0040.jpg I get the following output:

...
File Name                       : DJI_0040.jpg
...
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
...
Raw Thermal Image Type          : TIFF

and if I do the same as you exiftool -filetype DJI_0040.jpg
I get File Type                       : JPEG
so I don't know why you get TIFF for this. But the raw data export works perfect, thanks again.

Phil Harvey

Quote from: bobdebaumeister on February 02, 2018, 06:56:57 PM
When I read all metadata exiftool -k DJI_0040.jpg I get the following output:

Yes, but I was reading the metadata of the RawThermalImage, not the original JPEG (notice that I piped the output of one exiftool to another in my command).  So RawThermalImage is TIFF, not PNG, but it seems that it works for you even if you give it the wrong extension.

Run ExifTool on out2.png and you will see what I mean.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Jaime_Garcia

Hello, I am new to the group, I have a Flir Vue Pro camera, I would like to choose the temperature value in .TIFF format. What equation or method do you recommend to convert digital numbers to temperature values?

Phil Harvey

I would have to read through this long thread to answer your question.  I'm sure your answer is here somewhere, but I don't have time to find it for you.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tomas123

Quote from: Jaime_Garcia on March 21, 2018, 08:41:45 PM
I have a Flir Vue Pro camera, I would like to choose the temperature value in .TIFF format.

This is not the right forum for your question.
Ask here: http://www.eevblog.com/forum/thermal-imaging/

You might find a solution in my old link list
http://www.eevblog.com/forum/thermal-imaging/flir-e4-thermal-imaging-camera-teardown/msg342072/#msg342072

Also joe-c posts are good entry points:
http://www.eevblog.com/forum/thermal-imaging/freeware-software-for-thermal-analysis-thermovision_joec/

hebazxcv

Hello everyone
I have learned a lot so far from this forum, thank you for the hard work!. I am using FLIR T620 camera and my problem so far that the temperature obtained from converting the jpg image obtained from flir (downloaded from the sd-card) into tiff file using exiftool and then read it in matlab as a matrix and use all the mentioned equations in the forum with the calibration constants to convert it into temperature doesn't 100% matches the temperature obtained directly from reseachIr for the same image ( it has a deviation of less 0.2 degrees), I thought fist that the reason was from FLIR logo but I guess now it is not since the counts obtained from researchIR matches 100% the counts obtained from the tiff file.

And one last question, the only format that FLIR give for T620 camera is .jpg is it lossy?!

Again I would like to thank you for your time to read my question :).

hebazxcv

Hello everyone
Sorry for re-posting the question, please if I am in a wrong forum please direct me where I should post it. Thank you again.

I have learned a lot so far from this forum, thank you for the hard work!. I am using FLIR T620 camera and my problem so far that the temperature obtained from converting the jpg image obtained from flir (downloaded from the sd-card) into tiff file using exiftool and then read it in matlab as a matrix and use all the mentioned equations in the forum with the calibration constants to convert it into temperature doesn't 100% matches the temperature obtained directly from reseachIr for the same image ( it has a deviation of less 0.2 degrees), I thought fist that the reason was from FLIR logo but I guess now it is not since the counts obtained from researchIR matches 100% the counts obtained from the tiff file.

And one last question, the only format that FLIR give for T620 camera is .jpg is it lossy?!

Again I would like to thank you for your time to read my question.

StarGeek

I can't provide any information about your camera, but Jpegs are lossy.  There are some image manipulations you can do to a jpeg which are lossless (rotation in 90 degree increments, horizontal/vertical flips) and newer formats (JPEG 2000) which can be lossless, but otherwise, it will be a lossy format.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

If you are extracting the RawThermalImage as a TIFF then it could be lossless.  Honestly I can't help with a difference of 0.2 degrees since that seems much better than the accuracy of the device.  Approximations such as the amount of humidity in the air will change the calculation by more than that.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

hebazxcv

Thank you very much for your reply, yes 0.2 is very small compared to the accuracy of the camera, I will keep searching and if I find something I will post it here.

hebazxcv

Hello Again,
I have a question regarding the FLIR logo in thermal images. If the image is opened through FLIR software as ResearchIR the logo disappear, so how to check if they are using some kind of masking the logo pixels with the around pixels. In addition, when the image is converted to tiff using exiftool using RawThermalImage commend it has the same 16 bit data as from ResearchIR is that mean the logo pixels is masked with the around pixels as well. And would that be applicable for the color scale in the image or it will be different.

Phil Harvey

I think this question is better asked in the eevblog forum that tomas linked.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).