[v2,12/25] libtuning: lsc: rkisp1: Clip lsc values to valid range
diff mbox series

Message ID 20240628104828.2928109-13-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Add ccm calibration to libtuning
Related show

Commit Message

Stefan Klug June 28, 2024, 10:47 a.m. UTC
Based on the input images, the lsc values could exceed the range allowed
by the rkisp1.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 utils/tuning/libtuning/modules/lsc/rkisp1.py | 1 +
 1 file changed, 1 insertion(+)

Comments

Laurent Pinchart June 28, 2024, 11:19 p.m. UTC | #1
Hi Stefan,

Thank you for the patch.

On Fri, Jun 28, 2024 at 12:47:05PM +0200, Stefan Klug wrote:
> Based on the input images, the lsc values could exceed the range allowed
> by the rkisp1.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  utils/tuning/libtuning/modules/lsc/rkisp1.py | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py
> index 20406e436a6a..074f3b272dbf 100644
> --- a/utils/tuning/libtuning/modules/lsc/rkisp1.py
> +++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py
> @@ -81,6 +81,7 @@ class LSCRkISP1(LSC):
>              for lis in [list_cr, list_cgr, list_cgb, list_cb]:
>                  table = np.mean(lis[indices], axis=0)
>                  table = output_map_func((1, 3.999), (1024, 4095), table)

To improve the precision, this could then become

                  table = output_map_func((1, 4), (1024, 4096), table)

> +                table = np.clip(table, 1024, 4095)

That's good enough for now, but clipping could introduce quite bad
effects. Could it be better to instead scale the coefficients ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>                  table = np.round(table).astype('int32').tolist()
>                  tables.append(table)
>

Patch
diff mbox series

diff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py
index 20406e436a6a..074f3b272dbf 100644
--- a/utils/tuning/libtuning/modules/lsc/rkisp1.py
+++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py
@@ -81,6 +81,7 @@  class LSCRkISP1(LSC):
             for lis in [list_cr, list_cgr, list_cgb, list_cb]:
                 table = np.mean(lis[indices], axis=0)
                 table = output_map_func((1, 3.999), (1024, 4095), table)
+                table = np.clip(table, 1024, 4095)
                 table = np.round(table).astype('int32').tolist()
                 tables.append(table)