Forum

Author Topic: Orthomosaic Background Differences  (Read 1557 times)

ierickson

  • Newbie
  • *
  • Posts: 10
    • View Profile
Orthomosaic Background Differences
« on: September 01, 2018, 12:58:37 AM »
Greetings,

I'm exporting an Orthomosaic from a project using the PhotoScan Python API (v 1.4.2). I've noticed the following behavior which I can't explain.

When exporting an image using the following code, I get a proper RGBA image with an alpha channel.

Code: [Select]
import PhotoScan

doc = PhotoScan.app.document
doc.open("/data/some_project.psx")
chunk = doc.chunks[0]

wkt = 'PROJCS["WGS 84 / UTM zone 16N",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-87],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32616"]]'

coord_sys = PhotoScan.CoordinateSystem(wkt)

chunk.exportOrthomosaic(
  "/data/some_ortho_image.tif",
  image_format=PhotoScan.ImageFormat.ImageFormatTIFF,
  projection=coord_sys,
  write_alpha=True)

When exporting an image using a the JPEG compression method, the resulting image is a simple 3 band RGB image with no alpha mask. Given that JPEG is simply the compression method, why would there be a difference in the number of output bands in the resulting image?

Code: [Select]
import PhotoScan

doc = PhotoScan.app.document
doc.open("/data/some_project.psx")
chunk = doc.chunks[0]

wkt = 'PROJCS["WGS 84 / UTM zone 16N",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-87],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32616"]]'

coord_sys = PhotoScan.CoordinateSystem(wkt)

chunk.exportOrthomosaic(
  "/data/some_ortho_image_without_alpha.tif",
  image_format=PhotoScan.ImageFormat.ImageFormatTIFF,
  projection=coord_sys,
  tiff_compression=PhotoScan.TiffCompression.TiffCompressionJPEG,
  write_alpha=True)

Notice the only difference in the two code samples is that of the tiff_compression parameter.

Ian

Dave Martin

  • Full Member
  • ***
  • Posts: 170
    • View Profile
Re: Orthomosaic Background Differences
« Reply #1 on: September 01, 2018, 10:17:19 AM »
Ian,

I suspect this relates to choosing JPEG compression for your TIF, as the original native JPEG format didn't, AFAIK, have an alpha channel, so I'm not sure what that compression algorithm is actually doing, as in some ways its like using a round cookie-cutter on a square biscuit.

If you want to minimise the size of your exported TIF, have you tried the other options? LZW, Packbits, Deflate (foot of page 41 of the manual).

Dave

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14854
    • View Profile
Re: Orthomosaic Background Differences
« Reply #2 on: September 01, 2018, 12:35:47 PM »
Yes, JPEG compression applied to TIFF export leads to the loss of alpha channel, as common JPEG doesn't support transparency.
Best regards,
Alexey Pasumansky,
Agisoft LLC