Trying to get raw thermal data returns gibberish

Started by dybydx, March 08, 2022, 12:27:17 AM

Previous topic - Next topic

dybydx

I have a thermal image (attached).
I was trying to extract the raw data from the image using the following command:

exiftool flir2.jpg -rawthermalimage -b > out.dat

However, the output I get in out.dat is not readable. It has loads of random characters. Not sure what is going wrong  :(
I have also attached my out.dat file.

StarGeek

It appears to be a grey scale PNG image to me


Beyond that, I don't know, as I have no experience with thermal images.

Edit: From the FLIR tags page:
      The thermal image data may be stored either as raw data, or in PNG format. If stored as raw data, ExifTool adds a TIFF header to allow the data to be viewed as a TIFF image. If stored in PNG format, the PNG image is extracted as-is.

Looking at the output from your flir2.jpg, it states that it's a PNG image
C:\>exiftool -G1 -a -s -RawThermal* Y:\!temp\cccc\flir2.jpg
[FLIR]          RawThermalImageWidth            : 480
[FLIR]          RawThermalImageHeight           : 640
[FLIR]          RawThermalImageType             : PNG
[FLIR]          RawThermalImage                 : (Binary data 170309 bytes, use -b option to extract)
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

dybydx

I see. Thank you for the insight. I was actually trying to obtain the raw pixel value from the image, and that is why, I was tying to do this. So, I expected to see something like:


12781 12789 12789 12789 12783 12784 12785 .......
....    ....  .... ..... .....
....   ... ..... ....
....
....


for all the image pixels. But so far, I haven't been able to see this.
Could you guide me towards how I can obtain this data from the image?

I have been following the https://exiftool.org/forum/index.php?topic=4898.90 discussion, but I don't know why, it hasn't seemed to work for me. Apologies for being an amateur.

Perfect Pop

Hey, I am trying to do something similar too to start out with thermal images. Want to get the raw pixel values, to later do processing on them for conversion to temperature.

dybydx

That's good to know.
I am actually trying to get the data as follows:

18498 
18598 
18722 
18861 
18980
...
...

Basically, the raw.pgm output in reply#94 in https://exiftool.org/forum/index.php?topic=4898.90 . I am following the steps in that reply for an image (attached), but have not been able to see proper numbers. The steps I am doing are as follows:


$ exiftool -b -RawThermalImage flir3.jpg | convert - gray:- | convert -depth 16 -endian msb -size 512x640 gray:- raw.png

$ convert raw.png  -compress none raw.pgm


but, when I open raw.pgm with a text editor, I see output as:

P5
512 640
65535
&'!"#1"2()+$ )(#0.2=95477<EHG9G>EDBFKQTWZUYXS[ggd]dfjhinbifY

(this is a small part of the output)

So, I am not sure, what I am missing here. Please guide if anyone is aware of this.

StarGeek

Here's what I get.  First, extract the PNG
exiftool -P -overwrite_original -rawthermalimage -b Y:\!temp\cccc\flir2.jpg >Y:\!temp\cccc\out.png

A line I didn't add from the link above says
      Note that most FLIR cameras using the PNG format seem to write the 16-bit raw image data in the wrong byte order.

This is the reason for the -endian msb in the imagemagick command.  But, for your image, this may not be the case.  The PNG is already 16 bit depth as noted in the output above.

Editing the command listed in msg #94, as my more recent install of imagemagick doesn't contain a separate convert command:
magick convert Y:\!temp\cccc\out.png -compress none  Y:\!temp\cccc\out.pgm

Opening the PGM file in Notepad++
P2
480 640
65535
13873 13873 13873 13873 14385 14897 15409 16177 16689 17457 18225 18737 18993 18993 18993 18993 18993 18993 19761 20785 21297 21553 21809 22577 23601 24625 25905 27441 27953 27953 27697 28465 29233 30001 30769 31281 31793 32049 32305 32305 32305 32049 32049 31793 31793 31793 31793 32049 32561 32817 33329 33585 34353 35377 36657 37425 38193 38705 39729 40753 41521 42545 43313 44593 46129 47409 48177 48945 49201 49201 49457 50737 52273 53809 54065 54321 54321 54321 54321 56369 58929 60977 61489 61745 62001 62257 62513 63281 64305 65073 65073 65073 50 1074 2098 6194 11058 15666 18738 21810 24370 25906 27698 31538 35634 40242 47154 54066 58162 59442 60722 3123 12083 19763 20019 20531 20531 20531 20531 26163 33075 38451 37427 36403 36403 37171 37939 40243 43059 45107 45107 45107 45619 46131 46643 47667 48691 49459 49459 49459 49715 49971 50483 50739 51251 51507 51507 51507 51507 51507 51507 52019 53043 53811 54323 54835 55603 56115 56627 56883 57395 57651 57907 58163 58419 58419 58675 58675 58419 58419 58419 58163 58163 58163 57907 57907 57907 57651 57651 57395 57139 56883 56627 56627 56371 56115 55859 55859 55859 55859 56115 56115 56371 56627 56883 57139 57651 57907 58419 58675 58931 59443 59699 59955 60211 60723 60979 60979 61235 61235 61235 61235 60979 60723 60467 59955 59699 59187 58675 58163 57395 56883 56115 55603 55091 54323 51763 49459 49459 51763 54323 55091 55603 55859 56115 56371 58419 62259 564 3380 5940 8756 14132 19252 22324 22580 23092 27956 33588 38196 38196 38196 38196 38708 38964 44084 50228 55348 55860 56116 52532 44596 36660 30516 24884 19764 18740 17716 14132 8756 3124 59955 50739 43059 42803 42803 45619 50995 56371 60467 64307 2868 7988 13108 21044 31796 42548 49204 54836 60212 64308 2613 6453 10549 14389 18741 23349 27189 29237 31285 31797 31029 30261 31029 32053 33333 35125 36917 37429 36917 36149 34869 33589 32565 31797 31285 30773 30773 30773 28725 26165 23861 23349 22581 22325 22325 22325 15413 7221 53 64308 62772 59188 53044 46900 37684 27956 19252 17460 15668 15924 18484 20788 21044
20532 20276 20532 20788 21556 22580 23604 33844 45620 56628 63796 5173 9269 11061 12597 13877 15157 16437 17973 19765 21813 24117 26165 25909 24885 24373 25141 25909 27701 30261 32821 33077 33333 33589 35381 37429 38453 38965 39477 39477 38965 38453 36917 35125 33589 32053 30517 29493 28981 27957 25909 23861 23605 25397 26933 27701 28469 29237 30261 31541 32309 32821 33077 33333 33589 33845 33589 33589 33845 34869 35893 36917 38197 38965 38965 38965 39221 40501 41525 35893 29237 23349 22069 20533 20021 19765 19509 18485 17205 13365 61492 44084 35124 34612 34100 31796 29492 25396 13108 820 59955 59699 59187 58163 57139 56115 56115 56115 55859 55603 55347 54067 52531 51251 50227 49459 48691 47667 46899 45875 44851 43827 43571 43571 43571 43315 43059 44851 47155 48947 49715 50227 50483 50739 50995 50995
13873 13873 13873 13873 14385 14897 15409 16177 16689 17457 18225 18737 18993 18993 18993 18993 18993 19249 20017 20785 21297 21553 21809 22833 23601 24625 25905 27441 27953 27953 27953 28465 29233 30001 30769 31537 31793 32049 32305 32305 32305 32305 32049 31793 31793 32049 32049 32305 32817 33073 33329 33841 34353 35633 36913 37681 38193 38961 39985 40753 41777 42545 43313 44593 46129 47409 48177 48945 49201 49457 49457 50737 52529 53809 54065 54321 54321 54577 54577 56625 58929 60977 61489 61745 62001 62257 62513 63281 64305 65073 65073 65073 50 1074 2098 6450 11570 16178 18994 22066 24370 26162 27954 32050 36914 42034 48178 54578 58162 59442 60722 3123 12083 20019 20275 20531 20531 20531 20531 26163 32819 38195 37427 36403 36147 36915 37683 40243 42803 45107 45107 45107 45363 45875 46387 47411 48691 49459 49459 49459 49715 49971 50483 50739 50995 51507 51507 51507 51507 51507 51507 52019 53043 53811 54323 54835 55603 56115 56627 56883 57395 57651 57907 58163 58419 58419 58675 58675 58419 58419 58419 58163 58163 58163 57907 57907 57907 57651 57651 57395 57139 56883 56627 56371 56371 56115 55859 55859 55859 55859 55859 56115 56371 56627 56883 57139 57651 57907 58419 58675 58931 59187 59699 59955 60211 60467 60979 60979 61235 61235 61235 61235 60979 60723 60467 59955 59699 59187 58675 58163 57395 56883 56115 55603 55091 54323 51763 49459 49459 51763 54323 55091 55603 55859 56115 56371 58419 62259 564 3380 5940 8756 14132 19252 22324 22836 23348 28212 33588 38196 38196 38196 38452 38964 39476 44340 50484 55348 55860 56116 52532 45108 37428 31284 25396 20276 18996 17716 14388 9268 3892 60467 50995 43059 42803 42803 45363 50739 55859 59955 64051 2612 7732 12852 20788 31540 42292 48948 54836 60212 64052 2613 6453 10293 14133 18741 23093 27189 29237 31029 31797 31029 30261 31029 32053 33077 34869 36661 37429 36661 36149 34869 33589 32309 31797 31029 30773 30773 30773 28469 25909 23861 23349 22581 22325 22325 22325 15413 7221 53 64308 63028 59188 53300 47412 38196 28212 19508 17716 15668 15924 18484 21044 21044
20532 20276 20532 20788 21556 22580 23860 33076 44084 54580 62260 4661 9269 11061 12597 13877 15157 16693 18229 20021 21813 24117 26421 25909 25141 24373 25397 26165 27701 30261 32821 33333 33333 33589 35637 37429 38709 38965 39477 39221 38965 38453 36917 35125 33589 32053 30517 29493 28981 27957 25909 23861 23605 25397 26933 27701 28469 29237 30261 31541 32309 32821 33077 33333 33589 33845 33589 33589 33845 34869 35637 36917 38197 38965 38965 38965 39477 40501 41525 36149 29237 23349 22069 20533 19765 19765 19509 17973 15925 11573 60468 43828 35124 34356 33844 31028 27956 23348 11828 308 59955 59699 59187 58163 57139 56115 56115 56115 55859 55603 55347 54067 52531 50995 50227 49459 48691 47667 46899 45875 44851 43827 43571 43571 43571 43315 43059 44851 47155 48947 49715 50227 50483 50739 50995 50995
13873 13873 13873 13873 14385 14897 15409 16177 16945 17969 18481 18993 19249 19249 19249 19505 19761 20017 20273 20785 21297 21553 21809 23089 24113 25393 26417 27441 27953 27953 28209 28977 30001 30769 31281 31793 32049 32305 32305 32561 32817 32817 32817 32561 32817 32817 33073 33585 33841 34353 34609 35121 35633 36657 37681 38449 39473 40241 41009 41777 42545 43313 44081 45361 46641 47921 48433 48945 49457 49713 50225 51505 53041 54065 54321 54321 54577 55089 55345 57137 59185 60977 61489 61745 62257 62257 62513 63025 63793 64561 65073 50 818 1586 2354 7730 14130 19506 21298 22834 24626 26418 28210 35634 44338 52018 54322 56370 58162 59442 60722 3123 12339 20275 20275 20531 20531 20531 20531 25907 32051 37171 36659 35891 35891 36403 36915 39475 42547 45107 45107 45107 45363 45619 46131 47155 48179 49203 49203 49459 49715 49971 50227 50483 50739 51251 51251 51251 51251 51251 51251 52019 52787 53555 54323 54835 55347 55859 56371 56883 57139 57395 57651 57907 58163 58419 58419 58419 58419 58419 58163 58163 57907 57907 57907 57651 57651 57651 57395 57139 57139 56883 56627 56371 56115 55859 55859 55859 55859 55859 55859 56115 56371 56371 56883 57139 57395 57907 58163 58419 58931 59187 59443 59699 60211 60467 60723 60979 60979 61235 61235 60979 60979 60723 60467 59955 59699 59187 58675 58163 57395 56883 56115 55603 55091 54067 51763 49459 49459 51763 54323 55091 55603 55859 56115 56371 58419 62515 820 3380 5940 9012 14132 19252 22580 23860 25140 29492 34612 38708 38452 38196 38708 40500 42036 46644 51764 56116 56116 56116 53300 48180 42804 35892 28468 22068 20276 18484 15924 12340 8756 64051 52531 43059 43059 42803 44851 48947 53043 57907 63027 2612 6964 11316 18996 30260 41268 47924 54068 59700 63540 2101 5685 9269 12853 17461 22325 26677 28725 31029 31797 31029 30517 31029 32053 33077 34357 35893 36661 36149 35637 34613 33077 31797 31029 30261 30005 29749 29749 27701 25397 23605 23093 22581 22325 22069 21813 15157 7221 565 64564 63028 59956 55092 50228 41012 30516 21556 18996 16436 16436 18996 21556 21044
20020 19252 20020 20788 21812 22836 24116 28724 34100 40756 54324 2101 9781 11317 12597 14645 16437 18229 19509 20789 22325 24629 26677 26421 25909 25397 26165 26933 28469 30773 33333 33845 34101 34613 36149 37941 38965 39221 39733 39221 38709 37941 36405 35125 33589 32053 30517 29493 28981 27957 25909 23861 23605 25397 26933 27701 28469 29237 30261 31541 32309 32565 32821 33077 33589 33845 33845 33589 34101 34613 35381 36661 37941 39221 38965 38965 39477 40757 41781 36149 29237 23349 22069 20533 19765 19253 18741 14133 8757 1845 54580 41780 34868 33588 32308 26420 19508 12596 5428 63795 59955 59443 58931 57907 56883 55859 55859 56115 55859 55603 55347 53811 52275 50739 49971 49459 48691 47667 46899 45875 44851 43827 43571 43571 43571 43315 43059 44851 47155 48947 49715 50227 50483 50739 50995 50995
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

dybydx

Okay, so I have to check the byte order for an image first and then execute a command accordingly.

However, when I try your steps above, I get the first three lines (P2    480 640     65535) in the pgm file the same. But everything below that is gibberish. I think it might be some encoding issue(?)
The gibberish is there when I open it in notepad++. But when I open it in sublime text, I see the pixel values, but in hexadecimal, and the three lines from the top are not there.

Any ideas about this?

StarGeek

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

dybydx

Oh okay. Yes, I am on windows. I was using an Ubuntu WSL terminal. Will try with CMD as well.

dybydx

I have tried using Cygwin on windows, and I am still getting the same result.

StarGeek

Sorry, all I can really help with is exiftool.  Using your example image, it seemed to work for me using the steps above.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype