Forum

Author Topic: Smallest size depth map export  (Read 2697 times)

RGBttt

  • Newbie
  • *
  • Posts: 4
    • View Profile
Smallest size depth map export
« on: July 17, 2020, 05:58:25 PM »
Hi everyone,

I need to extract and store the scaled depth maps (exported after the mesh stage) for each image in my mosaics. For a given resolution, I am trying to find the smallest filesize to export, as they add up when there are tens of thousands of images.

The depth map needs to be a floating single channel image. Exporting as tiff (below) produces a single channel image with the actual values, so works great, but the file size is~20MB per the image resolution I need.

Code: [Select]

chunk = PhotoScan.app.document.chunk

for camera in chunk.cameras:

depth = chunk.model.renderDepth(camera.transform, camera.sensor.calibration)
depth = depth.convert(" ","F16")
depth.save("savepath" + camera.label + ".tif")

Exporting as .exr :

Code: [Select]
depth = depth.convert("RGB","F16")
depth.save("savepath" + camera.label + ".exr")

also works great and produces a 1.8 MB image for the same resolution - so huge improvement without much loss. But it makes a 3 channel image -- is there a way to export a single-channel exr from Metashape (or another format) that might even be smaller?

Thanks!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14817
    • View Profile
Re: Smallest size depth map export
« Reply #1 on: August 09, 2020, 01:57:31 AM »
Hello RGBttt,

You can try to vary the compression options to achieve smaller size output:

Code: [Select]
for camera in chunk.cameras:

depth = chunk.model.renderDepth(camera.transform, camera.sensor.calibration)
depth = depth.convert(" ","F16")
compr = Metashape.ImageCompression()
compr.tiff_compression = Metashape.ImageCompression().TiffCompressionDeflate
depth.save("savepath" + camera.label + ".tif", compression = compr)
Best regards,
Alexey Pasumansky,
Agisoft LLC

RGBttt

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Smallest size depth map export
« Reply #2 on: August 10, 2020, 02:25:10 AM »
Thank you Alexey! Exactly the solution I needed. Even smaller size than the .exrs.