[libcamera-devel] Questions about tonemapping

paul.elder at ideasonboard.com paul.elder at ideasonboard.com
Wed Jun 16 10:47:44 CEST 2021


Hello Naush and David,

We are planning to add controls for tonemapping [1], and we were
thinking to use the same controls that the android HAL uses.

Something along the lines of:

- TonemapMode
    type: int32_t
    draft: true
    description: |
     High-level global contrast/gamma/tonemapping control. Currently
     identical to ANDROID_TONEMAP_MODE.
    enum:
      - name: TonemapModeContrastCurve
        value: 0
	description: |
	 Use the tonemapping curve specified in TonemapCurve* entries.
	 All color enhancement and tonemapping must be disabled, except
	 for applying the tonemapping curve specified by TonemapCurve*.
      - name: TonemapModeFast
        value: 1
	description: |
	 Advanced gamma mapping and color enhancement may be applied,
	 without reducing frame rate compared to raw sensor output.
      - name: TonemapModeHighQuality
        value: 2
	description: |
	 High-quality gamma mapping and color enhancement will be
	 applied, at the cost of possibly reduced frame rate compared to
	 raw sensor output.
      - name: TonemapModeGammaValue
        value: 3
	description: |
	 Use the gamma value specified in TonemapGamma to perform
	 tonemapping. All color enhancement and tonemapping must be
	 disabled, except for applying the tonemapping curve specified
	 by TonemapGamma.
      - name: TonemapModePresetCurve
        value: 4
	description: |
	 Use the present tonemapping curve specified in
	 TonemapPresetCurve to perform tonemapping. All color
	 enhancement and tonemapping must be disabled, except for
	 applying the tonemapping curve specified by TonemapPresetCurve.

- TonemapGamma
    type: float
    draft: true
    description: |
     Tonemapping curve to use when TonemapMode is TonemapModeGammaValue.
     The tonemap curve will be defined by the following formula: * OUT =
     pow(IN, 1.0 / gamma) where IN and OUT is the input pixel value
     scaled to range [0.0, 1.0], pow is the power function and gamma is
     the gamma value specified by this key. The same curve will be
     applied to all color channels. The camera device may clip the input
     gamma value to its supported range. The actual applied value will
     be returned in result metadata. The valid range of gamma value
     varies on different devices, but values within [1.0, 5.0] are
     guaranteed not to be clipped. Currently identical to
     ANDROID_TONEMAP_GAMMA.

- TonemapPresetCurve
    type: int32_t
    draft: true
    description: |
     Tonemapping curve to use when TonemapMode is
     TonemapModePresetCurve.
    enum:
      - name: TonemapPresetCurveSRGB
        value: 0
	description: [2]
      - name: TonemapPresetCurveREC709
        value: 1
	description: [3]

- TonemapCurve{Red,Green,Blue}
    type: float
    draft: true
    description: |
     An array of [ [in, out], [in, out], ... ] format to describe a
     tonemapping curve to be applied when TonemapMode is set to
     TonemapModeContrastCurve.
    size: [64] (we need some way to specify the size)


What feedback do you have on these controls? How might you implement
these? Is it something that could be done? Do you forsee any issues?


Thanks,

Paul

[1] https://bugs.libcamera.org/show_bug.cgi?id=56
[2] https://developer.android.com/reference/images/camera2/metadata/android.tonemap.curveRed/srgb_tonemap.png
[3] https://developer.android.com/reference/images/camera2/metadata/android.tonemap.curveRed/rec709_tonemap.png


More information about the libcamera-devel mailing list