Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: pyeah on January 21, 2019, 12:01:14 PM

Title: False color export with MicaSense camera (python)
Post 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:


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:


But I am not sure how to use them here.

Thanks for looking into this.

Best regards,
Pieter-Jan



Title: Re: False color export with MicaSense camera (python)
Post by: Alexey Pasumansky on January 21, 2019, 01:16:01 PM
Hello Pieter-Jan,

If you need to save the orthomosaic in the False Colors representation, then I suggest the following code:
Code: [Select]
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:
Code: [Select]
{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)}