Help with extracting a tiff image from a IMG file

Started by JmsChf, July 06, 2023, 03:07:07 PM

Previous topic - Next topic

JmsChf

Hi,
I am working with some IMG files from a FLIR thermal camera. I am trying to write a script in python to extract the tiff image from the IMG file and save it in a new file. For some reason the TIFF image is completely grey when I open it though.

Here is my code:
import subprocess
import csv
import numpy as np

IMG_path = R"~IMG PATH~"

exiftool_command = ["C:\exiftool", "-b", "-RawThermalImageType", IMG_path]

print(subprocess.check_output(exiftool_command))

with open("data.tiff", 'w') as file:
  writer = csv.writer(file)
 
  exiftool_command = ["C:\exiftool", "-b", "-RawThermalImage", IMG_path]

  subprocess.run(exiftool_command, stdout=file)

  file.close()

with open("metadata.csv", 'w') as file:
  writer = csv.writer(file)
 
  exiftool_command = ["C:\exiftool", "-csv", IMG_path]

  subprocess.run(exiftool_command, stdout=file)

  file.close()


I am attaching the file the image is in as well. Any insight is appreciated.

Thanks,
JmsChf

StarGeek

Quote from: JmsChf on July 06, 2023, 03:07:07 PMFor some reason the TIFF image is completely grey when I open it though.

Do you mean completely solid one color grey?  Or grey scale?

This is the image I end up with extracting it on the command line (converted to PNG)
exiftool -b -RawThermalImage >Y:\!temp\aaaaa\t.tiff  Y:\!temp\aaaaa\thermal.IMG
t.png
"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

JmsChf

#2
Hi StarGeek,

When I run the both the code I wrote and the command you wrote I get a completely solid grey picture, not the image in greyscale.



StarGeek

The problem seems to be whatever you are using to view the image then.  When I view your tiff with irfanview, it shows up the same as what I posted earlier

i_view64-2023-07-07_12.47.29.png
"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

wywh

I get either seemingly solid gray or the same as StarGeek (with GraphicConverter, Photoshop, Lightroom) if the 16-bit picture.tiff is automatically/manually leveled/windowed. There is not much depth in that image.

- Matti

JmsChf

Thank you! Do you have any recommendations on ways to boost the contrast or manually level/window it to make it more visible. I was just opening it with the default windows image viewer, but when I opened it with Irfanview it came through. There definitely is not a lot of contrast in the image, its a thermal image of the ground so there wouldn't be much variance in value.

- Jms