gtatters / ThermImageJ

ImageJ functions and macros for working with thermal image files
Other
43 stars 6 forks source link

Import JPG or TIFF from Lepton 3 #5

Closed AndreasKoerner closed 3 years ago

AndreasKoerner commented 3 years ago

Hi,

First of all, thank you for creating this amazing tool.

I have installed everything and it looks alright. I am taking pictures with a Flir Lepton Application and a Flir Lepton 3 160HX120V with the PureThermal board. I export them as JPGs or Raw TIFFs.

Lepton_Capture Lepton_Capture_TIFF.zip

When I import them in Fiji I get the following error:

luts (g) array[54] lCmds (g) array[54] palettetypes (g) array[11] defaultpalette (g) "Grays" thermlCmds (g) array[11] ImportCmds (g) array[8] lut (g) -1 lutdir (g) "C:\Users\ADMINI~1\DOCUME~1\Fiji.app\luts\" list (g) 0 color (g) 0 colors (g) array[6] PR1 (g) 17998.5290 PR2 (g) 0.0151 PB (g) 1453.1000 PF (g) 1 PO (g) -5854 ATA1 (g) 0.0066 ATA2 (g) 0.0126 ATB1 (g) -0.0023 ATB2 (g) -0.0067 ATX (g) 1.9000 E (g) 0.9500 OD (g) 1 RTemp (g) 20 ATemp (g) 20 IRWTemp (g) 20 IRT (g) 1 RH (g) 50 imagewidth (g) 640 imageheight (g) 480 magicbyte (g) "02008002e001" frameinterval (g) 0.0333 imagetemperaturemin (g) -20 imagetemperaturemax (g) 60 perlscriptpath (g) "C:\Users\ADMINI~1\DOCUME~1\Fiji.app\scripts\" desktopdir (g) "C:\Users\Administrator\Desktop\" perlsplit (g) "C:\Users\ADMINI~1\DOCUME~1\Fiji.app\scripts\split.pl" OS (g) "Windows 10" perlpathOSX (g) "/usr/bin/" exiftoolpathOSX (g) "/usr/local/bin/" exiftoolOSX (g) "exiftool" ffmpegpathOSX (g) "/usr/local/bin/" perlpathLinux (g) "/usr/bin/" exiftoolpathLinux (g) "/usr/bin/" exiftoolLinux (g) "exiftool" ffmpegpathLinux (g) "/usr/bin/" perlpathWindows (g) "c:/Perl64/bin/" exiftoolpathWindows (g) "c:/Program Files/ExifTool/" exiftoolWindows (g) "exiftool.exe" ffmpegpathWindows (g) "c:/FFmpeg/bin/" cmd "Import FLIR JPG" perlpath "c:/Perl64/bin/" exiftoolpath "c:/Program Files/ExifTool/" exiftool "exiftool.exe" ffmpegpath "c:/FFmpeg/bin/" filepath "C:\Users\Administrator\Pictures\LeptonCaptures\Lepton_Capture.jpeg" flirvals array[19] printvalues "No" printvalues "No" filepath "C:\Users\Administrator\Pictures\LeptonCaptures\Lepton_Capture.jpeg" perlpath "c:/Perl64/bin/" exiftoolpath "c:/Program Files/ExifTool/" exiftool "exiftool.exe" ffmpegpath "c:/FFmpeg/bin/" flirvals "Image Height : 120 | Image Width : 160 | File..."


Error: Index (-1) is outside of the 0-255 range in line 2262: (called from line 769) (called from line 2739)

    PR1 = parseFloat ( substring ( flirvals , indexOf ( flirvals , ":" , indexOf ( flirvals , "Planck R1" ) <)> + 1 , index...

I am a bit lost. Am I doing something wrong or is there another issue I am not aware of?

AndreasKoerner commented 3 years ago

When I use the Convert JPG macro I get this:

Memory 88MB of 24384MB (<1%) nImages() 1 getTitle() "Lepton_Capture.tiff" luts (g) array[54] lCmds (g) array[54] palettetypes (g) array[11] defaultpalette (g) "Grays" thermlCmds (g) array[11] ImportCmds (g) array[8] lut (g) -1 lutdir (g) "C:\Users\ADMINI~1\DOCUME~1\Fiji.app\luts\" list (g) 0 color (g) 0 colors (g) array[6] PR1 (g) 17998.5290 PR2 (g) 0.0151 PB (g) 1453.1000 PF (g) 1 PO (g) -5854 ATA1 (g) 0.0066 ATA2 (g) 0.0126 ATB1 (g) -0.0023 ATB2 (g) -0.0067 ATX (g) 1.9000 E (g) 0.9500 OD (g) 1 RTemp (g) 20 ATemp (g) 20 IRWTemp (g) 20 IRT (g) 1 RH (g) 50 imagewidth (g) 640 imageheight (g) 480 magicbyte (g) "02008002e001" frameinterval (g) 0.0333 imagetemperaturemin (g) -20 imagetemperaturemax (g) 60 perlscriptpath (g) "C:\Users\ADMINI~1\DOCUME~1\Fiji.app\scripts\" desktopdir (g) "C:\Users\Administrator\Desktop\" perlsplit (g) "C:\Users\ADMINI~1\DOCUME~1\Fiji.app\scripts\split.pl" OS (g) "Windows 10" perlpathOSX (g) "/usr/bin/" exiftoolpathOSX (g) "/usr/local/bin/" exiftoolOSX (g) "exiftool" ffmpegpathOSX (g) "/usr/local/bin/" perlpathLinux (g) "/usr/bin/" exiftoolpathLinux (g) "/usr/bin/" exiftoolLinux (g) "exiftool" ffmpegpathLinux (g) "/usr/bin/" perlpathWindows (g) "c:/Perl64/bin/" exiftoolpathWindows (g) "c:/Program Files/ExifTool/" exiftoolWindows (g) "exiftool.exe" ffmpegpathWindows (g) "c:/FFmpeg/bin/" cmd "Convert FLIR JPG(s)" perlpath "c:/Perl64/bin/" exiftoolpath "c:/Program Files/ExifTool/" exiftool "exiftool.exe" ffmpegpath "c:/FFmpeg/bin/" whichtype "File" filelist array[1] dirpath "C:\Users\Administrator\Pictures\LeptonCaptures" convertfolder "C:\Users\Administrator\Pictures\LeptonCaptures\converted" i 1 filepath "C:\Users\Administrator\Pictures\LeptonCaptures\Lepton_Capture2.tiff"


Error: Undefined variable in line 1085: (called from line 2737)

    print ( "FLIR JPG files converted into " + <RawThermalType> + " format.  Import these and convert to temperature using ...
gtatters commented 3 years ago

how are you importing this tiff file? It is not a radiometric file, so ThermimageJ has nothing to convert. You can just load it as a normal TIFF file that ImageJ already has capability.

ThermimageJ is only for use with radiometric files from FLIR jpgs. I have no experience with Lepton files or if they are truly radiometric.

gtatters commented 3 years ago

i.e. I can load it as a simple TIFF - most likely a 16 bit image - values on your hand are ~8000. But whether this is a linear scale with respect to temperature or not, I do not know, and ThermimageJ only handles the radiometric data encoded within the files. Is this an original file from the lepton or has it been modified?

AndreasKoerner commented 3 years ago

Hi, thank you for the quick response. It is the file that is directly taken from the Application and has not been modified.

image

The FLIR Lepton Manual states this regarding the RAWs: image

image

gtatters commented 3 years ago

sorry I don't have one of these devices so cannot help unless you send a radiometric file. But if the conversion is a linear conversion, ImageJ's calibration tool might suffice for your application (capture an image of ice water and boiling water to get 0C and 100C calibration values), although the conversion won't likely be too accurate and won't use the proper algorithms.

gtatters commented 3 years ago

it's possible that Lepton sensors are simply not calibrated by the manufacturer, in which case you won't have radiometric calibration data stored in the file.

AndreasKoerner commented 3 years ago

oh. i kind of start wondering what the applicaiton of the Lepton is then, other than a thermal webcam. anyhow, thank you so much for taking the time. if i find a solution, i will post it here.

gtatters commented 3 years ago

Using exiftool from the terminal window this is the only info I can see in your file. It does not contain the info req'd to convert to temperature:

ExifTool Version Number : 11.62 File Name : Lepton_Capture.tiff Directory : . File Size : 38 kB File Modification Date/Time : 2021:03:25 14:42:54-04:00 File Access Date/Time : 2021:03:25 10:12:35-04:00 File Inode Change Date/Time : 2021:03:25 10:12:15-04:00 File Permissions : rw-rw-r-- File Type : TIFF File Type Extension : tif MIME Type : image/tiff Exif Byte Order : Little-endian (Intel, II) Image Width : 160 Image Height : 120 Bits Per Sample : 16 Compression : Uncompressed Photometric Interpretation : BlackIsZero Fill Order : Normal Strip Offsets : 8 Orientation : Horizontal (normal) Samples Per Pixel : 1 Rows Per Strip : 120 Strip Byte Counts : 38400 X Resolution : 1 Y Resolution : 1 Planar Configuration : Chunky Resolution Unit : None Page Number : 0 1 Software : 7CTiff - FLIR Systems, Indigo Operations Sample Format : Unsigned Image Size : 160x120 Megapixels : 0.019

gtatters commented 3 years ago

I think Lepton expects the user to apply their own algorithm to convert temperature. That's why it's inexpensive. FLIR leaves it up to the user to work out. My formulae could be applied to your data, but without the calibration constants, we would just generate highly inaccurate numbers.

What my macros look for are 5 constants that FLIR shares when they calibrate their sensors. Without those cal values, I suspect the best approach is to create your own calibration curve where you just use ImageJ-->Analyze-->Calibration:

Screen Shot 2021-03-25 at 10 32 44 AM

If you use a 2 or 4 point solution of known water temperatures you could use that to convert to temperature.

Yes if you find a solution, I'd be happy to have it shared here! I will close this for now, but if you wish feel free to respond or re-open as needed.

AndreasKoerner commented 3 years ago

Thanks a lot!

I think I have just discovered the issue: There is a tiny difference between FLIR's Lepton 3 and 3.5. 3.5 has the radiometry function, version 3 does not but is otherwise identical. I have a v3.

gtatters commented 3 years ago

Oh, how frustrating! It's the wild wild west with respect to how FLIR shares this info or not.
One sketchy solution might be to find a sample image from a newer model so we can see what the calibration constants are, but that would only give a very bad temperature estimate! At least it would get the value in the right ballpark.

But a customised calibration curve would not be a terrible solution, but it would be difficult to work with objects of differing emissivities or objects with diff reflected or atmospheric conditions. So, if you want an approx solution, the customised cal curve would still work. But many of ThermimageJ functionality would be a bit superfluous. Other that the LUTs - but I copied those from ImageJ so they are mostly short-cuts to existing plugins and functions.

AndreasKoerner commented 3 years ago

Hah. Yes, this is an excellent description of how they provide information. Also the price of the two is almost identical. I will find a workaround. Unfortunately, I need it exactly to compare a variety of materials so a custom calibration for each sounds like a nightmare.

Thanks again for the help, the tool and you time!

gtatters commented 3 years ago

Ah, so yes you would prefer an accurate solution. Sometimes people are just playing around with these devices. I feel your pain. Thus why i've tried to share these. Give me a shout if you get a newer lepton or if you find someone has shared an image from v.3.5 I can verify if it will work with ThermimageJ

AndreasKoerner commented 3 years ago

Hi Glenn,

I got my hand on a Lepton 3.5. I have attached two TIFFs from it that should include radiometric data :) Lepton_Capture.zip

gtatters commented 3 years ago

Unfortunately they do not contain the necessary information I would need to convert the radiometric data into temperature. Running Exiftool on both files does not show any calibration data? If you can export a radiometric flir jpg we could scan it for the calibration constants?

======== Lepton_Capture.tiff ExifTool Version Number : 11.62 File Name : Lepton_Capture.tiff Directory : . File Size : 38 kB File Modification Date/Time : 2021:04:12 13:47:28-04:00 File Access Date/Time : 2021:04:12 08:09:40-04:00 File Inode Change Date/Time : 2021:04:12 08:09:01-04:00 File Permissions : rw-rw-r-- File Type : TIFF File Type Extension : tif MIME Type : image/tiff Exif Byte Order : Little-endian (Intel, II) Image Width : 160 Image Height : 120 Bits Per Sample : 16 Compression : Uncompressed Photometric Interpretation : BlackIsZero Fill Order : Normal Strip Offsets : 8 Orientation : Horizontal (normal) Samples Per Pixel : 1 Rows Per Strip : 120 Strip Byte Counts : 38400 X Resolution : 1 Y Resolution : 1 Planar Configuration : Chunky Resolution Unit : None Page Number : 0 1 Software : 7CTiff - FLIR Systems, Indigo Operations Sample Format : Unsigned Image Size : 160x120 Megapixels : 0.019 ======== Lepton_Capture2.tiff ExifTool Version Number : 11.62 File Name : Lepton_Capture2.tiff Directory : . File Size : 38 kB File Modification Date/Time : 2021:04:12 13:47:54-04:00 File Access Date/Time : 2021:04:12 08:11:00-04:00 File Inode Change Date/Time : 2021:04:12 08:09:05-04:00 File Permissions : rw-rw-r-- File Type : TIFF File Type Extension : tif MIME Type : image/tiff Exif Byte Order : Little-endian (Intel, II) Image Width : 160 Image Height : 120 Bits Per Sample : 16 Compression : Uncompressed Photometric Interpretation : BlackIsZero Fill Order : Normal Strip Offsets : 8 Orientation : Horizontal (normal) Samples Per Pixel : 1 Rows Per Strip : 120 Strip Byte Counts : 38400 X Resolution : 1 Y Resolution : 1 Planar Configuration : Chunky Resolution Unit : None Page Number : 0 1 Software : 7CTiff - FLIR Systems, Indigo Operations Sample Format : Unsigned Image Size : 160x120 Megapixels : 0.019 2 image files read