Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: KarenStr on February 19, 2021, 12:24:32 AM

Title: Read values stored in tiff
Post by: KarenStr 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!  :)
Title: Re: Read values stored in tiff
Post by: Alexey Pasumansky 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.
Title: Re: Read values stored in tiff
Post by: KarenStr 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?