{"id":18990,"url":"https://patchwork.libcamera.org/api/1.1/patches/18990/?format=json","web_url":"https://patchwork.libcamera.org/patch/18990/","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":"<20230912102442.169001-2-david.plowman@raspberrypi.com>","date":"2023-09-12T10:24:38","name":"[libcamera-devel,v3,1/5] ipa: rpi: histogram: Add interBinMean()","commit_ref":null,"pull_url":null,"state":"accepted","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/18990/mbox/","series":[{"id":4017,"url":"https://patchwork.libcamera.org/api/1.1/series/4017/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4017","date":"2023-09-12T10:24:37","name":"Multi-channel AGC","version":3,"mbox":"https://patchwork.libcamera.org/series/4017/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18990/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18990/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 0EFB9C3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Sep 2023 10:24:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BF5A9628EB;\n\tTue, 12 Sep 2023 12:24:50 +0200 (CEST)","from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n\t[IPv6:2a00:1450:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B642261DF5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Sep 2023 12:24:49 +0200 (CEST)","by mail-wm1-x336.google.com with SMTP id\n\t5b1f17b1804b1-401187f8071so34649575e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Sep 2023 03:24:49 -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\tn10-20020a05600c294a00b003fefaf299b6sm12426575wmd.38.2023.09.12.03.24.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 12 Sep 2023 03:24:48 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1694514290;\n\tbh=u61zsKeWhQAgxve5YcLlCpBT79AgLH4OcJpd3Ged9qE=;\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:Cc:\n\tFrom;\n\tb=mOQJMy1SAQ6aGGQES1D0BdcxhvdSoQETBChIkBXLuPrVVzrMu8OfCSTHgyyjAkIaB\n\tbSu/7MyDmD7ae6XZrS4H+qy/DqrGFcs+/QzDfflEBKL81Ai7/H1s1Kugvm6CvfSBhj\n\tJryHWi0/XDio+8UREQXHx1yrLH+g02CoRy84KfOoA/y0/ky4AWno1CJFf9IyoNgwNg\n\taapsebjLvla5bxT7pUQGY9bB8oZKDmuv8TGsCofCrpxViiyl2L+SiaXTwzOGqd66vf\n\tLl3xY+fhiIe25H63K+D3LFsfESeVhaS6nt4UnhVK7G2DAAN+BuNw0l3OkGiFZtra1x\n\tgNUaECZz2U0VQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1694514289; x=1695119089;\n\tdarn=lists.libcamera.org; \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=PLzIHdZWYnWfcoP1tg/UVALNkMV3EEqa5nrqb1B3Op8=;\n\tb=ZqOtJnXq27bqmullABTCillBFVq+PgRekiWzUQPA9/73Ja6/AUaGnjzBdWys7D1Mnv\n\tnguIEzNQVZr9fJypbKSsqG6EEAmrv0k5q0sw50Zyj5wj8Znid4VhKQoKC/J7+d781HDL\n\tD6RoRLN1x4gAyDAH1thZQAUGVUi+cXmJfJl6lmD8R3af+bqmEi74WjgGtEHUMtR5yHbu\n\tRglGeLBhMfsLTB7r9I1vJep4uQjUuFMBSuUm3V9FNtViJh6iexMaxpPwrUSsJiryNouA\n\tEJn7HxG+zEnL1H/94dO8tZlpZuJzp8g0yl8jSCXwdribiWW/SJ7xU/dCARpWuWmc08Vl\n\tTn2Q=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"ZqOtJnXq\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1694514289; x=1695119089;\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=PLzIHdZWYnWfcoP1tg/UVALNkMV3EEqa5nrqb1B3Op8=;\n\tb=tD92C6sChdD3w2ZsO0Pvin+LWCA6LA0pQ3s/+qZ82f+hc73uBbTX33uYKfQqSHzGdg\n\t3f4mBh4bChmsOPVxNggq3/EuXj8kE2Fg00InRL7gOlGTySEKPrDWhnrCh9P5yNhQ0L4r\n\tZ3ZItxOREb+28Ta3E7DdqzYpj4FKxJg/D0z3v0jV8YaIXHn3CIJo4Vp0Puh1CmjSJKMc\n\tsmmUCi4i2aUUT9kqCwydo37gY9PzzZj1CRiWXnEsua7J4db1ONS9k/his4LW35tLO7DX\n\teGEPhQI9uIpPKBnADrGHCOC/XMVGsqd/Nr7FL5ukqyMAYAISh7tbw/YtV2zi+HgV6ea0\n\tIyvw==","X-Gm-Message-State":"AOJu0Yw7SnNcNM7DXy9HDcotnoCV4boT44plj2rwqYgEG2lNfNpVeakS\n\tmYpHl1ssQZhPweIC0WfF5Kx9DNEfGXKBx89pOXY=","X-Google-Smtp-Source":"AGHT+IGA1/dF52bpUR8gI4eoeqLslap1LQdCuGOxKX0wVJ9uFAz/oHq3cjLGey5aQeMQbqz743/v2A==","X-Received":"by 2002:a1c:4c09:0:b0:3ff:516b:5c4c with SMTP id\n\tz9-20020a1c4c09000000b003ff516b5c4cmr1522718wmf.18.1694514289040; \n\tTue, 12 Sep 2023 03:24:49 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 12 Sep 2023 11:24:38 +0100","Message-Id":"<20230912102442.169001-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20230912102442.169001-1-david.plowman@raspberrypi.com>","References":"<20230912102442.169001-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 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>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.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>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.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","v3","1/5"]}