<div dir="ltr"><div dir="ltr">Hi Paul,<div><br></div><div>Here are some initial thoughts from me. I'm sure David will have some views on this as well.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 16 Jun 2021 at 09:47, <<a href="mailto:paul.elder@ideasonboard.com" target="_blank">paul.elder@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Naush and David,<br>
<br>
We are planning to add controls for tonemapping [1], and we were<br>
thinking to use the same controls that the android HAL uses.<br>
<br>
Something along the lines of:<br>
<br>
- TonemapMode<br>
type: int32_t<br>
draft: true<br>
description: |<br>
High-level global contrast/gamma/tonemapping control. Currently<br>
identical to ANDROID_TONEMAP_MODE.<br>
enum:<br>
- name: TonemapModeContrastCurve<br>
value: 0<br>
description: |<br>
Use the tonemapping curve specified in TonemapCurve* entries.<br>
All color enhancement and tonemapping must be disabled, except<br>
for applying the tonemapping curve specified by TonemapCurve*.<br>
- name: TonemapModeFast<br>
value: 1<br>
description: |<br>
Advanced gamma mapping and color enhancement may be applied,<br>
without reducing frame rate compared to raw sensor output.<br>
- name: TonemapModeHighQuality<br>
value: 2<br>
description: |<br>
High-quality gamma mapping and color enhancement will be<br>
applied, at the cost of possibly reduced frame rate compared to<br>
raw sensor output.<br></blockquote><div><br></div><div>I always wondered why Android had a Fast and HQ mode for tone mapping - assuming this</div><div>is talking about global contrast enhancement, and not local which the description implies.</div><div>All it is doing is an in -> out mapping, so I don't get why we need different quality settings.</div><div>This may be related, but colour enhancement seems a bit vague, do you have any more</div><div>details on that?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- name: TonemapModeGammaValue<br>
value: 3<br>
description: |<br>
Use the gamma value specified in TonemapGamma to perform<br>
tonemapping. All color enhancement and tonemapping must be<br>
disabled, except for applying the tonemapping curve specified<br>
by TonemapGamma.<br>
- name: TonemapModePresetCurve<br>
value: 4<br>
description: |<br>
Use the present tonemapping curve specified in<br>
TonemapPresetCurve to perform tonemapping. All color<br>
enhancement and tonemapping must be disabled, except for<br>
applying the tonemapping curve specified by TonemapPresetCurve.<br>
<br>
- TonemapGamma<br>
type: float<br>
draft: true<br>
description: |<br>
Tonemapping curve to use when TonemapMode is TonemapModeGammaValue.<br>
The tonemap curve will be defined by the following formula: * OUT =<br>
pow(IN, 1.0 / gamma) where IN and OUT is the input pixel value<br>
scaled to range [0.0, 1.0], pow is the power function and gamma is<br>
the gamma value specified by this key. The same curve will be<br>
applied to all color channels. The camera device may clip the input<br>
gamma value to its supported range. The actual applied value will<br>
be returned in result metadata. The valid range of gamma value<br>
varies on different devices, but values within [1.0, 5.0] are<br>
guaranteed not to be clipped. Currently identical to<br>
ANDROID_TONEMAP_GAMMA.<br>
<br>
- TonemapPresetCurve<br>
type: int32_t<br>
draft: true<br>
description: |<br>
Tonemapping curve to use when TonemapMode is<br>
TonemapModePresetCurve.<br>
enum:<br>
- name: TonemapPresetCurveSRGB<br>
value: 0<br>
description: [2]<br>
- name: TonemapPresetCurveREC709<br>
value: 1<br>
description: [3]<br></blockquote><div><br></div><div>This bit is very related to the ColourSpace work that David has submitted for</div><div></div><div> review. My feeling is that these presets do not make much sense in isolation without</div><div>specifying things like colour primaries and ranges.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
- TonemapCurve{Red,Green,Blue}<br>
type: float<br>
draft: true<br>
description: |<br>
An array of [ [in, out], [in, out], ... ] format to describe a<br>
tonemapping curve to be applied when TonemapMode is set to<br>
TonemapModeContrastCurve.<br>
size: [64] (we need some way to specify the size)<br></blockquote><div><br></div><div>Generally speaking, do you expect different curves for R/G/B? There may be</div><div>a hardware limitation that only allows a single curve, so perhaps the description</div><div>could be updated to reflect this?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
What feedback do you have on these controls? How might you implement<br>
these? Is it something that could be done? Do you forsee any issues?<br></blockquote><div><br></div><div>Overall, I do find it quite strange that a user can take over the gamma/ce control</div><div>from the AGC. I think the biggest challenge is how does this control play well with</div><div>AGC? Perhaps there needs to be a Auto tone-mapping mode that allows the AGC</div><div>to do what it needs to do? Otherwise, this seems to be an easy way to mess up the</div><div>quality of the AGC output, even though the intention may be the opposite :-) </div><div><br></div><div>Another one is how this plays with Colourspace setup, where the tone mapping is just one</div><div>part of the equation.</div><div><br></div><div>Regards,</div><div>Naush</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
Thanks,<br>
<br>
Paul<br>
<br>
[1] <a href="https://bugs.libcamera.org/show_bug.cgi?id=56" rel="noreferrer" target="_blank">https://bugs.libcamera.org/show_bug.cgi?id=56</a><br>
[2] <a href="https://developer.android.com/reference/images/camera2/metadata/android.tonemap.curveRed/srgb_tonemap.png" rel="noreferrer" target="_blank">https://developer.android.com/reference/images/camera2/metadata/android.tonemap.curveRed/srgb_tonemap.png</a><br>
[3] <a href="https://developer.android.com/reference/images/camera2/metadata/android.tonemap.curveRed/rec709_tonemap.png" rel="noreferrer" target="_blank">https://developer.android.com/reference/images/camera2/metadata/android.tonemap.curveRed/rec709_tonemap.png</a><br>
</blockquote></div></div>