简体   繁体   English

计算亮度的常数k是多少

[英]what is the constant k in calculating the luminance

I want to calculate the luminance of image using RGB value but in the formula there is a constant ki didn't know what it is this is the formula from the document:我想使用 RGB 值计算图像的亮度,但在公式中有一个常量 ki 不知道它是什么这是文档中的公式:

"In calculating luminance (L), CIE Y is multiplied by a constant value 'k', where k can be either aconstant for the camera or determined for a scene based on a measurement of a selected region in the scene. “在计算亮度 (L) 时,CIE Y 乘以一个常数值‘k’,其中 k 可以是相机的常数,也可以是根据场景中选定区域的测量值确定的场景。

L=k*(0,2127 Red+0,7151 Green+0,0722*Blue) (cd/m²) L=k*(0,2127红+0,7151绿+0,0722*蓝) (cd/m²)

this is the link to the document: https://faculty.washington.edu/inanici/Publications/LRTPublished.pdf emphasized text这是文档的链接: https://faculty.washington.edu/inanici/Publications/LRTPublished.pdf强调文本

Short Answer简答

You are conflating something that is only for a specific piece of software called "Photosphere" and that math is not for general luminance use.您正在混淆仅适用于名为“Photosphere”的特定软件的东西,并且该数学不适用于一般亮度用途。

Complete Answer完整答案

You said:你说:

calculate the luminance of image using RGB value使用RGB值计算图像的亮度

What do you mean?你是什么意思? The luminance of some given pixel?某个给定像素的亮度? Or the RMS average luminance?还是 RMS 平均亮度? Or???或者???

AND: What colorspace (profile) is your image in?并且:您的图像在什么色彩空间(配置文件)中?

I am going to ASSUME your image is sRGB, and 8 bit per pixel.我将假设您的图像是 sRGB,每像素 8 位。 But it could be P3 or Adobe98, or any number of others... The math I am going to show you is for sRGB.但它可能是 P3 或 Adobe98,或任何数量的其他...我要向您展示的数学是针对 sRGB 的。

1) Convert to float 1)转换为浮点数

Each 8bit 0-255 sRGB color channel must be converted to 0.0-1.0每个 8bit 0-255 sRGB 颜色通道必须转换为 0.0-1.0

    let rF = sR / 255.0;
    let gF = sG / 255.0;
    let bF = sB / 255.0;

2) Convert to linear 2)转换为线性

The transfer curve aka "gamma" must be removed.传输曲线又名“伽马”必须被删除。 For sRGB, the "accurate" method is:对于 sRGB,“准确”的方法是:

    function sRGBtoLin(chan) {
       return (chan > 0.04045) ? Math.pow(( chan + 0.055) / 1.055, 2.4) : chan / 12.92
    }

3) Calculate Luminance 3)计算亮度

Now, multiply each linearized channel by the appropriate coefficient, and sum them to find luminance.现在,将每个线性化通道乘以适当的系数,然后将它们相加得到亮度。

  let luminance = sRGBtoLin(rF) * 0.2126 + sRGBtoLin(gF) * 0.7152 + sRGBtoLin(bF) * 0.0722;

BONUS: Andy's Down and Dirty Version奖励:安迪的肮脏版本

Here's an alternate that is still usefully accurate, but simpler for better performance.这是一个仍然有用的替代方法,但更简单以获得更好的性能。 Raise each channel to the power of 2.2, then multiply the coefficients, and sum:将每个通道提高到 2.2 的幂,然后乘以系数,然后求和:

  let lum = (sR/255.0)**2.2*0.2126+(sG/255.0)**2.2*0.7152+(sB/255.0)**2.2*0.0722;

Let me know if you have additional questions...如果您还有其他问题,请告诉我...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM