gtatters / Thermimage

R Package for working with radiometric thermal image files and data
GNU General Public License v3.0
164 stars 41 forks source link

Does the library work with files other than FLIR? #16

Closed giamo152 closed 3 years ago

giamo152 commented 3 years ago

Can the library work with image file other than FLIR, like those generated by the DJI camera? I get such issue when I try processing them.

image

gtatters commented 3 years ago

these functions rely on exiftool's conversion to extract the raw image data, and unless exiftool has that capacity, then Thermimage will not. the package was designed mainly to work with FLIR files since the raw data file format has been worked out for FLIR. Other companies are less transparent.

gtatters commented 3 years ago

if you don't mind sharing a sample file, I can at least look at it to advise?

giamo152 commented 3 years ago

Thank you so much for this dedication.

DJI

gtatters commented 3 years ago

Hmm, it's a larger jpg than is warranted for the digital data in it, suggesting the raw data are stored somewhere in the file.

Through trial and error using ImageJ --> Import --> Raw and setting the import options to:

Screen Shot 2021-04-16 at 8 23 08 AM

(The offset value of 50000 I guessed at. No guarantee it is exactly correct and might change from image to image).

It is possible to extract the raw data from the file as:

DJI_file

But there are still challenges I cannot help with. Looks like the camera has purposely introduced random errors to add 2 pixels of noise throughout the image. And we don't know if the raw data represent the raw radiance captured by the camera, or if this is simply a 16 bit, lossless representation of temperature. I just don't know enough about this camera and if they aren't sharing their methods publicly, it makes it a challenge to decipher. FLIR files generally have unique calibration constants stored in them, allowing us to run the algorithm outlined in Minkina's book (I've cited in the package - look to the help for the raw2temp function).

nrontsis commented 2 years ago

There exist other open source software that apparently allow for analysis of DJI thermal photos. Unfortunately, they rely on closed-source binaries from DJI and on exiftools.

Is there any intention to add support to this repo for DJI in a similar manner? I understand that DJI might not be as open as FLIR in their format, but supporting only hardware from a similar single manufacturer does not promote "openness" either.

Either way, thanks for all the amazing work done in this repo.

gtatters commented 2 years ago

First question: What's DJI?

Anyhow, this thread was regarding certain types of FLIR images that have regular spacing of contaminating info. I've been making some progress on figuring that out, but not enough to post any updates yet.

And, no there isn't any plan at the moment for Thermimage to work with other closed source binaries.

nrontsis commented 2 years ago

First question: What's DJI?

It's the largest consumer drone company in the world They have several drones with thermal cameras, like this one.

gtatters commented 2 years ago

Ah, Thermimage is a one person operation, and FLIR is the industry giant for research grade thermal imaging so this project was to enable research in my lab primarily. Given the distances that drones fly at, accurate thermal imaging might be a challenge. Anyhow, deciphering how every company stores info in their digital files takes group effort. I have had help from the Exiftool author as well as from EEVBLOG where you might want to share sample images where other electronic enthusiastics might be able to sleuth out how the data are encoded.

nrontsis commented 2 years ago

The ExifTool author has already added (partial?) support for DJI thermal "R-JPEG" images to ExifTool >= 12.15.

What remains unclear, at least to me, is what exactly each parameter extracted by ExifTool means and how the calibration and raw data are mapped into temperatures.

Anyhow, this thread was regarding certain types of FLIR images that have regular spacing of contaminating info.

I thought that the thread was DJI related, as per the author's original message:

Can the library work with image file other than FLIR, like those generated by the DJI camera?

gtatters commented 2 years ago

check out the help for the raw2temp function, I cite a source that explains it. This is FLIR's algorithm. I have no idea what algo DJI is using if they haven't published it. I guess we should beware of non-open source files since we don't know how they're processing the raw data.

gtatters commented 2 years ago

but i'll have to see the new version of exiftool. can't really do this, I'm in the middle of busy teaching with constant switching between online and face to face. this is a volunteer project.

nrontsis commented 2 years ago

Thanks for the info I will try to take a look.

I'm in the middle of busy teaching with constant switching between online and face to face. this is a volunteer project.

I appreciate that. Thanks for all the time spent in the project so far.

gtatters commented 2 years ago

So, I started this discussion last year on eevblog and JimM helped me out, but I honestly haven't finished working on it, and still need to respond to questions he asked me!

https://www.eevblog.com/forum/thermal-imaging/radiometric-jpg-ats-file-formats/msg3664963/#msg3664963

I also started a perl script that does some of the coding, but it's not my expertise, so I am still struggling with these R-JPEG files. They are basically raw radiance data in 16 bit format I think, but the algo used to convert to temperature isn't the same as what I have in the raw2temp function.