The luminance value of HDR file changed after using Photoshop for masking file

Hello everyone,
I am trying to generate a masking file for the HDR file. However, after applying the masking file in Photoshop, the luminance value of HDR file changed. Perhaps the problem is the way of Photoshop dealing with RGB information. But I don’t know how to solve it. Thanks a lot!

Photoshop doesn’t preserve the EXPOSURE= line in an HDR file. Two ways you can fix this:

ra_xyze -r -o capture.hdr > normalized.hdr

Then, do your masking operation in Photoshop on “normalized.hdr”. No post-processing needed. Alternatively, you can use pcomb if your mask is converted to an HDR image with 1’s where you want the image to appear and 0’s elsewhere:

pcomb -e “m=gi(2);ro=m*ri(1);go=m*gi(1);bo=m*bi(1)” -o capture.hdr mask.hdr > result.hdr

Note I used the “-o” for pcomb as well. This is doing the same thing as ra_xyze in the first method, removing the exposure from the input so it doesn’t mess up the output.

Hope this helps!
-Greg

Thanks a lot, Greg! :smiley:

Hello everyone,

If a masking file has already been applied to an HDR file, can pvalue extract the luminance information from the unmasked area? One approach is to exclude all zero values after using pvalue. However, if there are naturally occurring zero values in the unmasked area, this might lead to errors.

Thanks,
Green

You shouldn’t create a new post on the same (or very similar topic). I understand why you did it, because you marked the previous post as “solved.” I have unmarked it, again.

Since nothing in Radiance ever seems to really be “solved,” we should just disable this feature of Discourse for our purposes…

To compute the area average in a masked region, you can prepare an HDR mask image as described above, where parts you want have an RGB value of (1 1 1) and parts you don’t have (0 0 0). Then, simply divide the sum of all the masked pixels by the sum of all the 1’s to get your average, e.g.:

pvalue -h -H -df -b mask.hdr | total -if
pcomb -e “m=gi(2);ro=m*ri(1);go=m*gi(1);bo=m*bi(1)” -o capture.hdr mask.hdr | pvalue -h -H -df +e 179 -b | total -if

Then, manually divide the number from the second command (total luminance) by the number from the first (total unmasked pixels). This result will be in photometric units.

Cheers,
-Greg

Sorry, Greg. My bad. :sweat_smile:

I am not trying to get the average value. I just want to know if pvalue can extract the luminance information from the unmasked area (for every pixel) without missing any possible zero value in the area that is not masked.

Thanks,
Green

I don’t understand this question. You will get a zero value on output if there was a zero value on input, regardless of whether the mask includes the pixel or not. Both mask and pixel must be non-zero to get a non-zero output.

Best,
-Greg

Hi Green,
It is also more difficult for people to understand if you ask half of the question in private messages and causes at the end also more effort for everyone. I copy here below the relevant other questions and answers regarding creating a “band-mask”, because the solution to your problem is rather trivial knowing the steps before:

Question: When generating the masking file, I first used the evalglare -c command to export an image and then imported it into Photoshop, where I manually created a masking file along the boundary of the horizontal band. This process is not highly automated. Is there a more efficient method? I am particularly interested in this because a more precise boundary extraction would facilitate subsequent operations with commands like pvalue.

Answer: the combination of evalglare and pcomb can do the job efficiently. for linux/mac based systems you can do it like this (for windows you need to adjust the variable or even remove it):
#generate a colored band-image “band.hdr” with evalglare, adjust the variable imagestetting to your images to be evaluated
imagesetting=" -vta -vv 180 -vh 180 -x 1000 -y 1000 "
echo void glow sky_mat 0 0 4 1 1 1 0 sky_mat source sky 0 0 4 0 0 1 180 |oconv -f - |rpict -vp 0 0 0 -vd 0 0 1 -vu 1 0 0 $imagesetting |evalglare -B 0.349 -c band.hdr -d
#create masked image from the “input.hdr” using the band.hdr as mask:
pcomb -e “m=if(gi(1)-3*ri(1),1,0);ro=ri(2)*m;go=gi(2)*m;bo=bi(2)*m” band.hdr inputhdr > output.hdr
The “trick” here is that we know that the green channel is much larger than the red, so this is used as masking information. using “0” as decision is sometimes problematic as the internal variable format sometimes the 0 sometimes increases by a very small amount and is therefore not super reliable (in evalglare I use also a value slightly larger than 0 for that reason). In your case using the green information on a uniform image does the job perfectly.

So, what you can do at the step using pcomb that you simply add an “offset” to all channels of the pixels that are inside the mask, e.g. 10. Then when applying pvalue you simply remove the zero-pixels (as they are outside the mask) and for the remaining pixels you subtract again the 10 per channel. That’s a trivial solution, looks like this then if you use awk for the out-sorting/subtraction:
pcomb -e “m=if(gi(1)-3*ri(1),1,0);ro=ri(2)*m+10;go=gi(2)*m+10;bo=bi(2)*m+10” band.hdr input.hdr |pvalue -h |awk ’ { if (NR==1) {print $0 } else {if($3+$4+$5>0) print $1,$2,$3-10,$4-10,$5-10}}’ >output.txt
The output is then the same as from the pvalue -h call, but the pixels outside the mask are removed, zero values inside the mask are preserved. As mentioned before, with such result you have hard time to restore information about the solid angle of each pixel, and pixel based comfort metrics typically dont make sense as values change if you have a different projection method.
But, you question is solved to keep all pixels inside the mask, independent on their value.
Cheers
Jan

1 Like

Hi Jan,
Thanks a lot! I will ensure consistency and continuity in the questions and information in the future. :smiley: