{"id":21010,"url":"https://patchwork.libcamera.org/api/1.1/covers/21010/?format=json","web_url":"https://patchwork.libcamera.org/cover/21010/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240826152224.362773-1-stefan.klug@ideasonboard.com>","date":"2024-08-26T15:21:58","name":"[RFC/PATCH,v1,0/8] Implement polynomial lsc loader","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/cover/21010/mbox/","series":[{"id":4540,"url":"https://patchwork.libcamera.org/api/1.1/series/4540/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4540","date":"2024-08-26T15:21:58","name":"Implement polynomial lsc loader","version":1,"mbox":"https://patchwork.libcamera.org/series/4540/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/21010/comments/","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 31BD9C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Aug 2024 15:22:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C315D633D9;\n\tMon, 26 Aug 2024 17:22:30 +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 AD195633CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Aug 2024 17:22:29 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:58b7:f3d:c9d4:defa])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 50859480;\n\tMon, 26 Aug 2024 17:21:23 +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=\"MIg2BlGy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1724685683;\n\tbh=PynvSlUYn5POsQFCftRjPz8+t7xPCsIigDANb1f9WOk=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=MIg2BlGy+pMlHoF6zeNy9RGkbrb6cVZ6AybbhvZ3OlYxc1jE7GNZqweewz2LtbZKQ\n\tu4Ce3GGJOLMfl1Ws8mkdXfaXukJdsEXdextIZCNlja8TrvBY8sHYC0852qeLcNVOu5\n\twJW3fDbw4Vn4pBVxbO3W1zLq5C88gd44iWzbpzzw=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[RFC/PATCH v1 0/8] Implement polynomial lsc loader","Date":"Mon, 26 Aug 2024 17:21:58 +0200","Message-ID":"<20240826152224.362773-1-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"Hi all,\n\nThis series is not yet completely polished, as I'd like to get some\nfeedback on the overall direction first. It is based on my colour\ntemperature series [1].\n\nPolynomial functions allow a relatively precise representation of the\nlensshading. The formula used here is from the DNG specification [2]\npage 110. Initial implementations in libtuning show that the overall\nerror is quite low, but it is not yet clear if the ability to model the\nlens shading is sufficient for all cases.\n\nThe huge benefit of polynomials is that they can be easily resampled for\narbitrary crop rectangles. In case of the rkisp1 the hardware is\nconfigured using a 17x17 grid of gains.  Resampling these for a\narbitrary crop rectangle on the sensor leads to a degradation in\nquality. This can either be mitigated using a higher resolution grid as\nbasis or by describing the lens shading using polynomials. This series\nimplements the latter.\n\nPatches 1-3 replace the matrix interpolator with a generic interpolator\nclass. This is only refactoring without functional changes.\n\nPatch 4 Uses the new interpolator for the current lsc algorithm.\n\nPatch 5-8 Implement a loader for polynomial lens shading coefficients.\nSampling for the current sensor crop rectangle is done at load time.\n\nQuestions I have in mind:\n- libipa/polynomial.h is only used inside the loader. Is that worth a\n  own file, or should it be defined in lsc.cpp?\n- lsc.cpp now contains several helper classes on the top. Are these fine\n  there, or should they be moved into another file?\n\nI'm happy for any feedback.\n\nBest regards,\nStefan\n\n[1] https://patchwork.libcamera.org/project/libcamera/list/?series=4514\n[1] https://helpx.adobe.com/content/dam/help/en/photoshop/pdf/DNG_Spec_1_7_1_0.pdf\n\n\nStefan Klug (8):\n  ipa: libipa: Add generic Interpolator class\n  ipa: rkisp1: Use generic Interpolator class\n  ipa: rkisp1: Remove MatrixInterpolator\n  ipa: rkisp1: Use interpolator in lsc\n  ipa: rkisp1: Move loader functions into helper class\n  ipa: libipa: Add lsc polynomial class\n  ipa: rkisp1: Add sensor info to context\n  ipa: rkisp1: Add polynomial LSC loader\n\n src/ipa/libipa/interpolator.cpp        | 139 +++++++++\n src/ipa/libipa/interpolator.h          | 139 +++++++++\n src/ipa/libipa/matrix_interpolator.cpp | 110 -------\n src/ipa/libipa/matrix_interpolator.h   | 122 --------\n src/ipa/libipa/meson.build             |   6 +-\n src/ipa/libipa/polynomial.cpp          |  23 ++\n src/ipa/libipa/polynomial.h            | 107 +++++++\n src/ipa/rkisp1/algorithms/awb.cpp      |   4 +-\n src/ipa/rkisp1/algorithms/awb.h        |   5 +-\n src/ipa/rkisp1/algorithms/ccm.cpp      |  18 +-\n src/ipa/rkisp1/algorithms/ccm.h        |   6 +-\n src/ipa/rkisp1/algorithms/lsc.cpp      | 405 +++++++++++++++----------\n src/ipa/rkisp1/algorithms/lsc.h        |  13 +-\n src/ipa/rkisp1/ipa_context.h           |   2 +\n src/ipa/rkisp1/rkisp1.cpp              |   4 +-\n 15 files changed, 684 insertions(+), 419 deletions(-)\n create mode 100644 src/ipa/libipa/interpolator.cpp\n create mode 100644 src/ipa/libipa/interpolator.h\n delete mode 100644 src/ipa/libipa/matrix_interpolator.cpp\n delete mode 100644 src/ipa/libipa/matrix_interpolator.h\n create mode 100644 src/ipa/libipa/polynomial.cpp\n create mode 100644 src/ipa/libipa/polynomial.h"}