Forum

Author Topic: calibrating reflectance in python  (Read 2493 times)

william

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
calibrating reflectance in python
« on: March 25, 2018, 09:26:35 PM »
Hi,

Using Micasense Rededge photos, I'd like to try calibrating reflectance in python:
Code: [Select]
chunk.addPhotos(photo_paths, PhotoScan.MultiPlaneLayout)
chunk.locateReflectancePanels()
chunk.loadReflectancePanelCalibration(path='panel.csv')
chunk.calibrateReflectance()
# ...proceed with processing.

I have two questions:

1. How should panel.csv be formatted? I currently have a csv file with:
Quote
band,albedo
blue,0.709
green,0.729
red,0.728
rededge,0.712
nir,0.672

2. I see a Tasks.CalibrateReflectance with fields use_sun_sensor and use_reflectance_panels. But how can I set both those values to true using chunk.calibrateReflectance?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14110
    • View Profile
Re: calibrating reflectance in python
« Reply #1 on: March 26, 2018, 03:25:07 PM »
Hello William,

CSV file that is expected on input for the .loadReflectancePanelCalibration() function is just a two-column text file (see a part f it below):
Code: [Select]
Wavelength(nm), Reflectance
652.0, 0.6804
653.0, 0.6812
654.0, 0.6814
655.0, 0.6809
656.0, 0.6806
657.0, 0.681
658.0, 0.681
659.0, 0.6808
660.0, 0.68
661.0, 0.679
662.0, 0.6788
663.0, 0.6788
664.0, 0.6788
665.0, 0.6789
666.0, 0.6776
667.0, 0.6762
668.0, 0.6759
669.0, 0.6766
670.0, 0.677
671.0, 0.6765
672.0, 0.6755
673.0, 0.6748

In case you need to load the parameters from the file like you've mentioned, you can use the following approach:

Code: [Select]
albedo = {"Blue": "0.65952", "Green": "0.67788", "Red": "0.67718", "NIR": "0.66653", "Rededge": "0.6223266"} #values read from the file

for camera in chunk.cameras:
    if camera.group.label != "Calibration images":
        continue
    for plane in camera.planes:
        plane.meta["ReflectancePanel/Calibration"] = albedo[plane.sensor.bands]
 

PhotoScan.Tasks class can be used in the following way to perform the reflectance calibration:
Code: [Select]
task = PhotoScan.Tasks.CalibrateReflectance()
task.use_reflectance_panels = True
task.use_sun_sensor = True
task.apply(chunk)
If you use this approach, there's no longer a need to use .calibrateReflectance() function. In the next version update this function would have arguments to enable both options.
Best regards,
Alexey Pasumansky,
Agisoft LLC

william

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: calibrating reflectance in python
« Reply #2 on: March 27, 2018, 02:37:31 AM »
Thanks, Alexey. I'll try that right away.

By the way, as per http://www.agisoft.com/forum/index.php?topic=7730.msg41027#msg41027, should I run the following before calibrating? 

Code: [Select]
for camera in chunk.cameras:
    camera.plane.sensor.normalize_sensitivity = True

« Last Edit: March 27, 2018, 02:39:22 AM by william »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14110
    • View Profile
Re: calibrating reflectance in python
« Reply #3 on: March 27, 2018, 07:00:27 PM »
Hello William,

You need to use the following:

Code: [Select]
for sensor in chunk.sensors:
    sensor.normalize_sensitivity = True
Best regards,
Alexey Pasumansky,
Agisoft LLC

william

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: calibrating reflectance in python
« Reply #4 on: April 02, 2018, 08:30:04 PM »
Thanks, Alexey. I successfully ran this based on your suggestions. I just had to make the following edits:

Code: [Select]

for camera in chunk.cameras:
    if camera.group and camera.group.label == "Calibration images":
        for plane in camera.planes:
            plane.meta["ReflectancePanel/Calibration"] = albedo[plane.sensor.bands[0]]

Additionally, I noticed both 'Red edge' and 'Rededge' can appear as bands depending on the camera.