[{"id":30136,"web_url":"https://patchwork.libcamera.org/comment/30136/","msgid":"<20240628231924.GJ30900@pendragon.ideasonboard.com>","date":"2024-06-28T23:19:24","subject":"Re: [PATCH v2 12/25] libtuning: lsc: rkisp1: Clip lsc values to\n\tvalid range","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Fri, Jun 28, 2024 at 12:47:05PM +0200, Stefan Klug wrote:\n> Based on the input images, the lsc values could exceed the range allowed\n> by the rkisp1.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  utils/tuning/libtuning/modules/lsc/rkisp1.py | 1 +\n>  1 file changed, 1 insertion(+)\n> \n> diff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> index 20406e436a6a..074f3b272dbf 100644\n> --- a/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> +++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> @@ -81,6 +81,7 @@ class LSCRkISP1(LSC):\n>              for lis in [list_cr, list_cgr, list_cgb, list_cb]:\n>                  table = np.mean(lis[indices], axis=0)\n>                  table = output_map_func((1, 3.999), (1024, 4095), table)\n\nTo improve the precision, this could then become\n\n                  table = output_map_func((1, 4), (1024, 4096), table)\n\n> +                table = np.clip(table, 1024, 4095)\n\nThat's good enough for now, but clipping could introduce quite bad\neffects. Could it be better to instead scale the coefficients ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>                  table = np.round(table).astype('int32').tolist()\n>                  tables.append(table)\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D7F38BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Jun 2024 23:19:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CEE4862C99;\n\tSat, 29 Jun 2024 01:19:47 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A8CB619E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Jun 2024 01:19:46 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EA45663B;\n\tSat, 29 Jun 2024 01:19:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"wF7yx73p\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719616761;\n\tbh=m3a3fVGhYNZnicmdC7RVTJP4fd6Zr6YxbQ+siLGG86s=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wF7yx73pABN20VJCy4HhULRh1MRG4XBNYhjxHAJ5EEQCNWanHua05J2ZshEdN6Hxl\n\tdjvnzrOumux0pPzH8qNPTb68CUnE6frZG5rmZwf3yF6cSDdDH800Rn985QuxdOIezS\n\t64CTgfCuKtoG/PcyyrhT+dA/fAMf7IABNfBLt7vI=","Date":"Sat, 29 Jun 2024 02:19:24 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 12/25] libtuning: lsc: rkisp1: Clip lsc values to\n\tvalid range","Message-ID":"<20240628231924.GJ30900@pendragon.ideasonboard.com>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>\n\t<20240628104828.2928109-13-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240628104828.2928109-13-stefan.klug@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30192,"web_url":"https://patchwork.libcamera.org/comment/30192/","msgid":"<s36vvb6bham6yolc55raj5tfg4r6qjlzpgtxampf5bsdy2qmfx@x64xyl6ooi4y>","date":"2024-07-01T15:56:34","subject":"Re: [PATCH v2 12/25] libtuning: lsc: rkisp1: Clip lsc values to\n\tvalid range","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"On Sat, Jun 29, 2024 at 02:19:24AM +0300, Laurent Pinchart wrote:\n> Hi Stefan,\n> \n> Thank you for the patch.\n> \n> On Fri, Jun 28, 2024 at 12:47:05PM +0200, Stefan Klug wrote:\n> > Based on the input images, the lsc values could exceed the range allowed\n> > by the rkisp1.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  utils/tuning/libtuning/modules/lsc/rkisp1.py | 1 +\n> >  1 file changed, 1 insertion(+)\n> > \n> > diff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> > index 20406e436a6a..074f3b272dbf 100644\n> > --- a/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> > +++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> > @@ -81,6 +81,7 @@ class LSCRkISP1(LSC):\n> >              for lis in [list_cr, list_cgr, list_cgb, list_cb]:\n> >                  table = np.mean(lis[indices], axis=0)\n> >                  table = output_map_func((1, 3.999), (1024, 4095), table)\n> \n> To improve the precision, this could then become\n\nRight. I fixed it.\n\n> \n>                   table = output_map_func((1, 4), (1024, 4096), table)\n> \n> > +                table = np.clip(table, 1024, 4095)\n> \n> That's good enough for now, but clipping could introduce quite bad\n> effects. Could it be better to instead scale the coefficients ?\n\nI guess wee need to wait for these artefacts to occur to be able to\ndecide for the best solution. (E.g. I expect such things on lenses where\nthe fov doesn't cover the whole sensor and you see actual black corners)\n\nRegards,\nStefan\n\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> >                  table = np.round(table).astype('int32').tolist()\n> >                  tables.append(table)\n> >  \n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 03AF6BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Jul 2024 15:56:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D7AD762E22;\n\tMon,  1 Jul 2024 17:56:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00DF4604C1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Jul 2024 17:56:37 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E7F7763D;\n\tMon,  1 Jul 2024 17:56:10 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MdKVVTfz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719849371;\n\tbh=cmSkWmRnAX16KRBrIlEszE97PG9p4lmZ+DcSrwpgFg8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MdKVVTfz3vgShnjOhAohkIcGj0uNFVJb4v1XQKqWteSM7uGq0eqY63vJxx1XPqyBn\n\taAXfZ0zaaLb7VUb/S80pSXb6nGvitKeyV3k4BzEuwaKYjHaoQYz42/kDWzFIYsvEAm\n\tWCPwDAeYWx90NrG9ohxZPev6tIqwdk0Rz11AwYuM=","Date":"Mon, 1 Jul 2024 17:56:34 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 12/25] libtuning: lsc: rkisp1: Clip lsc values to\n\tvalid range","Message-ID":"<s36vvb6bham6yolc55raj5tfg4r6qjlzpgtxampf5bsdy2qmfx@x64xyl6ooi4y>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>\n\t<20240628104828.2928109-13-stefan.klug@ideasonboard.com>\n\t<20240628231924.GJ30900@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240628231924.GJ30900@pendragon.ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30201,"web_url":"https://patchwork.libcamera.org/comment/30201/","msgid":"<20240702092533.GA26760@pendragon.ideasonboard.com>","date":"2024-07-02T09:25:33","subject":"Re: [PATCH v2 12/25] libtuning: lsc: rkisp1: Clip lsc values to\n\tvalid range","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Jul 01, 2024 at 05:56:34PM +0200, Stefan Klug wrote:\n> On Sat, Jun 29, 2024 at 02:19:24AM +0300, Laurent Pinchart wrote:\n> > Hi Stefan,\n> > \n> > Thank you for the patch.\n> > \n> > On Fri, Jun 28, 2024 at 12:47:05PM +0200, Stefan Klug wrote:\n> > > Based on the input images, the lsc values could exceed the range allowed\n> > > by the rkisp1.\n> > > \n> > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > > ---\n> > >  utils/tuning/libtuning/modules/lsc/rkisp1.py | 1 +\n> > >  1 file changed, 1 insertion(+)\n> > > \n> > > diff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> > > index 20406e436a6a..074f3b272dbf 100644\n> > > --- a/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> > > +++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py\n> > > @@ -81,6 +81,7 @@ class LSCRkISP1(LSC):\n> > >              for lis in [list_cr, list_cgr, list_cgb, list_cb]:\n> > >                  table = np.mean(lis[indices], axis=0)\n> > >                  table = output_map_func((1, 3.999), (1024, 4095), table)\n> > \n> > To improve the precision, this could then become\n> \n> Right. I fixed it.\n> \n> > \n> >                   table = output_map_func((1, 4), (1024, 4096), table)\n> > \n> > > +                table = np.clip(table, 1024, 4095)\n> > \n> > That's good enough for now, but clipping could introduce quite bad\n> > effects. Could it be better to instead scale the coefficients ?\n> \n> I guess wee need to wait for these artefacts to occur to be able to\n> decide for the best solution. (E.g. I expect such things on lenses where\n> the fov doesn't cover the whole sensor and you see actual black corners)\n\nLSC with fish-eye lens will be interesting indeed. We'll probably need\nto define some sort of region of interest for the LSC tuning.\n\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > \n> > >                  table = np.round(table).astype('int32').tolist()\n> > >                  tables.append(table)\n> > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 559ECBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Jul 2024 09:25:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 915CA62E23;\n\tTue,  2 Jul 2024 11:25:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E3B7619C8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Jul 2024 11:25:55 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B9227664;\n\tTue,  2 Jul 2024 11:25:27 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dCmtYezU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719912327;\n\tbh=EE49/lGc/cbSjDSgl4Lztp5QlZk1LOwbXuhoR0ku7Mk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=dCmtYezUbCeWWovsK5GXVHeZOeArpLOesTPHwc6i7vbQ6Ic91fHm/1dZ23Sgag1V8\n\t4lkNsoNCmGjsnGozDAJptgIJ0thi0vonn2vgYPtSwHeAxbUHRRSHZTWkuOWii11AaY\n\t6hoUYF4fzxoDfXEU78+OJeedwphyjptFceDs54y4=","Date":"Tue, 2 Jul 2024 12:25:33 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 12/25] libtuning: lsc: rkisp1: Clip lsc values to\n\tvalid range","Message-ID":"<20240702092533.GA26760@pendragon.ideasonboard.com>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>\n\t<20240628104828.2928109-13-stefan.klug@ideasonboard.com>\n\t<20240628231924.GJ30900@pendragon.ideasonboard.com>\n\t<s36vvb6bham6yolc55raj5tfg4r6qjlzpgtxampf5bsdy2qmfx@x64xyl6ooi4y>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<s36vvb6bham6yolc55raj5tfg4r6qjlzpgtxampf5bsdy2qmfx@x64xyl6ooi4y>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]