Reflectance Estimation


#47

Hi community,
@domenzain @muzammil360
I ask help to calculate the sunshine irradiance. I don’t know the steps needed to get this value. I have read the exif data of my image and I have alredy calculated the sequoia irradiance for each pixel. However, to obtain the reflectance value firstly I have to calculate the sunshine irradiance and K value. Could you guide me?

Thanks in advance.

J.J.


#48

Dear @jjurado, the first step in calculating Sunshine Irradiance is extracting the IrradianceList data in exif. This tag has all the essential information you need to compute sunshine irradiance. For some reason, the data in IrradianceList is BASE64 encoded. Therefore, first step would be to decode the BASE64 data. Once you have that, rest of the process is pretty simple and I can guide you how to do that later.


#49

@muzammil360 I have tested different c++ methods to BASE64 decode the IrradianceList tag and I don’t get any good result. I have extracted the string belong to this tag but when I try to decode, it does not work. The code used is:

static std::string base64_decode(const std::string &in) {

std::string out;

std::vector<int> T(256,-1);
for (int i=0; i<64; i++) T["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i]] = i; 

int val=0, valb=-8;
for (uchar c : in) {
    if (T[c] == -1) break;
    val = (val<<6) + T[c];
    valb += 6;
    if (valb>=0) {
        out.push_back(char((val>>valb)&0xFF));
        valb-=8;
    }
}
return out;

}

IrradianceList: e//kGwAAAABEACAAAQBkABuW9sLRpDzBGGF4PRcL6BsAAAAAQwAgAAEAZADBYfbC2cUvwQNQJ76NL+sbAAAAAEMAIAABAGQAEnr1wgXgV8HcSArACB/uGwAAAABDACAAAQBkAFLT9sJTkkLBMZ00vc8r8RsAAAAAQwAgAAEAZAAgnvbCvR09wdZ7Er9GOfQbAAAAAEMAIAABAGQApc/2wm3ML8Eu8VE++0H3GwAAAABCAB8AAQBkAM189sIOEjLBHaAzv7hO+hsAAAAAQwAgAAEAZAAba/fCnF8+waGaeD8tV/0bAAAAAEQAIAABAGQA3xn4wlN8JcFP7vA/TGYAHAAAAABEACAAAQBkANnD+MJmYhfBgYaTQKJ1AxwAAAAAQwAgAAEAZACseffCWls2wRkwoz/GfgYcAAAAAEMAHwABAGQA4mr3wkmJMsE4Oow/+ZIJHAAAAABDACAAAQBkACSD98I5jjfByKlZPyadDBwAAAAAQwAgAAEAZAA75vfCzQo6wSr9ez9irQ8cAAAAAEQAIAABAGQADo33wsgiN8HwGkw+HL4SHAAAAABCAB8AAQBkADFP98IvaAfBZifhvkbIFRwAAAAAPwAdAAEAZACSsvfCTEjPwKAS1D993RgcAAAAAD4AHQABAGQA90z4wrahPz8fXEPA0OcbHAAAAAA9AB0AAQBkAChM+MIP+cjARyoXwAH5HhwAAAAAPAAcAAEAZAArRvjCjusswXt3eb+WCCIcAAAAADwAHAABAGQAHFr3wkhaX8EOp0LAbw8lHAAAAAA9AB0AAQBkAMAQ98K48XrBYApUwDIgKBwAAAAAQAAeAAEAZADnF/jCC+1NwZmH27/sKiscAAAAAEAAHwABAGQAjXD3wvuRVcEFvzjAuTguHAAAAABBAB8AAQBkAH3K+MLhsyTBIHcrP4JHMRwAAAAAQAAeAAEAZAAcfvnCzuP+wPjJjkA=

J.J.


#50

Well, the result that you get out of BASE64 decoding needs to be interpreted properly. Let me share some material with you that will allow you to interpret it correctly.

I know this sounds annoying but onces you will understand it, it will start to make sense.


#51

Okey, I have tested the same decoded method in c++ with others “string” examples and it works fine. I hope your help.


#52

Hi @jjurado,

The Sunshine Irradiance tag is detailed on another thread. Look for IrradianceList amongst the topics or follow this link to a working implementation in that same thread. @seanmcleod helpfully provided it.


#53

Hi @muzammil360 and @domenzain,

I have extracted all information of structures array like you can see in the follow image:

I have calculated Sequoia Irradiance and the follow stept is the calculation of Sunshine Irradicance. I have to apply this formula: Captura but I don’t understand how I must resolv it. Could you guide me?

Thanks.

J.J.


#54

@jjurado, I am not sure if its correct. There is something that’s telling me that CH0 count should not be less than CH1 count. Besides, I wouldn’t expect Gain_Index to be 1024. Plus the integration time also seems to be HUGE. Plus your Time_Stamp also doesn’t seem to be correct.

Are you sure you are using correct endianness? You should be using little-endian.

Following is what I would expect after decoding:

  • Gain index should be [0, 3]
  • Integration time ~600
  • CH0 is usually greater than CH1
  • Time stamp can be converted to normal human readable dateandtime using online converters.

#55

#56

Hi again,

thanks for your help, I had an error in my code but now, it has been resolved. The Irradiancelist tag of my photo is the follow:

Captura07

I think that this data is correct so now I have to calculate the sunshine sensor irradiance for each image is it correct? My ultimate goal is to calculate the reflectance map of my image @muzammil360 and @domenzain could you guide me to obtain this value?

Thanks!


#57

I only have one question, is the sunshine sensor really used?

  • I work with Pix4D and its final results are reflectance maps with values from 0 to 1. Ok

  • Following the document SEQ AN 01, I obtain the irradiance. Ok
    image image

  • My image happens to have values of 0 +20. okay. But from here, what?

After reviewing a thousand times forum information and the very valuable help of @muzammil360 (thanks for your time) , I do not find any satisfactory result except one, which is explained in the official page of Micasense, so:
image, image, where:

  • K: calibration factor for the each band
  • Pi: known reflectance of the Calibration Panel
  • Avg (Li): average radiance values of the pixels that fall inside the calibration panel
    1
    I get values from 0 to 1 :slight_smile:
    Where are the irradiance values used?

#58

@joan.cano, the formula you have used above converts raw pixel values to sequoia irradiance. These is a way to get sunshine irradiance as well. And then two of these along with a calibration coefficient (specific to every fight and camera) are used to compute reflectance. If you have not already, then take a look at this document


#59

Hi everybody,

we are using the Sequoia and the sunshine sensor within our eBee plus drone.
Currently, I try to understand, where, how and when our tif files are processed into reflectance.
We are using eMotion and Pix4D.

I read the entire converstion about the sunshine sensor dilemma on the Parrot Community Forum and the conversation of this developer forum.
To be honest I already fail to find the irradiance measurements and the list in the exif tags.

Would be great, if someone can help me.
I wrote a short python code to print out the exif tags:

import exifread

f = open('N:/exiftest/IMG_171108_114510_0000_NIR.tif', 'rb')

# Return Exif tags
tags = exifread.process_file(f)
print tags

**Result:**


> {'EXIF ApertureValue': (0x9202) Ratio=2147483647/943945856 @ 10316,
>      'EXIF BodySerialNumber': (0xA431) ASCII=PI040378AA6I001305 @ 10414,
>      'EXIF DateTimeDigitized': (0x9004) ASCII=1970:01:01 00:03:09 @ 10288,
>      'EXIF DateTimeOriginal': (0x9003) ASCII=2017:11:08 11:45:10 @ 10268,
>      'EXIF ExifImageLength': (0xA003) Long=960 @ 10152,
>      'EXIF ExifImageWidth': (0xA002) Long=1280 @ 10140,
>      'EXIF ExposureMode': (0xA402) Short=Auto Exposure @ 10200,
>      'EXIF ExposureTime': (0x829A) Ratio=3865470/2147483647 @ 10244,
>      'EXIF FNumber': (0x829D) Ratio=2147483647/976128896 @ 10252,
>      'EXIF FocalLength': (0x920A) Ratio=2147483647/539568768 @ 10332,
>      'EXIF FocalLengthIn35mmFilm': (0xA405) Short=30 @ 10212,
>      'EXIF FocalPlaneResolutionUnit': (0xA210) Short=4 @ 10188,
>      'EXIF FocalPlaneXResolution': (0xA20E) Ratio=2147483647/8053064 @ 10364,
>      'EXIF FocalPlaneYResolution': (0xA20F) Ratio=2147483647/8053064 @ 10372,
>      'EXIF ISOSpeedRatings': (0x8827) Short=400 @ 10008,
>      'EXIF ImageUniqueID': (0xA420) ASCII=7324E23E672B24115EC6BAF84BD804D5 @ 10380,
>      'EXIF MaxApertureValue': (0x9205) Ratio=2147483647/943945856 @ 10324,
>      'EXIF ShutterSpeedValue': (0x9201) Signed Ratio=2147483647/235526848 @ 10308,
>      'EXIF SpectralSensitivity': (0x8824) ASCII=790 nm @ 10260,
>      'EXIF SubSecTime': (0x9290) ASCII=172315 @ 10340,
>      'EXIF SubSecTimeDigitized': (0x9292) ASCII=395161 @ 10356,
>      'EXIF SubSecTimeOriginal': (0x9291) ASCII=172315 @ 10348,
>      'EXIF Tag 0x9211': (0x9211) Long=0 @ 10092,
>      'GPS GPSAltitude': (0x0006) Ratio=120697441/1000000 @ 10644,
>      'GPS GPSAltitudeRef': (0x0005) Byte=0 @ 10504,
>      'GPS GPSDate': (0x001D) ASCII=2017:11:08 @ 10692,
>      'GPS GPSLatitude': (0x0002) Ratio=[54, 9, 33001569/1000000] @ 10596,
>      'GPS GPSLatitudeRef': (0x0001) ASCII=N @ 10456,
>      'GPS GPSLongitude': (0x0004) Ratio=[13, 23, 3739209/250000] @ 10620,
>      'GPS GPSLongitudeRef': (0x0003) ASCII=E @ 10480,
>      'GPS GPSMapDatum': (0x0012) ASCII=WGS-84 @ 10684,
>      'GPS GPSSpeed': (0x000D) Ratio=2147483647/54907012 @ 10676,
>      'GPS GPSSpeedRef': (0x000C) ASCII=K @ 10552,
>      'GPS GPSStatus': (0x0009) ASCII=A @ 10540,
>      'GPS GPSTimeStamp': (0x0007) Ratio=[11, 45, 5131/500] @ 10652,
>      'GPS GPSVersionID': (0x0000) Byte=[2, 2, 0, 0] @ 10444,
>      'Image ApplicationNotes': (0x02BC) Byte=[] @ 2940,
>      'Image BitsPerSample': (0x0102) Short=16 @ 54,
>      'Image Compression': (0x0103) Short=Deflate @ 66,
>      'Image DateTime': (0x0132) ASCII=2017:11:08 11:45:10 @ 2920,
>      'Image ExifOffset': (0x8769) Long=9962 @ 246,
>      'Image GPSInfo': (0x8825) Long=10434 @ 258,
>      'Image ImageDescription': (0x010E) ASCII=790 nm @ 328,
>      'Image ImageLength': (0x0101) Short=960 @ 42,
>      'Image ImageWidth': (0x0100) Short=1280 @ 30,
>      'Image Make': (0x010F) ASCII=Parrot @ 336,
>      'Image MinSampleValue': (0x0118) Short=0 @ 174,
>      'Image Model': (0x0110) ASCII=Sequoia @ 344,
>      'Image PhotometricInterpretation': (0x0106) Short=1 @ 78,
>      'Image PlanarConfiguration': (0x011C) Short=1 @ 186,
>      'Image Predictor': (0x013D) Short=Horizontal differencing @ 222,
>      'Image RowsPerStrip': (0x0116) Short=3 @ 150,
>      'Image SamplesPerPixel': (0x0115) Short=1 @ 138,
>      'Image Software': (0x0131) ASCII=v1.2.1 @ 2912,
>      'Image StripByteCounts': (0x0117) Long=[4439, 4438, 4428, 4464, 4417, 4461, 4425, 4422, 4449, 4450, 4476, 4449, 4492, 4461, 4470, 4459, 4451, 4463, 4491, 4482, ... ] @ 1632,
>      'Image StripOffsets': (0x0111) Long=[10704, 15144, 19582, 24010, 28474, 32892, 37354, 41780, 46202, 50652, 55102, 59578, 64028, 68520, 72982, 77452, 81912, 86364, 90828, 95320, ... ] @ 352,
>      'Image Tag 0x000B': (0x000B) ASCII=eMotion 3.3.4 @ 314,
>      'Image Tag 0xC619': (0xC619) Short=[2, 2] @ 270,
>      'Image Tag 0xC61A': (0xC61A) Long=[5400, 5376, 5356, 5368] @ 9894,
>      'Image Tag 0xC62F': (0xC62F) ASCII=PI040378AA6I001305 @ 9910,
>      'Image Tag 0xC68B': (0xC68B) Byte=[73, 77, 71, 95, 49, 55, 49, 49, 48, 56, 95, 49, 49, 52, 53, 49, 48, 95, 48, 48, 48, 48, 95, 78, 73, 82, 46, 84, 73, 70, 0] @ 9930}

So, this is all I get. No “IrradianceCalibrationMeasurement”, no “IrradianceList” at all


#60

First, I would update the Firmware of your camera, you’re at 1.2.1, the most recent is 1.4.1


#61

You can see the exif information in your images using exiftool from here. If you want to understand how tif files are converted to reflectance, these two documents are going to be helpful

https://1drv.ms/b/s!Au_f2CPYR0HD-DYszS5NTkXt-2kU

http://forum.developer.parrot.com/uploads/default/original/2X/3/383261d35e33f1f375ee49e9c7a9b10071d2bf9d.pdf


#62

Thanks, I will test the new camera update on wednesday.
Keep you informed!


#63

Hi everbody,

I actually found the problem.
Neither IrfanView nor the Python module “exifread” show all tags that are hidden in the image.

Finally all tags could be extracted with exiftools in the command line.
Unfortunately it does not work in Python.

Anyway, the problem was not the firmware version.

Thanks for your help


#64

Workaround here :

Clone or download archive and install with
python setup.py install


#65

Hi @kikislater,

For reflectance calculation, we must obtain some information which is embedded in image file as a exif information. While some of them are fixed (a,b,c coefficients), others are changeable (expsure time…) image by image. As you know we need exposure time to calculate reflectance but nearly all of the images have different value. So how can we obtain this value automaticly? or we must obtain this values manually to process our images.

Best…


#66

Hi,
Simply write a python script. Using python exiftool module help. You could parse every file in a batch and compute it for every pixel.