Forum

Author Topic: Undistorting images with ConvertImages class?  (Read 2448 times)

jedfrechette

  • Full Member
  • ***
  • Posts: 130
  • Lidar Guys
    • View Profile
    • www.lidarguys.com
Undistorting images with ConvertImages class?
« on: March 08, 2022, 09:50:31 PM »
I noticed that the Python release notes for 1.8.1 include:


Quote
• Removed fix_pixel_aspect, fix_principal_point, and remove_distortions attributes from ConvertImages class

Does that mean that the ConvertImages class can't be used to create undistorted images anymore? If so what is the recommended way to do that, both via the API and the GUI?
Jed

Paulo

  • Hero Member
  • *****
  • Posts: 1324
    • View Profile
Re: Undistorting images with ConvertImages class?
« Reply #1 on: March 09, 2022, 04:43:13 AM »
Hi Jed,

you are correct the ConvertImages() class no longer supports undistorsion. The workaround would be for every relevant camera to use the Metashape.Image.undistort() method as follows:
Code: [Select]
camera
Out[20]: 2022-03-08 19:36:20 <Camera '100_0006_0004.JPG'>

image = camera.photo.image()    # camera image
und_image = image.undistort(camera.sensor.calibration,center_principal_point=False, square_pixels=True)   # undistorted image
und_image.save(path=export_path+'/'+camera.label,compression=compression)

« Last Edit: March 09, 2022, 05:08:17 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

jedfrechette

  • Full Member
  • ***
  • Posts: 130
  • Lidar Guys
    • View Profile
    • www.lidarguys.com
Re: Undistorting images with ConvertImages class?
« Reply #2 on: March 09, 2022, 07:17:52 AM »
Thanks, using the Image class's undistort method is what we're doing now.

This is a fairly significant API change though so a couple follow up comments and questions. Prior to 1.6 the ConvertImages class was UndistortPhotos so I think the documentation should include a note to indicate that the intended usage of the class has changed completely from what it was originally created for. There are almost certainly other users out there with existing code who won't be able to use this class anymore and without some explanation it is hard to guess what the intended usage is.

If ConvertImages is no longer intended for performing undistortions why is use_initial_calibration still an option and what exactly does this option do?

How can users who are not programmers export undistorted images? Convert Images seems to be the only method exposed in the GUI and my testing indicates that in 1.8.1 it has the the same behavior as the API. Is there a different way to export undistorted images from the GUI that I'm overlooking?
Jed

Paulo

  • Hero Member
  • *****
  • Posts: 1324
    • View Profile
Re: Undistorting images with ConvertImages class?
« Reply #3 on: March 09, 2022, 10:17:00 AM »
Jed,

I agrree with you. Documentation remains Agisoft's  Aquiles heel.... Any change to a class should be well documented .....

Also curious to find out what use initial calibration does in Convert Image GUI... I suspect that a new Undistort GUI may come out in next releases...

Cheers,
Best Regards,
Paul Pelletier,
Surveyor