Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GT data [understanding the max of range] #13

Open
ittim4 opened this issue Aug 10, 2021 · 6 comments
Open

GT data [understanding the max of range] #13

ittim4 opened this issue Aug 10, 2021 · 6 comments

Comments

@ittim4
Copy link

ittim4 commented Aug 10, 2021

First of all, thanks for your comments in this thread regarding align ratio. Wanted to understand few more details. For e.g.: How to find out what is the maximum nits represented in GT data? Is there any information or metadata indicated where GT is graded for say 1000nits, etc? Essentially, trying to understand whats the relationship of uint16 number in GT file and the nits it might represent.
Current understanding is:: GT data is uint16 & gamma encoded and lets say if original range was [0 M], it is always scaled in a way that max of image content will be represented by 65535 where alignratio= 65535/M.

Current thought process to make sense of GT data:

  1. GT_aligned = output of function imread_uint16_png() i.e. read GT uint16 from file and divide by alignratio to get original range, say [0 M].
  2. At this point, GT_aligned is not normalized to [0 1]. Ideally, would like to normalize it to [0 1] before applying gamma correction. Q1. How to normalize GT_aligned to [0 1]? e.g. GT_norm = function(GT_aligned)..what function to use for normalization?
  3. GT_linear = GT_norm ^ gamma
  4. Now, GT_linear will be in normalized to [0 1], but trying to understand what 1 represents? For e.g. for linear SDR signal, 1 will represent 100nits. Q2. But, for this GT_linear of HDR signal, 1 will translate to what value of nits? Any idea/ suggestions to understand this? or any assumptions made here?

would be great if you can share your insight in this regard.

@chxy95
Copy link
Owner

chxy95 commented Aug 10, 2021

@ittim4 In this repo, HDR values are not processed into [0, 1] in the data reading phase, while you can think that the Tanh function used in Tanh_L1 loss function is designed for normalization.

@chxy95
Copy link
Owner

chxy95 commented Aug 10, 2021

@ittim4 GT_linear = GT_aligned ^ gamma. Linear signal is not strictly related to the value of nits for display-referred data.

@ittim4
Copy link
Author

ittim4 commented Aug 10, 2021

Thank you @chxy95 ! Interesting to know that HDR values are not processed into [0 1] and I see that, in the context of this problem, Tanh function (in Tanh_L1 loss) can serve as a normalization and also in that sense, one need not know strict relation to nits of display referred data.
However, normalization of GT_aligned [0 M] to GT_aligned_norm [0 1] would be interesting to understand if one needs to apply gamma correction and convert to linear... or even it might help for visualization purpose. Actually, when I look at "tonemapped_visualization.py", it seems 99th % of GT data (i.e. line 31: norm_perc = np.percentile(hdr_linear_image, 99) ) is used to normalize result image (i.e.line 39. m.tanh_norm_mu_tonemap(res_linear_image, norm_perc) ) . Noticed that "res_linear_image / norm_perc", say 'res_linear_norm' still not bounded to [0 1], but tanh of 'res_linear_norm' will ofcourse bound to [0 1].

Q1. Can you help understand what's the rational behind using 99th percentile of GT as "norm_perc" value in line 31? why not just take max i.e. 100th percentile?
Q2. Function tanh_norm_mu_tonemap(hdr_image, norm_value, mu=5000) comment in metrics.py mention " hdr_image (np.ndarray): Linear HDR image with values in the range of [0-1]". However, line 39 on "tonemapped_visualization.py" : m.tanh_norm_mu_tonemap(res_linear_image, norm_perc), here "res_linear_image" does not seem to be in [0 1] range. Is this a mistake in comment or bug/limitation in a code? or maybe I am interpreting it incorrectly?

@chxy95
Copy link
Owner

chxy95 commented Aug 11, 2021

@ittim4 Q1: The parameters of the tone mapping algorithm are default provided by the organizor. You can also use 100th percentile as norm_perc value.
Q2: The comments are also provided by the original codes provide by the organizor. Actually, the value range of hdr is beyond [0,1]. 1 means the maximum pixel value which can be shown in display without tone mapping. The comments here are not incorrect in my opinion.

@UdonDa
Copy link

UdonDa commented Aug 12, 2021

In summary, when a loss is calculated, the range of fake_H is just output values of a generator and the range of real_H is [0, 1] since it is normalized by an alignratio value, right?
https://github.com/chxy95/HDRUNet/blob/main/codes/data/LQGT_condition_dataset.py#L38

@chxy95
Copy link
Owner

chxy95 commented Aug 12, 2021

@UdonDa The range of real_H is [0, M] after it is normalized by the alignratio value. when L1 loss is calculated, fake_H and real_H are processed by the Tanh function first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants