Author Topic: 3d recostrucrion of thermal data  (Read 18479 times)

0 Members and 1 Guest are viewing this topic.

Offline tuffiTopic starter

  • Newbie
  • Posts: 8
  • Country: it
3d recostrucrion of thermal data
« on: June 12, 2016, 05:42:13 pm »
Dear friends,
I need help for analyze some thermal image dataset. My sensor is an OPTRIS PI400
I have some thousand of .CSV matrix that are a 382x288 array, where every cells are a temperature in celsius with one or two decimal data.
I need to make a photogrammetric process to my data, so i need to convert my CSV data into TIFF image (16bit - the sensor works at 12bit). So:
1 - Looking for a minimum and maximum values of temperature of all dataset of array
2 - Create a LUT where the min temp is black (0) and max temp is white (65,536)
3 - Whit this palette create a TIFF image of every CSV.
After photogrammetric recostruction I need to resample final orthoimage with the same LUT and create a 32 bit TIFF possible with radiometric information for every pixel.
Anyone know some script that can help me!?
Thank you so much..
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: 3d recostrucrion of thermal data
« Reply #1 on: June 12, 2016, 07:35:05 pm »
Search for OpenCV and Python. Maybe even matlab or the free alternative scilab.
I'm sure they can perform the basic image transformations.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #2 on: June 15, 2016, 10:56:29 pm »
Imagemagick also works fine with txt files as input of array.
(use fx operator for mathematics).

convert your *.csv file to integer values like [100xKelvin - Offset] and use *.pgm format for saving the 16 bit grayscale images
http://www.imagemagick.org/Usage/formats/#pbmplus
Code: [Select]
P2
382 288
65535
....

Offline tuffiTopic starter

  • Newbie
  • Posts: 8
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #3 on: June 16, 2016, 02:23:54 pm »
Thank you,

but before use ImageMagik....I need to looking for a v min and v max off all of dataset right? I need to make a palette for all of dataset (one image every second for one or two houar) and not a single file...

Sorry for all of my question but OPTRIS software is a very close system and i need an alternative to make my research...
 

Offline joe-c

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: de
    • Joe-c.de
Re: 3d recostrucrion of thermal data
« Reply #4 on: June 17, 2016, 03:49:51 am »
Hello,
could you upload some sample files?

than i can see how implant it here:
https://www.eevblog.com/forum/thermal-imaging/freeware-software-for-thermal-analysis-thermovision_joec/

there is no 3d reconstruction yet, but maybe it helps for interpreting the images.
joe-c
Freeware Thermal Analysis Software: ThermoVision_Joe-C
Some Thermal cameras: Kameras
 

Offline LaserSteve

  • Super Contributor
  • ***
  • Posts: 1281
  • Country: us
Re: 3d recostrucrion of thermal data
« Reply #5 on: June 17, 2016, 09:39:44 am »
Take a look at NIH'S freeware ImageJ, while made for biological microscopy, it works wonders with scripts. I used it for batch combining alternate lines of two grabbed  images for field sequential stereo imaging, and that.took only ten lines of script.
"What the devil kind of Engineer are thou, that canst not slay a hedgehog with your naked arse?"
 

Offline gio123

  • Newbie
  • Posts: 6
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #6 on: June 17, 2016, 12:37:09 pm »
Hi All,
I've been following this forum regarding IR related topics, and this is my first post.
I'm basically in the same situation as Tuffi: I have an Optris PI400 imager, and I need to radimetrically (temperature data) process several hundreds of images taken at roughly 1 s inerval, however I'm facing some stumbling blocks: the Optris imager can generate either radiometric tiff's (8-bit, two-page; unrecognized MakerNotes as per exiftool) or text files (.csv - either temperature data or temperature profile): I'm attaching 3 samples of the same scene, with the 3 different Optris saving options (the original Test1.tiff was reanmed to Test1.jpg since this forum doas not allow to upload tiff's - the jpg has retained thw 2-page layout; I do not know if anything else has changed from the native tiff; the 2 .csv files were renamed as .txt for the same fiel extension limitations ofthis forum).
I would like to be able to generate radiometric-thermal gray-scale images (tiff or jpeg) in order to process them with CV/SfM software to obtain one single mosaiced orthophoto and a 3D model retainng individual pixel thermal data; one of the things (among the many others) that's creating problems, I guess, is the tiff 2-page structure - I saved the tiff as 2 separate files, but then the thermal information is lost...
Just for information purposes: before writing this post I've read pretty much all the posts and outstanding information form Tomas123 on a similar topic relating to Filr (both within this forum and also from exiftool - great appreciation goes to Phil Harvey - as well and ImageMagik); I also downloaded and tried with no luck Thermovision from Joe-c (impressive work as well): unfortunately I do not have a programming background so I'm not really able to 'port' FIlir related scripts into Optris.
Any feedback/tips/help would be gratlyappreciated.
Thanks in advance
Regards
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #7 on: June 17, 2016, 05:01:16 pm »
I'm not sure, how to interpret your radiometric images.

As you said, the *.tiff image contains two 8 Bit images of 382x288 pixels:
Code: [Select]
$ identify Test1.tif
Test1.tif[0] TIFF 382x288 382x288+0+0 8-bit sRGB 397KB 0.000u 0:00.000
Test1.tif[1] TIFF 382x288 382x288+0+0 8-bit sRGB 397KB 0.010u 0:00.009

simple expand this two 8 Bit images with Imagemagick
Code: [Select]
$ convert Test1.tif image.png
convert: Unknown field with tag 37500 (0x927c) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/891.
convert: Unknown field with tag 59933 (0xea1d) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/891.

$ identify image*.png
image-0.png PNG 382x288 382x288+0+0 8-bit sRGB 202KB 0.000u 0:00.000
image-1.png PNG 382x288 382x288+0+0 8-bit sRGB 114KB 0.000u 0:00.000

The *.csv is only the temperature of the center cross hair (full line 288/2 and column 382/2 less a border of 12 pixels)
Code: [Select]
Temperature profile 1;;;;Temperature profile 2;;;;
 x; y; Temperature;; x; y; Temperature;;
12.0; 144.0; 20.0; ;191.0; 12.0; 17.7;
13.0; 144.0; 20.0; ;191.0; 13.0; 17.7;
...

Is there a known temperature range for your 8 Bit images?
My next idea is a splittet upper and lower byte for a real 16 Bit radiometric image...
Code: [Select]
$ convert image-0.png -separate -depth 8 image-0-RGB%d.png
$ convert image-1.png -separate -depth 8 image-1-RGB%d.png

... and I see a typical switched upper/lower byte image like this 16 bit image:


compare with your 8 Bit image-1-RGB2.png

Offline gio123

  • Newbie
  • Posts: 6
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #8 on: June 17, 2016, 05:19:52 pm »
Hi Tomas123, and thanks a ot for replying in such a prompt and detailed manner: much appreciated.
The temperature range of the image is 17.9 C - 32.9 C.
Actually what you were able to dig out is outstanding on one side, on the other it adds more 'clouds' to my little brain...;)
I'm not sure at this point that fully radiometric images god for orthorectification and 3d modelling can be obtained...
Thanks
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #9 on: June 17, 2016, 08:35:49 pm »
Unfortunately there is no free download for the software "Optris Pi Connect".
Therefore I can't check your radiometric 8-Bit tiff with the original software.

Offline gio123

  • Newbie
  • Posts: 6
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #10 on: June 17, 2016, 08:55:16 pm »
Can you send me an email address: I'll send you a link to download some additional info.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #11 on: June 17, 2016, 11:53:18 pm »
I would like to be able to generate radiometric-thermal gray-scale images (tiff or jpeg) in order to process them with CV/SfM software to obtain one single mosaiced orthophoto and a 3D model retainng individual pixel thermal data
The solution is simple ;)

As presumed above, the second image inside the tiff is the 16 bit radiometric image splitted in the two 8 bit channels green and blue:

Code: [Select]
$ identify Test1.tiff
Test1.tiff[0] TIFF 382x288 382x288+0+0 8-bit sRGB 397KB 0.000u 0:00.000
Test1.tiff[1] TIFF 382x288 382x288+0+0 8-bit sRGB 397KB 0.000u 0:00.009

// get only scene 1, remove alpha channel
$ convert Test1.tiff[1] -alpha off scene1.png

$ identify -verbose scene1.png  | grep -A3 "Channel depth"
  Channel depth:
    red: 1-bit
    green: 8-bit
    blue: 8-bit

// stitch the 8 bit green and blue channels to one 16 bit radiometric grayscale image
// force 16 bit channel with PNG48:
$ convert scene1.png -separate -fx "(u[1]+u[2]/256)" PNG48:image-3.png

// check min/max value
$ identify -verbose image-3.png  | grep -A 6 "Channel depth"
  Channel depth:
    gray: 16-bit
  Channel statistics:
    Pixels: 110016
    Gray:
      min: 64868 (0.989822)
      max: 65250 (0.995651)

That's all. The image-3.png is your 16 bit radiometric grayscale image with a temperature range from min 64868 to max 65250.
It's obscure, why your upper byte (green channel) has such high values from min=252 to max=253 by an image range from 13°C to 27°C.
Maybe we need an sample image with higher temperature to check, whether we have an overflow to the red channel. 
The data sheet of PI 400 give us a range from –20 °C ... 100 °C.

All steps in one line with expanding the level for visual examination:
Code: [Select]
$ convert Test1.tiff[1] -separate -fx "(u[1]+u[2]/256)" -auto-level PNG48:gray.png

PS: use the 16 bit version of IM ;D

Offline gio123

  • Newbie
  • Posts: 6
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #12 on: June 18, 2016, 07:47:26 am »
Tomas123, you're a Guru of image analysis and manipulation...  :-+ to me this is all 'black magic'...  ;)
Is it feasible to batch process an enitre sequence of native tiff images and obtain either greyscale radiometric tiff or jpg (instead of .png's)?
Would something like this work:

$ convert *.tiff[1] -separate -fx "(u[1]+u[2]/256)" -auto-level TIFF48:gray*.tiff

I'm also attaching an image of an iron (both the png and jpg are renamed from the original tiff) showing higher temperatures.

To have the pixel data in Celsius degress I assume one has to go about a similar process as you did for Flir with equations and constants etc. (assuming Optris publishes their raw sensor data conversion into temperatures).

As a final thought: can you recommend some readings/links on digital image analysis/processing/structures, where even a donkey like me can get at least the gist of all this?

Thanks a lot
Best Regards
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #13 on: June 18, 2016, 11:39:11 am »
Hi gio123,

you can write a for loop over all images in Windows (cmd.exe) or Linux (bash).

some notes:
(1) Use auto-level only after stitching all images to a mosaic
(2) You can calculate the real temperature from RAW values (after stitching) by interpolation over known values.
Use your *.csv files (with cross hair temperature profile) as reference points.
See my post for getting RAW values of single pixels:
https://www.eevblog.com/forum/thermal-imaging/flir-e4-thermal-imaging-camera-teardown/msg350250/#msg350250

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #14 on: June 18, 2016, 03:49:25 pm »
The iron image shows, that the green channel is a 8 bit signed value  :-\
(the increasing values goes from ... 254,255, 0, 1 ... etc.)

therefore I used the dirty hack:
Code: [Select]
$ convert Sample2.tiff[1] -separate -fx "(u[1]>=0.75)?(u[1]-0.25+u[2]/256):(.75+1/256+u[1]+u[2]/256)" PNG48:gray2.png
use -auto-level only for for visual examination:
Code: [Select]
$ convert Sample2.tiff[1] -separate -fx "(u[1]>=0.75)?(u[1]-0.25+u[2]/256):(.75+1/256+u[1]+u[2]/256)" -auto-level PNG48:gray2.png
(added 1/256 for shifting 0 to 1, to avoid that 255=0)

Offline gio123

  • Newbie
  • Posts: 6
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #15 on: June 20, 2016, 10:42:28 am »
Tomas123,
That's just awsome; thanks a lot.
I'm taking some time to (try) to understand the process you've applied; as I said this area (as well as many others..) is a little bit over my head.
I'll get back to you shortly.
Thanks much
 

Offline tuffiTopic starter

  • Newbie
  • Posts: 8
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #16 on: June 22, 2016, 03:17:16 pm »
Hi guys,

I have another type of data from OPTRIS.

A csv matrix file.

Every pixels are rapresented by a one decimal temp data. It's useful for our objective?

I attach same CSV.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #17 on: June 24, 2016, 08:34:20 am »
csv: 288 lines with 382 temperature values

This are temperature values of your sensor array 382x288.

A disadvantage is the bad thermal resolution of 0.1 °C.

You can convert this csv files with sed and Imagemagick  ;)
Code: [Select]
sed "1iP2 382 288 255 " Record_2016-02-18_12-01-09.csv | sed "s/\.//g" | convert PGM:- -auto-level Record_2016-02-18_12-01-09.jpg(edit this line for your purpose, I used 25,5°C=255 as high level, because you take a shot with closed shutter/cover)

Offline joe-c

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: de
    • Joe-c.de
Re: 3d recostrucrion of thermal data
« Reply #18 on: June 24, 2016, 11:14:42 am »
Hello,
i have a new Version of my Thermovision including some Optris Pi400 stuff.
http://joe-c.de/pages/posts/programm_thermovision_joe-c_184.php#V1_0_2_0

if you change the Filedrop mode to "Drop-> Optris PI400 Mode" (in "Datei" or "File" if you set Language to EN).
after that you can easy Drag & Drop your *.tif, *.tiff,*.csv Files.
the temperature of the tif files have to setup manually by choose "fixed". for a dynamic calculation there are Level and Span values. You have to setup them following:
take a image with a big temperature range... for example -10 to 90°C. calculate the Range (max-min) and change the span value until your image has the same range in the Thermovision (the range is noted in the Scale bottom). After that you change the offset until you reach the real temperature values of your image (while changing the offset maybe the Span needs tiny changes because the Range moves).
its the same Setup as the Seek thermal Camera needs.
if the setup is finished, your other images should be show values near the real.
Not that accurate, but I don't now how Optris store the Temperature.

Well... the csv has a poor Sensitivity with the 0.1°C but the Values are truth.
you can import csv files by drop. additional there is a folder Processing. you can hit the button and choose a folder, or just drop the folder in workspace of the Thermovision.
The folder processing does:
- read all *.csv files
- create a subfolder called "ThermoViewer_JPG"
- convert each csv to a jpg file
- writes at end the Overview.txt with some extra info's, like the number of files, the highest and lowest temperature for each and for all files...

I hope it's useful for you.

and last but not least, a big thanks for tomas123, who make a great example for reading the Files (peculiar the tif).

joe-c
Freeware Thermal Analysis Software: ThermoVision_Joe-C
Some Thermal cameras: Kameras
 
The following users thanked this post: gio123

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: 3d recostrucrion of thermal data
« Reply #19 on: June 24, 2016, 01:30:37 pm »
We are playing together since years Curling.
I'm the sweeper and you make the shots  :)

Offline tuffiTopic starter

  • Newbie
  • Posts: 8
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #20 on: June 26, 2016, 02:13:19 pm »
tomas and joe..thank you so mcuh...

realtive to the sensiblity of data saved in csv format I think that for my use (enviromental mapping and slope stability) will be ok work witha 0.1°C of Sensibility...anyway the PI400 have a raw sensibility of 0.08°C, so there is a little loss of information..

Maybe is possible integrate TIFF raw data and CSV information to obtain a radiometric image with a real temp data obtained from CSV?

As soon as possible I try an acquisition with OPTRIS for testing the conversion and the 3d recostruction.
 

Offline tuffiTopic starter

  • Newbie
  • Posts: 8
  • Country: it
Re: 3d recostrucrion of thermal data
« Reply #21 on: June 28, 2016, 11:36:35 am »
Hi,

i make some test and the software works fine, but for 3d recostruction there is two small problems:

1. the first one is the black bands up and down the images.
2. the second is that the strach of the Palette (from CSV) is dynamic for every array. There is a way for use the same strech for every CSV in the folder. I think that all CSV must be processed for looking for a min and max temperature before restart the process and create the jpg. So after mosaic all of image i can create a color legend.

I attach two file. The NAS disk in the two image have the same temperature but are processed with two differet color (I think because in one image, the temp max is relative to the ac-dc converter).

In yours opinion, why CSV data are less sensitive of TIFF?
 

Offline joe-c

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: de
    • Joe-c.de
Re: 3d recostrucrion of thermal data
« Reply #22 on: June 29, 2016, 04:17:56 pm »
Hello,
to 1.
the generated images are a preview image with embedded Thermal Frame.
to 2.
i could make a second function, what first get the min and max for all and process then in single images with the same scale.
Or with a previous set min and max raw value.
but first i have a focus on this:
https://www.eevblog.com/forum/thermal-imaging/diy-thermocam-an-open-source-do-it-yourself-thermal-imager/

And yes, the tiny difference between the gray level is a result of different min/max values and scales.
I made the same scale for both images and put them in one image. there seems to be a tiny difference,
maybe because the dynamic values are not set and so the result temperature has a shift (0.9°C diff, between both box averrages).

The CSV data is maybe just cropped to 1 digit because the manufacture will provide no information you maybe don't need.
And if you go to 2 digits, you have 1Byte for each extra char (pixel) -> 388x288 -> 111744 extra chars in file.
I think they just do this to hold the file size small.

Joe-c
Freeware Thermal Analysis Software: ThermoVision_Joe-C
Some Thermal cameras: Kameras
 

Offline edgar_eacg

  • Newbie
  • Posts: 2
  • Country: mx
(Temperature values <-> Thermal Color) Mapping
« Reply #23 on: June 30, 2016, 07:37:15 pm »
Hello.
I hope you can help me. I'm interested in the mapping process from one pixel temperatures value to color using a specific color palette. I read here  http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,4898.msg24230.html#msg24230  about a flir.php file which does what i want. But when I checked the source code I realized that the algorithm is wrapped in the use of convert.exe through the command line exec.

Which is the algorithm or LookUpTable procedure to map from one pixel's temperature value to color (using a color palette)?
I've been able to get the color's palette raw data (through exiftool by Phil Harvey). I also have the pixel's temperatures .csv file from my jpg (through Flir QuickReport)

I found here https://www.eevblog.com/forum/thermal-imaging/flir-e4-thermal-imaging-camera-teardown/msg350250/#msg350250 an alternative but again, but it relies on the use of convert.exe which for now it's like a black box to me.

I need to study the mapping algorithm from temperatures to color (using the color Palette) so that I could conceive an inverse algorithm for mapping from color to pixel temperature since, my real problem is to 'estimate' one pixel's temperature from just the pixel's color. This is the scenario:
- I have a Flir P640 which can only take radiometric jpg photos, at most, sequences of 180 radiometric photos (.seq files).
- I have 2-3 hours non-radiometric video recordings (.avi videos).
- I need to pause the video and 'estimate' one pixel temperature, for this I take a snapshot from the specific frame and read the RGB channels of that pixel. That's all I have! :-//

Beforehand, thanks.
And congratulations for your work.

« Last Edit: July 01, 2016, 02:21:00 pm by edgar_eacg »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: (Temperature values <-> Thermal Color) Mapping
« Reply #24 on: July 02, 2016, 11:42:07 am »
I'm interested in the mapping process from one pixel temperatures value to color using a specific color palette.
Follow the links in my footer.
There are some simple step-by-step samples for this process.
I don't know, how can I explain it better.

But when I checked the source code I realized that the algorithm is wrapped in the use of convert.exe through the command line exec.
see http://www.imagemagick.org/Usage/color_mods/#color_lut

I need to study the mapping algorithm from temperatures to color (using the color Palette) so that I could conceive an inverse algorithm for mapping from color to pixel temperature since, my real problem is to 'estimate' one pixel's temperature from just the pixel's color.

You need a video with a (linear) grayscale palette for the reverse lookup process (one channel, 256 color steps).
Better is using of the Flir RAW video format (*.seq).
see:


1. Bill Kraus has developed a SDK app that does continuous raw image saving. PM him on Flickr for a beta copy. My Therm-App -> FLIR intensity conversion is also now built into his app.

2. Convert your continuous "video" stream of PNGs into .fffs, as before. To do this in batch, you can use "forfiles" on windows.
...


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf