Converting Embedded DAT to JPG

Started by phoenix401, November 15, 2016, 01:45:08 PM

Previous topic - Next topic

phoenix401

Hello,

I am currently writing an Android application that uses a FLIR One to take a BlendedMSXRGBA8888Image and I'd like to be able to extract the embedded visible image in a batch procedure  that runs in post (this actually works fine from images that we get from iPhones but not Android devices). I came across this post https://developer.flir.com/forums/topic/how-to-obtain-thermal-image-and-edges-from-blendedmsxrgba8888image/ and my results are similar using the following commands:

exiftool -emb* FLIROne-2015-01-16-14-11-22-0500.jpg
Embedded Image Width            : 480
Embedded Image Height           : 640
Embedded Image Type             : DAT
Embedded Image                  : (Binary data 921600 bytes, use -b option to extract)

exiftool -b -EmbeddedImage FLIROne-2015-01-16-14-11-22-0500.jpg > test.jpg


However, this results in an Invalid Image (and the binary data size is huge). The original author mentioned opening the files in FLIR Tools, which does work and allows me to extract the image... but I have datasets of hundreds of images and this isn't a feasible for me. I am curious if anyone has encountered this issue and might have a solution?

Cheers.

Phil Harvey

The embedded image in your FLIR file is a raw binary image:

> exiftool ~/Desktop/FLIROne-2015-01-16-14-11-22-0500.jpg -embeddedimage'*'
Embedded Image Width            : 480
Embedded Image Height           : 640
Embedded Image Type             : DAT
Embedded Image                  : (Binary data 921600 bytes, use -b option to extract)


You can use ImageMagick's "convert" utility to convert the raw binary image to a viewable format.  With this, the following command will create a PNG image (a.png) from your FLIR file:

exiftool FLIROne-2015-01-16-14-11-22-0500.jpg -embeddedimage -b | convert -size 480x640 -depth 8 rgb:- a.png

- 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 ($).

phoenix401

#2
Oh, wow. Thanks Phil!

I am curious about the difference in color of the image as the output still doesn't match the version that comes out of FLIR Tools; is the output in some different color space? YCbCr? I also noticed that not only is the aligned visible image available but all the full visible image is also available and access to both would be really helpful! I've attached some example images.

PH Edit: Removed large file previously posted

Phil Harvey

#3
Ah yes.  Change "rgb" to "ycbcr" in the convert command.

The fullphoto you posted is 480x640, which is the size of the EmbeddedImage.  I suspect that this image is cropped somehow by FLIR tools to produce the aligned image.

- 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 ($).

phoenix401

Oh, ha! I didn't notice the image differences (to focused on the color space); thank you so much for the help!