Hello everyone,
I attempted to calculate the average luminance of an HDR file using two different methods: pvalue and evalglare.
- When using pvalue, I executed the command:
pvalue -h -H -o mask.HDR
. For the output, I applied the following formula to calculate the luminance:
luminance = (RED*.263 + GREEN*.655 + BLUE*.082) * 179
The average luminance was then computed after excluding the zero values, which corresponded to the masked areas.
- When using evalglare, I ran the command: evalglare -d mask.HDR.
However, the results from these two methods differed.
Thank you in advance!
I believe evalglare applies a cosine weighting to the values, and is not simply a straight average as it is computing (vertical) illuminance. Unless your view type is -vth, the result should be different from an average computed with pvalue (less zeroes).
-Greg
1 Like
Evalglare considers the solid angle of the pixel (assuming the proper view header specification), which your pvalue command does not. you can use pcomb and pvalue like this to get the correct average luminance (again assuming proper view header) and your color coefficients:
pcomb -e ‘viewarea=2*3.14159;lo=(ri(1)*0.263+gi(1)*0.655+bi(1)*0.082)S(1)/viewarea179’ img.hdr | pvalue -o -b -h -H -d | total
make sure you change viewarea if you do not have a 180 degree field of view. If you are comparing this to the 3rd column of the detailed output this should match pretty closely, except evalglare uses the radiance built in bright function (I think) which assumes different color values:
CIE_rf=.265074126, CIE_gf=.670114631 and CIE_bf=.064811243, based on your coefficients, I assume you are not in radiance RGB, so you should make your image greyscale (or convert colorspace) before feeding it to evalglare (pcomb -e ‘lo=ri(1)*0.263+gi(1)*0.655+bi(1)*0.082’ img.hdr > img_grey.hdr)
1 Like
sorry, the formatting caused a typo in my formula:
pcomb -e ‘viewarea=2*3.14159;lo=(ri(1)*0.263+gi(1)*0.655+bi(1)*0.082)*S(1)/viewarea*179’ img.hdr | pvalue -o -b -h -H -d | total
pcomb -e ‘lo=ri(1)*0.263+gi(1)*0.655+bi(1)*0.082’ img.hdr > img_grey.hdr
Hi Greg,
My view type is -vth (Hemispherical fisheye).
Hi Stephen,
Thanks a lot! I tried the formula you provided.
For the first one, the output value was quite low.
For the second one, when I put the img_grey.hdr into evalglare, it gave back “error: header contains invalid exposure entry!!! check exposure and correct header setting !”
yes, Stephen is right: Evalglare considers the solid angle of each pixel to calculate average luminances (this is valid for all functions in evalglare), but not cosine weighted! (cosine weighting is only used in addition when calculating illuminance values).
this error message is quite clear: there is a problem with your header. If you post the .hdr picture I can have a quick look to see potential reasons.
As evalglare is relying on correct header information it stops automatically when the header contains invalid or suspicious information regarding exposure or projection method.
Check that all the formatting with the appropriate quotes, sometimes copy paste changes things, and different shells expect different marks.
I tried my commands on one of my own images:
evalglare -d 230819_00124_02.hdr
# yields: 500.567537
pcomb -e 'viewarea=2*3.14159;lo=(ri(1)*0.263+gi(1)*0.655+bi(1)*0.082)*S(1)/viewarea*179' -o 230819_00124_02.hdr | pvalue -o -b -h -H -d | total
# yields 500.724193
pcomb -e 'lo=ri(1)*0.263+gi(1)*0.655+bi(1)*0.082' -o 230819_00124_02.hdr > img_grey.hdr
evalglare -d img_grey.hdr
# yields 500.706943
so (in this case) the color difference has only a slight effect. As for the header issue, this is probably the cause of both problems, you can try putting a -o before the input file in the pcomb commands (as I did above, but not needed in my case as the images were already exposure nullified).
Hi Jan,
Thanks a lot. When using evalglare, the average lumiance was 10.48. When using pvalue command I mentioned in the topic above, the output was 9.74.
However, I am having trouble running Stephen’s commands.
Thanks for the file. The key issue remains your pvalue command does not account for the solid angle of each pixel. A secondary issue is based on your header, you are using radiance primaries, so your R,G,B multipliers are incorrect and you can use the default radiance ones. I also see from your header that you are on windows, so formatting the commands is definitely an issue (and I can’t help with that). But to show you what your results should be:
Downloads % evalglare -d 6-5.HDR
10.479421
Downloads % pcomb -h -w -e 'viewarea=2*3.14159;lo=(li(1))*S(1)/viewarea*179' -o 6-5.HDR | pvalue -o -b -h -H -d | total
10.0082932
Downloads % pvalue -o -b -h -H -d 6-5.HDR| rcalc -e '$1=$1*179;cond=$1' | total -m
9.77981468
There is a diffference in how pcomb and evalglare calculate solid angle, and evalglare is also going to do a better job at masking the in/out of view pixels (since this image has a blur (pfilt -r 0.6), some of the edge pixels are close to, but not zero so they are bringing the average down. Sorry I can’t help more
Hi Stephen,
I successfully ran all the commands on windows. Thanks a lot for your help!!!
One more question, if evalglare can do a better job at masking the in/out of view pixels, can it output the luminance value for each pixel like pvalue?
No, I don’t think it can. And as I thought about this more, I don’t think this is the issue. In both cases the outer rim of pixels will be artificially low (but not to make a significant different) because of the pfilt command (some of the black blends into the image) and by using the solid angle in the pcomb command with a hemispheric fisheye will zero out these values. It could be because of the different solid angle calculations and the large difference a result of your small bright glare sources landing just wrong, or it could be something else. A 5% discrepancy is surprising.
Ok, I figured out the issue:
pcomb -h -w -e 'lo=S(1)' -o 6-5.HDR | pvalue -o -b -h -H -d | total
6.01511079
the solid angle of valid pixels according to pcomb is only 6.015, not 6.28. This is because of an aliasing effect at the edge. if you use this value in the denominator of the average:
pcomb -h -w -e 'viewarea=6.01511079;lo=(li(1))*S(1)/viewarea*179' -o 6-5.HDR | pvalue -o -b -h -H -d | total
10.4543335
you get something quite close to evalglare. Note if you use a different resolution image, then you need to recalculate this total solid angle.
1 Like