Sign in to follow this  
Viik

RE: Histogram computation on HDR rendering

Recommended Posts

Original discussion here

In ShaderX 6 article of Franceso Carucci "HDR Meets Black & White 2", author mentioned absolute_max_luminance and gave brief explanation of where to get it's numerical value. As a previous topic starter, I was confused too by that parameter, but I've found these slides and according to them absolute_max_luminance used to build bins of histogram, is a maximum luminance of the scene, that needs to be calculated BEFORE building histogram as it will define the highest histogram bin (page 20).

Hope it helps.

Triying to wrap my head over mentioned histogram equalisation approach, looks like it needs "summed area table" approach to get it working or sort of similar algorithm. Not really getting how "remapping" process works algorithmically.

PS: Please merge threads if possible.

Share this post


Link to post
Share on other sites
Quote:
Original post by Viik
Original discussion here

In ShaderX 6 article of Franceso Carucci "HDR Meets Black & White 2", author mentioned absolute_max_luminance and gave brief explanation of where to get it's numerical value. As a previous topic starter, I was confused too by that parameter, but I've found these slides and according to them absolute_max_luminance used to build bins of histogram, is a maximum luminance of the scene, that needs to be calculated BEFORE building histogram as it will define the highest histogram bin (page 20).

Hope it helps.

Triying to wrap my head over mentioned histogram equalisation approach, looks like it needs "summed area table" approach to get it working or sort of similar algorithm. Not really getting how "remapping" process works algorithmically.

PS: Please merge threads if possible.


Histogram equalization is actually easy, here's some code to help you understand:



float probabilityR[256];
float probabilityG[256];
float probabilityB[256];
float sumR[256];
float sumG[256];
float sumB[256];
memset(probabilityR,0,sizeof(float)*256);
memset(probabilityG,0,sizeof(float)*256);
memset(probabilityB,0,sizeof(float)*256);
memset(sumR,0,sizeof(float)*256);
memset(sumG,0,sizeof(float)*256);
memset(sumB,0,sizeof(float)*256);

for(int i=0;i<result.height;++i)
{
for(int j=0;j<result.width;++j)
{
++probabilityR[ int(result.R[i][j]*255.0f) ];
++probabilityG[ int(result.G[i][j]*255.0f) ];
++probabilityB[ int(result.B[i][j]*255.0f) ];
}
}
for(int i=0;i<256;++i)
{
probabilityR[i] /= (result.height*result.width);
probabilityG[i] /= (result.height*result.width);
probabilityB[i] /= (result.height*result.width);

for(int j=0;j<=i;++j)
{
sumR[i] += probabilityR[j];
sumG[i] += probabilityG[j];
sumB[i] += probabilityB[j];
}
sumR[i] *= 255.0f;
sumR[i] = floor(sumR[i] + 0.5f);
sumG[i] *= 255.0f;
sumG[i] = floor(sumG[i] + 0.5f);
sumB[i] *= 255.0f;
sumB[i] = floor(sumB[i] + 0.5f);
}
for(int i=0;i<result.height;++i)
{
for(int j=0;j<result.width;++j)
{
result.R[i][j] = sumR[int(result.R[i][j]*255.0f)] / 255.0f;
result.G[i][j] = sumG[int(result.G[i][j]*255.0f)] / 255.0f;
result.B[i][j] = sumB[int(result.B[i][j]*255.0f)] / 255.0f;
}
}







In that code, result is both the input and output. There are only 256 "gray level" values; in other words, 256 discreet values a pixel can be (on either red, green or blue channels). Do note that I am storing the pixel values in the result as real numbers in the range [0,1], so I have to convert them to the integral range [0,255] to do this algorithm. A larger range would work too. Any questions?

[Edited by - xytor on October 16, 2010 11:39:04 AM]

Share this post


Link to post
Share on other sites
As I understood it's a basically a summed area table but with only one dimmension. So mentioned in paper S array is the array where each element consist of sum of all previous elements of original histohram. It kind of works now.
I didn't like the tonemaping operator presented in paper itself. Anyway, calculated values of min max and average luminosities can be plugged into Reinhard's operator for example.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this