From patchwork Fri Sep 20 13:39:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21295 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A48A8C3257 for ; Fri, 20 Sep 2024 13:39:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 666A2634FC; Fri, 20 Sep 2024 15:39:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Trc5zEBN"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C09B4618E0 for ; Fri, 20 Sep 2024 15:39:46 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:8ade:938d:48b1:cede]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A0F284CE; Fri, 20 Sep 2024 15:38:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726839502; bh=JxExKhPDm5OJBe4Uxebh7hxFn9nUhdx+gvwRjt+Lvic=; h=From:To:Cc:Subject:Date:From; b=Trc5zEBNYqYX/fZzXpvBiQhgzu63Fh+8okD+2DK8+M+a7O5fgCGwiXUvoplBDvZ5Y gFETHnNJxyj+IrddAxEMR/IvKsvI/GPXo0VxfrzKr9jp3vAY9+/UYc4R+oscurw4/Z uAuyk+Yl7o9JgQMk/vsM1TXWP2iTqDmKUmPNX4c8= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 0/9] Implement polynomial lsc support Date: Fri, 20 Sep 2024 15:39:15 +0200 Message-ID: <20240920133941.90629-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi all, Polynomial functions allow a precise representation of the lensshading. The formula used here is from the DNG specification [2] page 110. Initial implementations in libtuning show that the overall error is quite low, but it is not yet clear if the ability to model the lens shading is sufficient for all cases. The huge benefit of polynomials is that they can be easily resampled for arbitrary crop rectangles. In case of the rkisp1 the hardware is configured using a 17x17 grid of gains. Resampling these for a arbitrary crop rectangle on the sensor leads to a degradation in quality. This can either be mitigated using a higher resolution grid as basis or by describing the lens shading using polynomials. This series implements the latter. Patches 1-4 replace the matrix interpolator with a generic interpolator class. This is only refactoring without functional changes. Patch 5 Uses the new interpolator for the current lsc algorithm. Patch 6-9 Implement a loader for polynomial lens shading coefficients. Sampling for the current sensor crop rectangle is done at load time. [1] https://patchwork.libcamera.org/project/libcamera/list/?series=4514 [1] https://helpx.adobe.com/content/dam/help/en/photoshop/pdf/DNG_Spec_1_7_1_0.pdf Changes in v3: - Some smaller fixes from review - Cleaned the loader decision logic. - The series now depends on the yaml parser fix https://patchwork.libcamera.org/project/libcamera/list/?series=4608 Changes in v2: - Renamed polynomial class to LscPolynomial to better expresss the intent. - Fixed some stylistic issues form review - Added test for interpolator - Improved interpolator efficiency - Add docs for LscPolynomial Stefan Klug (9): ipa: libipa: Add generic Interpolator class test: ipa: libipa: Add tets for Interpolator ipa: rkisp1: Use generic Interpolator class ipa: rkisp1: Remove MatrixInterpolator ipa: rkisp1: Use interpolator in lsc ipa: rkisp1: Move loader functions into helper class ipa: libipa: Add lsc polynomial class ipa: rkisp1: Add sensor info to context ipa: rkisp1: Add polynomial LSC loader src/ipa/libipa/interpolator.cpp | 157 +++++++++ src/ipa/libipa/interpolator.h | 131 ++++++++ src/ipa/libipa/lsc_polynomial.cpp | 81 +++++ src/ipa/libipa/lsc_polynomial.h | 105 +++++++ src/ipa/libipa/matrix_interpolator.cpp | 103 ------ src/ipa/libipa/matrix_interpolator.h | 120 ------- src/ipa/libipa/meson.build | 6 +- src/ipa/rkisp1/algorithms/ccm.cpp | 18 +- src/ipa/rkisp1/algorithms/ccm.h | 6 +- src/ipa/rkisp1/algorithms/lsc.cpp | 419 +++++++++++++++---------- src/ipa/rkisp1/algorithms/lsc.h | 13 +- src/ipa/rkisp1/ipa_context.cpp | 3 + src/ipa/rkisp1/ipa_context.h | 2 + src/ipa/rkisp1/rkisp1.cpp | 4 +- test/ipa/libipa/interpolator.cpp | 54 ++++ test/ipa/libipa/meson.build | 15 + test/ipa/meson.build | 1 + 17 files changed, 829 insertions(+), 409 deletions(-) create mode 100644 src/ipa/libipa/interpolator.cpp create mode 100644 src/ipa/libipa/interpolator.h create mode 100644 src/ipa/libipa/lsc_polynomial.cpp create mode 100644 src/ipa/libipa/lsc_polynomial.h delete mode 100644 src/ipa/libipa/matrix_interpolator.cpp delete mode 100644 src/ipa/libipa/matrix_interpolator.h create mode 100644 test/ipa/libipa/interpolator.cpp create mode 100644 test/ipa/libipa/meson.build