Forum

Author Topic: Read values stored in tiff  (Read 1842 times)

KarenStr

  • Newbie
  • *
  • Posts: 7
    • View Profile
Read values stored in tiff
« on: February 19, 2021, 12:24:32 AM »
Hello!

We are using Metashape to evaluate images taken during UAV flights. I am currently working on a data set of thermal images (radiometric tiffs). Since some parameters in the thermal camera during the flight weren't set correctly, I need to access and manipulate the temperature values stored in the tiff files (16bit number representing the temperature of each pixel). I am sure I can use python to do this in metashape - but I am very new to this.

My first idea was to use Image.open() on the cameras to access the values (and then store them in an array, do my manipulation, and put the now corrected values back into the image?). But this doesn't seem to work...

Any pointers to the right direction?

Thank you!  :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Read values stored in tiff
« Reply #1 on: February 19, 2021, 05:54:49 PM »
Hello KarenStr,


You can create a new Metashape.Image() object where you can write the original image data, perform the manipulation (editing) and then save under different name.
Best regards,
Alexey Pasumansky,
Agisoft LLC

KarenStr

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Read values stored in tiff
« Reply #2 on: March 19, 2021, 07:52:25 PM »
Hi and sorry for the late reply!
Thank you for the help, it kind of worked! But I have a follow-up:
If I simply use

im = MetaImgObject.open(image_path, layer=0, datatype='U16')
imarray = np.array(im)

I do not get an error but the produced array is empty. However, it did work after saving the image under a different name and then reopening it:   

im.save(os.path.join(testsave_path, "testsave.tiff"))
im_tiff_normal = Image.open(os.path.join(testsave_path, "testsave.tiff"))
imarray = np.array(im_tiff_normal)
      
Any hint on why that might be?