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.
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?
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