Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: pyeah on January 21, 2019, 12:01:14 PM
-
Hello,
I am trying to export a False Color orthomosaic from a MicaSense flight campaign, using the python API.
In the interface, I am able to do this:
- Tools => Set Raster Transform => Transform tab => load three bands (B3/10000, B2/10000 and B1/10000
- Tools => Set Raster Transform => Palette tab => choose False Color from the dropdown
If I want to transform this in Python code, I end up with something like this:
chunk.raster_transform.formula=["B3/10000","B2/10000","B1/10000"];
chunk.raster_transform.palette = "False Color";
chunk.exportOrthomosaic("D:/test.tif", raster_transform=PhotoScan.RasterTransformPalette);
However, selecting the palette does not seem to work here. In the API, I notice the following keywords in the RasterTransform definition:
- false_color => list of false color channels
- palette => dict object type
But I am not sure how to use them here.
Thanks for looking into this.
Best regards,
Pieter-Jan
-
Hello Pieter-Jan,
If you need to save the orthomosaic in the False Colors representation, then I suggest the following code:
chunk.raster_transform.formula=["B3/10000","B2/10000","B1/10000"]
chunk.raster_transform.false_color = [0, 1, 2] #this defines R-G-B channels order in the output
chunk.exportOrthomosaic("D:/test.tif", raster_transform=PhotoScan.RasterTransformPalette)
So you just need to correct one line and define the order of false RGB colors.
raster_transform.palette should be used to define the coloring profile that is applied to the index value in the defined range. It looks like the following dictionary:
{0.0: (0, 0, 255),
0.25: (0, 255, 255),
0.5: (0, 255, 0),
0.75: (255, 255, 0),
1.0: (255, 0, 0)}