Usage of ximage

Hi list,
I have a question about the command “ximage”. We can use the interactive option “l” to get the average luminance of the selected area in the HDR image. However, since the image is too large to display completely on the screen, so I can’t choose this specific area to get its luminance that is in the center of the image. The HDR image is 5496x3670 pixels while the analysed area is almost 500x400 pixels.

In my opinion, using the command “pvalue” and the masked image to get the RGB values is kind of troublesome. And I used “pcompos” to crop this image and the luminance value is much smaller than normal one. It seems that “pcompos” is not suitable to such a problem. Is there any other efficient solution? Any suggestion is appreciated!

1 Like

Hi Lee,

Since you are interested in the average luminance, and want to keep the interactive/ximage approach, you can use pfilt to reduce the image size:

pfilt -1 -e 1 -y 1000 -p 1 myimg.hdr > myimg_sm.hdr

the “-1 -e 1” is important for maintaining original values, otherwise an image exposure is applied. The -y 1000 tells the program to reduce the image to 1000 pixels high (chosen to fit on a reasonable resolution monitor) and the -p 1 keeps the pixel aspect ratio at 1, which will help to correctly set the x-resolution.

If you want a non-interactive approach, piping pcompos to pvalue to total works well, but there are also some important flags:

pcompos -x 500 -y 400 =00 myimg.hdr 250 200 | pvalue -o -b -h -H -d | total -m | rcalc -e '$1=179*$1'

the pcompos flags here crop to the center of the image: set the output size to 500x400, set the anchor to the image center, offset in each direction by half the output. You can adjust the offest or change the anchor point (see the pcompos man page) to crop any window. You can pipe the pcompos output into ximage or a temporary image to make sure the cropping is correct. The pvalue flags in order given are: original pixel values, brightness (instead of rgb), no header, no resolution string, data only (no pixel coordinates). Total -m calculates the mean.

The ximage “l” option prints luminance, which is 179 times the stored values, so don’t forget to add this multiple, here handled by rcalc.

Hi Stephen,
Thanks for your detailed advice. I am using the first method to get the average luminance and the luminance is almost 1240 which seems OK. Meanwhile, I tried the second way but the result is 31.09 that is too small.

I guess this problem is related to the command “pcompos”. Once I got the RGB values which was also much smaller of a cropped HDR image using “pcompos” and “pvalue”. You can refer to this post:

Until just recently, pcompos would elide the exposure value even if only one image is given. I have since improved the code, so the latest HEAD (just released yesterday in fact) corrects this problem, and your command should now work.

Obviously, you need to install the latest HEAD for this to be true from here.


Hi Greg,
Thanks a lot for your reply! Finally this bug of “pcompos” has been fixed. The result is nearly expected. It means anyone who has been hampered with such similar problem can turn to use the upgraded version of Radiance!