From patchwork Sat Jul 4 09:59:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 8617 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 9F079BD792 for ; Sat, 4 Jul 2020 09:59:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6494C603AA; Sat, 4 Jul 2020 11:59:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fOxGU8Jd"; dkim-atps=neutral Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E1CD1603AA for ; Sat, 4 Jul 2020 11:59:24 +0200 (CEST) Received: by mail-wr1-x42e.google.com with SMTP id z2so13012854wrp.2 for ; Sat, 04 Jul 2020 02:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cdAGZtHKtZqwU2zD4B5mvtMuoo6AbqD0SlgJ9r60fco=; b=fOxGU8Jd4SOH1lOX2753RO4Tr8aR47xFD5pSkybL02EKMiG/A0YiIw96gJUt7o8KBZ 65ZhDxRmQjJfrd07SjU5XGd2+v77zCmtCC8dQB9oneUECt0Bg07WOnQyUJ3i97OhYr3f xv5Y6UHUoxX3WhcYU16xqF8D2OUITRRz+Vlu49uq0MoMSY4MT/rqFVq1jhJt9jLGmAvF OSIwL4+6AZYpExWZhGmZq62e04ZLHb5B3cI8IjcKroAqP+eoF6Ei4GbX2clWxGupPLm8 S6HUVcLTzOMlO3XeRqoLnQDTsVC8rG5kpZPZo1R3cggEcbRbClVts+m4d9HljsE/8hyQ LvMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cdAGZtHKtZqwU2zD4B5mvtMuoo6AbqD0SlgJ9r60fco=; b=CHVVjYq3kv1SReWISsvuHcmCPbXwW2TiVxSaonwambgTNycT9oTxF+huObjYrGqsVU iOQ11+5R/w+WJiE6iq2L2/zv+YU+bwvYpfgpU1zy9h6MD9Q/7pz2Wu5q6HSBmy7BoC4U 9VfReZj5dWvdMGZLVX4o4Z+Tw6X3+IaYZfdDIT2gTN5g6m6gftWChosVUqsHRpUc8sKL Bfk3B/f10yyM1QbrVB8a6/vv/9noxFg7JR6CiO9Tx/0z275s0F1Mn/JtsXXrGuzMM/rZ EGAdi0LwTNwilHf8LXdW1sS1vXhlxe0w5webwZLA2tqxtAZdjQBnTEalzO6No8dKLzsI OjFQ== X-Gm-Message-State: AOAM533swGk2Gr189uQVBI7qfCoRd/cW5ZBpV0qXnVd/J5e/sHdOKKuK Joga48QvYdhbsl6mr4vkeBut5n9iojk= X-Google-Smtp-Source: ABdhPJzAW6bvYNpVPBhWz3I5e8T9Hm2KplLB2ugoBn30L0sF2JbTfnoS83ZB/5r9iKM6bPUfQbAqrg== X-Received: by 2002:adf:f60a:: with SMTP id t10mr32264539wrp.64.1593856764412; Sat, 04 Jul 2020 02:59:24 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id z10sm11477681wrm.21.2020.07.04.02.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 02:59:24 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 10:59:12 +0100 Message-Id: <20200704095914.17344-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200704095914.17344-1-david.plowman@raspberrypi.com> References: <20200704095914.17344-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] libcamera: Add ColourCorrectionMatrix control 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" This control is principally for returning, in the image metadata, the CCM (Colour Correction Matrix) used by the imaging pipeline. By which we mean the 3x3 matrix that is applied to the camera RGB pixels after subtraction of black levels and white-balancing, but before any gamma transformation. Some implementations may also choose to let an application set explicit colour matrices, using this as a control. Signed-off-by: David Plowman Reviewed-by: Laurent Pinchart --- src/libcamera/control_ids.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 8c3e4c7..23c3f06 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -251,4 +251,16 @@ controls: higher than anyone could reasonably want. Negative values are not allowed. Note also that sharpening is not applied to raw streams. + + - ColourCorrectionMatrix: + type: float + description: | + The 3x3 matrix that converts camera RGB to sRGB within the + imaging pipeline. This should describe the matrix that is used + after pixels have been white-balanced, but before any gamma + transformation. The 3x3 matrix is stored in conventional reading + order in an array of 9 floating point values. + + size: [9] + ... From patchwork Sat Jul 4 09:59:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 8619 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 3FEC8BD794 for ; Sat, 4 Jul 2020 09:59:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B1CF860DFA; Sat, 4 Jul 2020 11:59:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Mpsb9vD6"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 66FDE609C7 for ; Sat, 4 Jul 2020 11:59:26 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id a6so23767383wmm.0 for ; Sat, 04 Jul 2020 02:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GFh3wkDdONKwREfYhfL0pB5YOH4zlaqiZUR/aVLv/zk=; b=Mpsb9vD6lJqDCYsb0/oBdy8+Pk9DR+hGeYjQ82OlMl/xCknvJ9j+6LKQ3KqxBcuP3N pJIHXGn3CzqQYSQMXNTNTNU3Z9cA2vVFsXxp5aciK+mZTVgpbMGUk9LIKY+hF6nHoi6O 8d7h6Bqdcou7msu2xs6FVVhHJTbZnmapzKpZ/nzIr7DsIcEXz5wBngt8RPaCHdXrLeyH uYyRogPjpOe/QyHe1WY+QgQbIxGtIQC+S8GKjQCQ4tev58a4Llnu/ONmOAqLznKGcSH7 2XgQ/HIqsKuUfu5oBHhAqo7rczE55j+7rQukNFZl3P7Mj6soBW/zysHDswSu14bxtejv tA9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GFh3wkDdONKwREfYhfL0pB5YOH4zlaqiZUR/aVLv/zk=; b=BtGRHyMiBUp9bN5jjwN88Mf5mUglttAllGiq7xFMZXeGir3kyI6ARBcqmqS5guW7hi sbaIiCta0tbCpzK9I9ApuYMTFD6ANNhw+uXAfJl6ciEgh5pr/8lpC81q/HPZZ4ljTb5N v34549PpwcapSlMRz8OPXtnxYeEMYasJDCRjrNT1q1CYMCYXLCX7SYaIsGdGgSZ2m29P TRx+iSEejwkZvB8Pzu8TElMaTNils8kgd3F/H31OT267LbTQyfV6rbqHJ30NoiqkSKlR u7IbGuA9OjHnhrXr/xww7O5n7KxRXGB4ZyRh9qSRY0tg7jpPYJRmdIFumAo/PVeYUFkV xBKg== X-Gm-Message-State: AOAM5337Hs7xB0unXWn42c4+YrRSFr2fISx0tQOFD7ONdFYUHVcjEPpV eUJgw1vPW6bc7T437hqBXj3+LWgmyew= X-Google-Smtp-Source: ABdhPJzkhS7h8202DUxGPksfJCthQ1ZZFl1X86ROwef/JK0BAlV6crSw7uj2FPXVWlN3iUblpsevag== X-Received: by 2002:a1c:f714:: with SMTP id v20mr39337667wmh.81.1593856765577; Sat, 04 Jul 2020 02:59:25 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id z10sm11477681wrm.21.2020.07.04.02.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 02:59:25 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 10:59:13 +0100 Message-Id: <20200704095914.17344-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200704095914.17344-1-david.plowman@raspberrypi.com> References: <20200704095914.17344-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] libcamera: raspberrypi: Add ColourCorrectionMatrix control 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" Implements, for the Raspberry Pi platform, the returning of the CCM (Colour Correction Matrix) used by the pipeline in the libcamera metadata. Signed-off-by: David Plowman --- include/libcamera/ipa/raspberrypi.h | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index a18ce9a..2682319 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -52,6 +52,7 @@ static const ControlInfoMap RPiControls = { { &controls::Contrast, ControlInfo(0.0f, 32.0f) }, { &controls::Saturation, ControlInfo(0.0f, 32.0f) }, { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) }, + { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, }; } /* namespace libcamera */ diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bc89ab5..592bb04 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -404,6 +404,15 @@ void IPARPi::reportMetadata() static_cast(blackLevelStatus->black_level_g), static_cast(blackLevelStatus->black_level_g), static_cast(blackLevelStatus->black_level_b) }); + + CcmStatus *ccmStatus = rpiMetadata_.GetLocked("ccm.status"); + if (ccmStatus) { + float m[9]; + int i; + for (i = 0; i < 9; i++) + m[i] = ccmStatus->matrix[i]; + libcameraMetadata_.set(controls::ColourCorrectionMatrix, m); + } } /* From patchwork Sat Jul 4 09:59:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 8620 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 43C83BD790 for ; Sat, 4 Jul 2020 09:59:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 07F3660DD3; Sat, 4 Jul 2020 11:59:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Q/hhBLVl"; dkim-atps=neutral Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A14D360DF3 for ; Sat, 4 Jul 2020 11:59:27 +0200 (CEST) Received: by mail-wm1-x342.google.com with SMTP id l17so34215073wmj.0 for ; Sat, 04 Jul 2020 02:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iY+GHfBzn33kHSONBRFpZ/briIH9MQ/8QlpghUiYqCk=; b=Q/hhBLVlBMIuxOMNRBysA43OEbsUx5wl6UaldaG8ImeBO3EUTxxJiph4ffrgSGvN32 MrgWK82pebg24quB7eJVCRj21KO6D0MXOGNjKOX+D0+1YJDSX11zFiYa1qeXqM2JJiCA xZYYhxQuQjPr13dAHxbrGZ2qqBO5nNSLJGHYayqSuu87Mfae9z9ynGprnFYbJqXeoiG9 gZ9V72LdNm59qosyZ4o1NZ2tQnoA1uDGjtc01tnDXi7rDToESgu6sAC29PcYYnsBMrw1 6FcBjJLm1HHWEBhwJKCrlVUN+u1uf70y4O+aIn1kHBe2qJogpRX0jJOFukbfJyhou+ll NR6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iY+GHfBzn33kHSONBRFpZ/briIH9MQ/8QlpghUiYqCk=; b=i00bEqd+PafuTAaOQmm1xwZL8ox1cIXMruhU/BKlrWc0l9z+H7NhAUYZ1TYA24j1eE VReqBYHpJaqLmCpfkgFdBKtcCB0tMBxVSk7M+jqiMdL7NE38yuKHkxT91fhALrJMsmA1 ZxBZjq+iAxoQozE0yCEENSb7dbkqCmZMBCn8ij3LtYSkNXZM+IfXP+B0TmSXWsWlALNM yzkfxy9em/JJ1vu0rP6SZUS28y/L+tuVQSv58Fyexim4QP+BS89Jo/z0+xYjwJFzD1af LoHbmOWTIGxZ2nm/KDTG/pn+K4emB/vPQulO3O8/iAWue2gbIACfPjAEX7mSGqm0t7+L jYDg== X-Gm-Message-State: AOAM532vyfKX24Nt1NtmoxazOJsvfZ/eoohoCqo8gtslCUbqAMDBrN0h TuHL/3jL0V5lvoXwFN57MiM9gACrW/o= X-Google-Smtp-Source: ABdhPJxIwNObF395vUAUZfW3kBDCuG/LMeqmTwih/Rr2BkoPFIliOV5/jtI/gx7XULD4JXa8zReJgg== X-Received: by 2002:a1c:2543:: with SMTP id l64mr18043956wml.31.1593856766953; Sat, 04 Jul 2020 02:59:26 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id z10sm11477681wrm.21.2020.07.04.02.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 02:59:26 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 10:59:14 +0100 Message-Id: <20200704095914.17344-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200704095914.17344-1-david.plowman@raspberrypi.com> References: <20200704095914.17344-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] libcamera: qcam: Improve colour information in DNG files 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" This patch improves the colour information recorded in DNG files using the ColourCorrectionMatrix metadata for the image. Note that we are not supplying a full calibration using two illuminants, nonetheless the single matrix here appears to be respected by a number of tools. Signed-off-by: David Plowman --- src/qcam/dng_writer.cpp | 93 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index 61505d3..222df9f 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -34,6 +34,63 @@ struct FormatInfo { unsigned int stride); }; +struct Matrix { + Matrix(float m0, float m1, float m2, + float m3, float m4, float m5, + float m6, float m7, float m8) + { + m[0] = m0, m[1] = m1, m[2] = m2; + m[3] = m3, m[4] = m4, m[5] = m5; + m[6] = m6, m[7] = m7, m[8] = m8; + } + Matrix(float diag0, float diag1, float diag2) + : Matrix(diag0, 0, 0, 0, diag1, 0, 0, 0, diag2) {} + Matrix() {} + float m[9]; + Matrix transpose() const + { + return Matrix(m[0], m[3], m[6], m[1], m[4], m[7], m[2], m[5], m[8]); + } + Matrix cofactors() const + { + return Matrix(m[4] * m[8] - m[5] * m[7], + -(m[3] * m[8] - m[5] * m[6]), + m[3] * m[7] - m[4] * m[6], + -(m[1] * m[8] - m[2] * m[7]), + m[0] * m[8] - m[2] * m[6], + -(m[0] * m[7] - m[1] * m[6]), + m[1] * m[5] - m[2] * m[4], + -(m[0] * m[5] - m[2] * m[3]), + m[0] * m[4] - m[1] * m[3]); + } + Matrix adjugate() const { return cofactors().transpose(); } + float determinant() const + { + return (m[0] * (m[4] * m[8] - m[5] * m[7]) - + m[1] * (m[3] * m[8] - m[5] * m[6]) + + m[2] * (m[3] * m[7] - m[4] * m[6])); + } + Matrix inverse() const { return adjugate() * (1.0 / determinant()); } + Matrix operator*(Matrix const &other) const + { + Matrix result; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + result.m[i * 3 + j] = + m[i * 3 + 0] * other.m[0 + j] + + m[i * 3 + 1] * other.m[3 + j] + + m[i * 3 + 2] * other.m[6 + j]; + return result; + } + Matrix operator*(float const &f) const + { + Matrix result; + for (int i = 0; i < 9; i++) + result.m[i] = m[i] * f; + return result; + } +}; + void packScanlineSBGGR10P(void *output, const void *input, unsigned int width) { const uint8_t *in = static_cast(input); @@ -315,6 +372,42 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); + /* + * Fill in some reasonable colour information in the DNG. We supply + * the "neutral" colour values which determine the white balance, and the + * "ColorMatrix1" which converts XYZ to (un-white-balanced) camera RGB. + * Note that this is not a "proper" colour calibration for the DNG, + * nonetheless, many tools should be able to render the colours better. + */ + float neutral[3] = { 1, 1, 1 }; + Matrix wbGain(1, 1, 1); + /* From http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html */ + Matrix rgb2xyz(0.4124564, 0.3575761, 0.1804375, + 0.2126729, 0.7151522, 0.0721750, + 0.0193339, 0.1191920, 0.9503041); + Matrix ccm(1, 1, 1); + const double eps = 1e-2; + + if (metadata.contains(controls::ColourGains)) { + Span colour_gains = metadata.get(controls::ColourGains); + if (colour_gains[0] > eps && colour_gains[1] > eps) { + wbGain = Matrix(colour_gains[0], 1, colour_gains[1]); + neutral[0] = 1.0 / colour_gains[0]; /* red */ + neutral[2] = 1.0 / colour_gains[1]; /* blue */ + } + } + if (metadata.contains(controls::ColourCorrectionMatrix)) { + Span m = metadata.get(controls::ColourCorrectionMatrix); + Matrix tmp = Matrix(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8]); + if (tmp.determinant() > eps) + ccm = tmp; + } + /* This is guaranteed to be invertible because all the bits in it are. */ + Matrix colorMatrix1 = (rgb2xyz * ccm * wbGain).inverse(); + + TIFFSetField(tif, TIFFTAG_COLORMATRIX1, 9, colorMatrix1.m); + TIFFSetField(tif, TIFFTAG_ASSHOTNEUTRAL, 3, neutral); + /* * Reserve space for the SubIFD and ExifIFD tags, pointing to the IFD * for the raw image and EXIF data respectively. The real offsets will