{"id":18905,"url":"https://patchwork.libcamera.org/api/1.1/patches/18905/?format=json","web_url":"https://patchwork.libcamera.org/patch/18905/","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":"<20230731094641.73646-2-david.plowman@raspberrypi.com>","date":"2023-07-31T09:46:37","name":"[libcamera-devel,1/5] ipa: rpi: histogram: Add interBinMean()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0fe24a22affc8b48f66507a8ae46f849a586d373","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18905/mbox/","series":[{"id":3996,"url":"https://patchwork.libcamera.org/api/1.1/series/3996/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3996","date":"2023-07-31T09:46:36","name":"Multi-channel AGC","version":1,"mbox":"https://patchwork.libcamera.org/series/3996/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18905/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18905/checks/","tags":{},"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 9FB2CBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Jul 2023 09:46:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B0C32627F0;\n\tMon, 31 Jul 2023 11:46:47 +0200 (CEST)","from mail-wm1-x330.google.com (mail-wm1-x330.google.com\n\t[IPv6:2a00:1450:4864:20::330])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BE87627E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Jul 2023 11:46:45 +0200 (CEST)","by mail-wm1-x330.google.com with SMTP id\n\t5b1f17b1804b1-3fbc59de0e2so39781385e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Jul 2023 02:46:45 -0700 (PDT)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:2bce:64d6:1a5c:49a2])\n\tby smtp.gmail.com with ESMTPSA id\n\t9-20020a05600c240900b003fa98908014sm13612838wmp.8.2023.07.31.02.46.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 31 Jul 2023 02:46:44 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1690796807;\n\tbh=HZ1HQi8StWKq23YMtV9lNb7bvoOCR1720QDC6QcT1E4=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=czVGFZVfkn2M1WzwXQxABnpGA+vDtmn/Dq5Nlg4e3+QL9fIYtP7+Emmjyj2etHagn\n\t/pe5uonjVS6Oh9g0tTv7dtXJNajLoaaIg0JnfRFBsct8WP5MzQVZYsA6xMZRuJu5ii\n\t+KNpQiwovGZml+scMMo/4GdbpoPjcWUweEWCowlevUziJUtaClCoKWDOv7DpW2vyZP\n\t8cgtdQxU3JyW+kqlVE1D0v73ZnfPJzAEDBx/jmz6LnybNaVx4xbE9hey1rvzC+JXS8\n\txibIY69VPH7DkaPgCjW15sibTavqJcInfoi8jabcvjmYAW3+SFduP3vOwmSNq/pucG\n\tTqM3601cHsFMA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1690796805; x=1691401605;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=h/HPCdJqCX5ZMO0JFYmakkAGInDV7AColVdgpVx0OUg=;\n\tb=hhsezBFMFwngZF4W960Rum1Q8bmouD8FXxuf/G+390DE2pGmiX+ph5OCd6n+NXjpKc\n\tpDfT3ZYz3E/uXY3ZEsQj29FTVSdzQfJdLClQazP2UDYL9HrQBbbTW/WkfqOFnY1FyNv1\n\tzL4U2hAlRQn2t0RJYP9FgPH0mFszQS69aeMqCq1X7MU4V60Q5bMCrltPEShp1JTue1rt\n\tzIYNMwkll1Tj50pujL4QH46uSROCDtjb+BIi4L9sknXiVexmnE0Gw/k6qhmqsIxix3HV\n\tkeLjPbb0n0N9ALPKHPRmGrhdPd+hDGGic8tqQpKMjkIPxn1Bup7a7/A8cRe27ApU9RNg\n\tdjFw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"hhsezBFM\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1690796805; x=1691401605;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=h/HPCdJqCX5ZMO0JFYmakkAGInDV7AColVdgpVx0OUg=;\n\tb=H2DUDY7iRtuXmVrqbgDv5T8HL8vbRzV7kzEiBOPnQ7giRI5YXpd39ZshuZxWM2tt3A\n\t7HlqhI7h4B7cYx2H5ELc/tLXrdpeGmP707fNlEiYMT/tCGqLRXbeiGp5f1b4chqwxH1b\n\tM3u6HLRHwfO0SidrQBThxg+Lo3spzbFvUDT3+G9PuHNT87tE/hXZQSS8Ed1nSueO7LWS\n\ttnoXTqj3Vx14mhAHl1k+B345hVqS+hLDfegG4jg8SO36Hag8J8+BJ3YpwBw7P/7YpqMC\n\twn4UnSNgmbzNsa8BGc1syaD3VF87esGzzAj23nKdh86soGHaZJ8m6COrXO7fo59zD09L\n\tS96g==","X-Gm-Message-State":"ABy/qLaA+sv8pdeK4fxLmrUnLjHpb4IOOt8YiKFzsI5ODWYgJq3BZbjs\n\tGqfSdMlcz7g79wsr/mt3GdIre00cfwUmQul0Xus=","X-Google-Smtp-Source":"APBJJlG12ndMc8bSFhB6u4TaelSaEt16AsSyxODEwjEYZZPdQ4WyHVCAnNbisUnBHyPipBZD32pgNw==","X-Received":"by 2002:a05:600c:2143:b0:3fe:2140:f504 with SMTP id\n\tv3-20020a05600c214300b003fe2140f504mr1396263wml.20.1690796804783; \n\tMon, 31 Jul 2023 02:46:44 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 31 Jul 2023 10:46:37 +0100","Message-Id":"<20230731094641.73646-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20230731094641.73646-1-david.plowman@raspberrypi.com>","References":"<20230731094641.73646-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/5] ipa: rpi: histogram: Add\n\tinterBinMean()","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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Naushir Patuck <naush@raspberrypi.com>\n\nAdd a new helper function Histogram::interBinMean() that essentially\nreplaces the existing Histogram::interQuantileMean() logic but working on\nbins instead.\n\nRework the interQuantileMean() to call into interBinMean() with the\nappropriate convertion from quatiles to bins.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/histogram.cpp | 22 ++++++++++++++--------\n src/ipa/rpi/controller/histogram.h   |  2 ++\n 2 files changed, 16 insertions(+), 8 deletions(-)","diff":"diff --git a/src/ipa/rpi/controller/histogram.cpp b/src/ipa/rpi/controller/histogram.cpp\nindex 16a9207f..0a27ba2c 100644\n--- a/src/ipa/rpi/controller/histogram.cpp\n+++ b/src/ipa/rpi/controller/histogram.cpp\n@@ -45,20 +45,26 @@ double Histogram::quantile(double q, int first, int last) const\n \treturn first + frac;\n }\n \n-double Histogram::interQuantileMean(double qLo, double qHi) const\n+double Histogram::interBinMean(double binLo, double binHi) const\n {\n-\tassert(qHi > qLo);\n-\tdouble pLo = quantile(qLo);\n-\tdouble pHi = quantile(qHi, (int)pLo);\n+\tassert(binHi > binLo);\n \tdouble sumBinFreq = 0, cumulFreq = 0;\n-\tfor (double pNext = floor(pLo) + 1.0; pNext <= ceil(pHi);\n-\t     pLo = pNext, pNext += 1.0) {\n-\t\tint bin = floor(pLo);\n+\tfor (double binNext = floor(binLo) + 1.0; binNext <= ceil(binHi);\n+\t     binLo = binNext, binNext += 1.0) {\n+\t\tint bin = floor(binLo);\n \t\tdouble freq = (cumulative_[bin + 1] - cumulative_[bin]) *\n-\t\t\t      (std::min(pNext, pHi) - pLo);\n+\t\t\t      (std::min(binNext, binHi) - binLo);\n \t\tsumBinFreq += bin * freq;\n \t\tcumulFreq += freq;\n \t}\n \t/* add 0.5 to give an average for bin mid-points */\n \treturn sumBinFreq / cumulFreq + 0.5;\n }\n+\n+double Histogram::interQuantileMean(double qLo, double qHi) const\n+{\n+\tassert(qHi > qLo);\n+\tdouble pLo = quantile(qLo);\n+\tdouble pHi = quantile(qHi, (int)pLo);\n+\treturn interBinMean(pLo, pHi);\n+}\ndiff --git a/src/ipa/rpi/controller/histogram.h b/src/ipa/rpi/controller/histogram.h\nindex 6b3e3a9e..e2c5509b 100644\n--- a/src/ipa/rpi/controller/histogram.h\n+++ b/src/ipa/rpi/controller/histogram.h\n@@ -38,6 +38,8 @@ public:\n \tuint64_t total() const { return cumulative_[cumulative_.size() - 1]; }\n \t/* Cumulative frequency up to a (fractional) point in a bin. */\n \tuint64_t cumulativeFreq(double bin) const;\n+\t/* Return the mean value between two (fractional) bins. */\n+\tdouble interBinMean(double binLo, double binHi) const;\n \t/*\n \t * Return the (fractional) bin of the point q (0 <= q <= 1) through the\n \t * histogram. Optionally provide limits to help.\n","prefixes":["libcamera-devel","1/5"]}