Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1361457ybk; Sat, 16 May 2020 08:53:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlKW0fON7LiwewlavCPCquVlvEIgostzmOrCpb01w1Qw3YT5KmeUhmaC9kyF7DZI6kOcgB X-Received: by 2002:a50:9317:: with SMTP id m23mr5992422eda.65.1589644431743; Sat, 16 May 2020 08:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589644431; cv=none; d=google.com; s=arc-20160816; b=ld83hIXv9fGM+p6pDK0GaNkX8MqlI5SVOJDidQayd8GCweN58yZPMYiw/RsYBQIL7z nYpijFVnCb6ukFfDZKK97ZYXIc0Q8XenTdxhrnc3az7vTK1bxWPUOt0ryt3IqUGpF01J a7JA/yAMLuohOGUaeVYjAMRLbV3wN3jKn0vY7Q6MPhM4WnNKyk2REgu6FXH2/X1B2IOC rnRrolwBA+WG6ZxpH1iKdY39/KerEu6Ig876pU5gT+u5RR9qhnruJ4iLV+Pr2IyRnXCp nZjqQ1+uYuBY8vBP/k4DxClOOsExvKBgyyXc542m22qTnAQXJa5QJNJK82DM7w5mBpiy mf+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/3LDkoCyC6iwqkWga9GxzkEUq2af7i2KGCzBIFVgxuw=; b=dwzkY7/LP+nUirksb1Xx4raZCx/rdfZQJni2pk/VMuG8B+VPpT8RoIOZCOWM/bTqDm KF6LAxZs8vnXAk0ddTVX6nagmWCOE9LwPJE7S0K1JBM8w1G/SX29Uj5+7Ymo5OsxMyJB PPJ11Q8H2hYNZJPAxCLeLIvdkLBpzwVx7rHDvw+ixUzKB0/w18i4Z+m0r3LHG03aMOQY ord10jNJhYJ8a+oAxPWs+qIAG40EEDhow6KEyWXspiMzNRzI6K0oTMCUkR0GOf8mInT3 17IAnKwdkeQqmrgRTOp2WpoqEruuc0VsZ72Naxh4L5pKDQBf0TmWw6J0+CTOeEUeI+8X Zn+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g6Qldw4v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si2955095ejr.498.2020.05.16.08.53.28; Sat, 16 May 2020 08:53:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g6Qldw4v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726229AbgEPPuE (ORCPT + 99 others); Sat, 16 May 2020 11:50:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:42220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726206AbgEPPuD (ORCPT ); Sat, 16 May 2020 11:50:03 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8EE2420727; Sat, 16 May 2020 15:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589644202; bh=hhy3Rx5Ua0JE3z3fSJo5xllDQdIaYvzcHljCDwp2hhc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=g6Qldw4v2VsyLxn3pAuJEYfYac96RqAzfRLt0DeeFvUybBiIPNtarqL5e5wyZorpv vktZNcUwy4kPRC5a1Rqrzg0ad8AyGnWW5AxKcJ/VDso7R9TxnfB9ui/vKWKY3JDZ+J 7Knxh+wMHq0/XYEG7ZBgdOZofa3MtbdDf3xC9G/I= Date: Sat, 16 May 2020 16:49:58 +0100 From: Jonathan Cameron To: Gwendal Grignou Cc: Jonathan Cameron , Enric Balletbo i Serra , Benson Leung , Guenter Roeck , linux-kernel , linux-iio Subject: Re: [PATCH v2 1/3] iio: Add in_illumincance vectors in different color spaces Message-ID: <20200516164958.453c8469@archlinux> In-Reply-To: References: <20200506230324.139241-1-gwendal@chromium.org> <20200506230324.139241-2-gwendal@chromium.org> <20200508161635.00006cd2@Huawei.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 May 2020 21:10:40 -0700 Gwendal Grignou wrote: > On Fri, May 8, 2020 at 8:16 AM Jonathan Cameron > wrote: > > > > On Wed, 6 May 2020 16:03:22 -0700 > > Gwendal Grignou wrote: > > > > Illuminance in the title. Plus I'm still arguing these > > aren't illuminance values. > > > > The Y value is illuminance but X and Z definitely aren't. > > RGB needs to stick to intensity - like the other existing > > RGB sensors. > > > > Gah. XYZ and IIO is a mess. > > > > I suppose we could introduce a new type and have > > in_illumiance_raw > > in_chromacity_x_raw > > in_chromacity_z_raw but chances of anyone understanding what we > > are on about without reading wikipedia is low... > > > > Sigh. Unless someone else chips in, I'm inclined to be lazy and rely > > on documentation to let in_illuminance_x,y,z be defined as being > > cie xyz color space measurements. > > > > It seems slighlty preferable to defining another type for these, > > though I suspect I'll regret this comment when some adds > > cie lab which was always my favourite colour space :) > > > > > > > > > Define 2 spaces for defining color coming from color sensors: > > > RGB and XYZ: Both are in lux. > > > RGB is the raw output from sensors (Red, Green and Blue channels), in > > > addition to the existing clear channel (C). > > > > > The RGBC vector goes through a matrix transformation to produce the XYZ > > > vector. Y is illumincance, and XY caries the chromaticity information. > > > The matrix is model specific, as the color sensor can be behing a glass > > > that can filter some wavelengths. > > > > > > Signed-off-by: Gwendal Grignou > > > --- > > > New in v2. > > > > > > Documentation/ABI/testing/sysfs-bus-iio | 27 +++++++++++++++++++++++++ > > > 1 file changed, 27 insertions(+) > > > > > > diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio > > > index d3e53a6d8331b..256db6e63a25e 100644 > > > --- a/Documentation/ABI/testing/sysfs-bus-iio > > > +++ b/Documentation/ABI/testing/sysfs-bus-iio > > > @@ -1309,6 +1309,33 @@ Description: > > > Illuminance measurement, units after application of scale > > > and offset are lux. > > > > > > +What: /sys/.../iio:deviceX/in_illuminance_red_raw > > > +What: /sys/.../iio:deviceX/in_illuminance_green_raw > > > +What: /sys/.../iio:deviceX/in_illuminance_blue_raw > > > +KernelVersion: 5.7 > > > +Contact: linux-iio@vger.kernel.org > > > +Description: > > > + Illuminance measuremed in red, green or blue channels, units > > > + after application of scale and offset are lux. > > > > No they aren't. Units are some magic intensity at some magic wavelength. > > > > > + > > > +What: /sys/.../iio:deviceX/in_illuminance_x_raw > > > +What: /sys/.../iio:deviceX/in_illuminance_y_raw > > > +What: /sys/.../iio:deviceX/in_illuminance_z_raw > > > +KernelVersion: 5.7 > > > +Contact: linux-iio@vger.kernel.org > > > +Description: > > > + lluminance measured in the CIE 1931 color space (XYZ). > > > + in_illuminance_y_raw is a measure of the brightness, and is > > > + identical in_illuminance_raw. > > > > That is fair enough. > > > > > + in_illuminance_x_raw and in_illuminance_z_raw carry chromacity > > > + information. > > > + in_illuminance_x,y,z_raw are be obtained from the sensor color > > > + channels using color matching functions that may be device > > > + specific. > > > + Units after application of scale and offset are lux. > > > > True for Y, not for X and Z which don't have 'units' as such. > Indeed,I have difficulty mapping what comes from the sensor after > adapting to an acceptable universal entity. > > The goal of the sensor is to measure the ambient correlated color > temperature (CCT), based on the x and y of the CIE xyY color space. > Given x and y are defined as x = X / (X + Y +Z) and y = X / (X + Y + > Z), X, Y and Z must have the same units. The issue here is that illuminance is an unusual thing. To go for an analogy. It's like measuring the volume of something at a particular temperature. However, it's only defined at that temperature. You can divide it by other volumes at other temperatures and get all sorts of interesting quantities and much like volume the indeed have the same units, but that unit is not lux (which is unit of illuminance). The reason being illuminance is like defining volume at 0 degree centigrade. Illuminance is only defined for that particular set of frequencies and is not defined otherwise. If we'd called our light input something other than illuminance - say 'in_light_raw' then we could play fast and loose with units perhaps but we didn't. We deliberately used intensity to represent all light measurements other than the one specific one that is illuminance. So we should stick to intensity really which was chosen specifically to 'not carry' the weird characteristics that illuminance has. It deliberately makes no statement about frequency sensitivity etc. In a past life I did a lot of work machine vision so am familiar with most of the standard colour spaces and what they were trying to do when defining them. Personally always like CieLAB because you can basically use it to get rid of shadows :) Maths to compute it is however fairly crazy. Jonathan > > CCT(x,y) is computed in user space, for example using this > approximation (https://en.wikipedia.org/wiki/Color_temperature#Approximation). > > Gwendal. > > > > > > > + The measurments can be used to represent colors in the CIE > > > + xyY color space > > > > XYZ > > > > > + > > > What: /sys/.../iio:deviceX/in_intensityY_raw > > > What: /sys/.../iio:deviceX/in_intensityY_ir_raw > > > What: /sys/.../iio:deviceX/in_intensityY_both_raw > > > >