Forum

Author Topic: how to apply NDVI formula with pan-sharpening RedEdge-P bands?  (Read 815 times)

t.h

  • Newbie
  • *
  • Posts: 5
    • View Profile
I read MicaSense article which describes how to output pan-sharpening bands from input bands.

https://support.micasense.com/hc/en-us/articles/4416696717847-Pan-sharpening-processing-data-from-RedEdge-P-sensor-in-Agisoft-Metashape

This article explains how to output pan-sharpening bands first, then how to apply NDVI formula using output bands.

How do I need to do these process using Python API?

Paulo

  • Hero Member
  • *****
  • Posts: 1023
    • View Profile
Re: how to apply NDVI formula with pan-sharpening RedEdge-P bands?
« Reply #1 on: July 12, 2022, 06:41:13 AM »
Hello t.h.,

given a chunk with Micasense RedEdge P sensor data set, you can set the primary channel to channel 3 panchro by:
Code: [Select]
chunk.primary_channel = 2
then after processing you can set  sharpening formulae by:
Code: [Select]
chunk.raster_transform.formula = ['B1 * (B3 /  (0.2 * B1 + 0.2 * B2 + 0.2 * B4 + 0.2 * B5 + 0.2 * B6))/32768',
'B2 * (B3 /  (0.2 * B1 + 0.2 * B2 + 0.2 * B4 + 0.2 * B5 + 0.2 * B6))/32768',
'B4 * (B3 /  (0.2 * B1 + 0.2 * B2 + 0.2 * B4 + 0.2 * B5 + 0.2 * B6))/32768',
'B5 * (B3 /  (0.2 * B1 + 0.2 * B2 + 0.2 * B4 + 0.2 * B5 + 0.2 * B6))/32768',
'B6 * (B3 /  (0.2 * B1 + 0.2 * B2 + 0.2 * B4 + 0.2 * B5 + 0.2 * B6))/32768']

To enable the raster transform do:
Code: [Select]
chunk.raster_transform.enabled = True
and for orthomosaic export  look at (in API reference manuel p.36):
chunk.exportRaster(path='', format=, image_format=, raster_transform=Metashape.RasterTransformValue

This should get you started...
« Last Edit: July 12, 2022, 06:45:59 AM by Paulo »
Best Regards,

Paul Pelletier,
Surveyor

t.h

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: how to apply NDVI formula with pan-sharpening RedEdge-P bands?
« Reply #2 on: July 12, 2022, 10:07:31 AM »
Thank you Mr Paulo,

You answered about the way to output pan-sharpening bands.

So I want to know how to apply NDVI ,say, "NIR - RED"/"NIR + RED" formulae after your process.

Paulo

  • Hero Member
  • *****
  • Posts: 1023
    • View Profile
Re: how to apply NDVI formula with pan-sharpening RedEdge-P bands?
« Reply #3 on: July 12, 2022, 10:35:14 AM »
Yes T.h,

i guess after exporting the pan sharpened ortho you could do this in external software or reimport the ortho into Meta and then re do the calculation (B5-B3/(B5+B3))...

I am testing procedure on test rededge P data set to see how it works...
Best Regards,

Paul Pelletier,
Surveyor

Paulo

  • Hero Member
  • *****
  • Posts: 1023
    • View Profile
Re: how to apply NDVI formula with pan-sharpening RedEdge-P bands?
« Reply #4 on: July 12, 2022, 09:23:53 PM »
Dear Alexey,

to test the procedure defined in Micasense article https://support.micasense.com/hc/en-us/articles/4416696717847-Pan-sharpening-processing-data-from-RedEdge-P-sensor-in-Agisoft-Metashape mentioned by t.h., I downloaded sample RedEdge-P sample data from https://static.micasense.com/samples/rededge-p-soccer-field-sample-dataset.zip?_gl=1
and aligned a subset with success and generated an ortho (first defining primary channel as Panchro channel 3). When I apply the formulae to the ortho and try to display according to  False Color, I get an image that is really too intense not really natural... see attachements first display in color (R,G,B) then in False color (NIR,R,G)

Is there a way to get better results?

PS. I think the big difference in tone/brightness between left and right part of ortho (sunny/shady) may be due to lack of Réflectance calibration. Since I do not have panel csv for this dataset reflectance panel, I did not perform a calibration. However, I decided to do calibration using just Sun sensor and re generated the ortho so now I get a much better result.
see 3rd attachment with ortho displayed in False color after scaling output bands by 27000 instead of 32768.  It is much better but I think that output bands have to be differentially scaled to get even better results.
4th attachment shows False color after scaling RG bands by 5000 and NIR band by 270000. Much better!
Anyway it is critical to have good reflectance calibration before ortho building...
« Last Edit: July 13, 2022, 12:58:53 AM by Paulo »
Best Regards,

Paul Pelletier,
Surveyor