Doing HRD rendering one should compute the average luminance value of the scene and then scale the image with respect of it. Fairly simple

What I don’t understand, it’s why shlould I compute my average like this:

1/pixelcount * exp(sum of ln(L(x, y))

Why log? Why not
1/pixelcount * sum of ln(L(x, y)

As far as I understand luminance is superpositionable value.

One more question: should I take RGB luminance values(one for each chanel) or should I compute the sum(= intencity)? Computing average for each color chanel would shift colors, wouldn’t it?

Both versions are kind of wrong as far as I can see.

Maybe the following was intended:
exp((sum of ln(L(x,y)))/pixelcount)
?

That would leave the issue that ln(0) is undefined, or, at best, -infinity. Not very nice for this application.

I can’t judge whether or not a non-linear average is beneficial for exposure, as I have no hands on experience. However, if that’s desired, a geometric mean (RMS*) is much safer than what you currently have. SMR* would be closer, and numerically safe, too.

I’d say you should try to get a linear mean implemented first. Once that’s working, there’s still time to play around with those other approaches.

*RMS <=> root of mean square: m=sqrt((sum of all(x²))/n)
by SMR I mean the reverse: m=((sum of all(sqrt(x)))/n)²

“One more question: should I take RGB luminance values(one for each chanel) or should I compute the sum(= intencity)? Computing average for each color chanel would shift colors, wouldn’t it?”

Yup. Exposure (what you’re simulating) doesn’t do this in the real world, and thus you shouldn’t do it. It wouldn’t look real (might be an interesting ‘special effect’ though …).

Originally posted by Zengar:
One more question: should I take RGB luminance values(one for each chanel) or should I compute the sum(= intencity)? Computing average for each color chanel would shift colors, wouldn’t it?
[/b]

You should use something like
L = 0.3 R + 0.59 G + 0.11 B