From patchwork Wed Nov 22 09:13:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 19222 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 C385ABDE6B for ; Wed, 22 Nov 2023 09:13:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC851629BC; Wed, 22 Nov 2023 10:13:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1700644389; bh=lNiz4SSegP2bboTuu9uTak3GUxIWIRuS71AwMwkyozA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZDtME6Y9+glaCR5oxiBqwdLPaCiTwI8KDS5JpLMyRFusu024MEQe1AKEjY2Ohu1zB hpN8BQV/FspVRnBY/8O/vNaNQi5C9BR4XMIL2Q1BH1/Lunf/1ZJXJHxMSCOgMOO/6u wUYQ5QSxsmjaVBHUj2qyu2WgWG5hjOdRDxl4a+8MhZN/k7+cWhnTtmhT8xNVOkMoMk YNZ09RdbAYS/lDeurwvD1ayc3DeikcMa5EjCWFdvfdTgSkcm6giQNCqOZ6GcOTdKX8 GJk0RHm5UpDGdaek9o/5ZYXPhkC34rcWmU8SI3TH1r54gIZ+yJycrLl5jK6UeBnl4h A+ob/kuy+oFdg== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 234F161DAB for ; Wed, 22 Nov 2023 10:13:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="APBvb5+G"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40839807e82so3457315e9.0 for ; Wed, 22 Nov 2023 01:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1700644386; x=1701249186; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LFFoAOCoH8nVM/sE2NTlrADNUQ0wHIMyqkDKwoxyvEY=; b=APBvb5+G526smvBu09KV6EaJXXLdpwnKR5SiXW+K2bu6q437ubzxQMwOzBX97UO2LW i3fExI6iQQySXrggt3dhgxcPJxxRYFoDT7Lh6hPJLFIINbJDH9/PzuoHf2C7XWKiH4h+ ffENjAsKiuTn14UMiYHtZJbyziK8e/xhE9lfZIUNwvdBk6AeZjgb/X1yBnS9Qj24idk6 7XLd78wRQLT2BkSjX8r2XlBUtbSCHEuW3nSINEe9QmAuL6TNXLNcNvcSgBaXdBVN75Yt NkiYjn147bJ7Ea4g+hJayq0tBzOpUdcTQPBy69DHhTe65Db+Gzt1VEtAujGarVvy/QNQ dVaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700644386; x=1701249186; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LFFoAOCoH8nVM/sE2NTlrADNUQ0wHIMyqkDKwoxyvEY=; b=A2yIcSKbxvSKsURETIbCi4heBFLn+CvyXxJwLTLthhrAg4Ku5pIuLnSVT8WE4U2xQD ANSRw/LeaZ1y0GhK8nkZhyYb6KIZV674wTyOCD5x+IEQdSu8wGp37bF6itwx5KOgPaN8 Yms0S4pdLNwohaUgg6GrfJGF4DNXwJcgq1sSj44w7lopuZVGUzW8gF0mSrFG2FMUMv2Z +4yLcC/IovHvyviaR3cp3r/28rVmTKKHkgYMHEWT8gRwvRPZ0KHzTDT+KpEVqJ/c7yLK i3WBfM3DvjlF+oJDsrjMvgIYIiJxYPQMl4lHUde5FlWIi/Ifkp7E4yejYg/q8y6M84Jx Do8g== X-Gm-Message-State: AOJu0YxoTmV1Avf+ubSPQ9So1XWFtVq+rhPVLJCjHQm97KjEnKrs7LcI WATfpnua1lMngRQYCh6qiWC3JPJI7vw1nM7nttY= X-Google-Smtp-Source: AGHT+IGXKSzWGDMK1dNipCoMQJnAxpANS7KOZktdL4Ynvyh5RonVOymJaXkFWn1g32KM7HlnUUVIhg== X-Received: by 2002:a1c:7518:0:b0:40b:2afd:1a9 with SMTP id o24-20020a1c7518000000b0040b2afd01a9mr3662170wmc.15.1700644385961; Wed, 22 Nov 2023 01:13:05 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:2bce:64d6:1a5c:49a2]) by smtp.gmail.com with ESMTPSA id q17-20020a05600c46d100b004064288597bsm1506394wmo.30.2023.11.22.01.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 01:13:05 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Nov 2023 09:13:02 +0000 Message-Id: <20231122091302.550574-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] ipa: rpi: alsc: Do not allow zero colour ratio statistics 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: , X-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The algorithm computes R/G and B/G colour ratio statistics which we should not allow to go to zero because there is clearly no gain you could apply to R or B to equalise them. Instead flag such regions as having "insufficient data" in the normal manner. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/ipa/rpi/controller/rpi/alsc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp index b7413611..8a205c60 100644 --- a/src/ipa/rpi/controller/rpi/alsc.cpp +++ b/src/ipa/rpi/controller/rpi/alsc.cpp @@ -548,7 +548,9 @@ static void calculateCrCb(const RgbyRegions &awbRegion, Array2D &cr, for (unsigned int i = 0; i < cr.size(); i++) { auto s = awbRegion.get(i); - if (s.counted <= minCount || s.val.gSum / s.counted <= minG) { + /* Do not return unreliable, or zero, colour ratio statistics. */ + if (s.counted <= minCount || s.val.gSum / s.counted <= minG || + s.val.rSum / s.counted <= minG || s.val.bSum / s.counted <= minG) { cr[i] = cb[i] = InsufficientData; continue; }