[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 Superseded
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)
>
Stefan Klug July 1, 2024, 3:56 p.m. UTC | #2
On Sat, Jun 29, 2024 at 02:19:24AM +0300, Laurent Pinchart wrote:
> 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

Right. I fixed it.

> 
>                   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 ?

I guess wee need to wait for these artefacts to occur to be able to
decide for the best solution. (E.g. I expect such things on lenses where
the fov doesn't cover the whole sensor and you see actual black corners)

Regards,
Stefan

> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> >                  table = np.round(table).astype('int32').tolist()
> >                  tables.append(table)
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart
Laurent Pinchart July 2, 2024, 9:25 a.m. UTC | #3
On Mon, Jul 01, 2024 at 05:56:34PM +0200, Stefan Klug wrote:
> On Sat, Jun 29, 2024 at 02:19:24AM +0300, Laurent Pinchart wrote:
> > 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
> 
> Right. I fixed it.
> 
> > 
> >                   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 ?
> 
> I guess wee need to wait for these artefacts to occur to be able to
> decide for the best solution. (E.g. I expect such things on lenses where
> the fov doesn't cover the whole sensor and you see actual black corners)

LSC with fish-eye lens will be interesting indeed. We'll probably need
to define some sort of region of interest for the LSC tuning.

> > 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)