Gain = 255 / (1 - 10 ^ ((Refblack-Refwhite) * 0.002/0.6) ^ (Dispgamma/1.7))
那是一种计算机语言吗,它看起来像 c 但排他性或浮点数不计算。任何人都可以将其转换为c吗?
谢谢
在许多语言中,^
是取幂。那就是pow()
,它在 中具有以下原型math.h>
:
double pow(double x, double y);
这将计算 x 的 y:th 次方。因此,这使得等式转换为:
#include <math.h>
Gain = 255 / (1 - pow(10, pow(((Refblack-Refwhite) * 0.002/0.6), (Dispgamma/1.7))));
我猜他们的意思是:Gain = 255 / (1.0 - powf(10, powf((Refblack-Refwhite) * 0.002/0.6), Disgamma/1.7)))
因为 ^ 在 C 中是正常的 xor 运算符。正如其他人使用 pow 一样,它只会使用 int:s 并返回一个 int。man 3 pow 了解更多信息。
gain = 255.0 / (1.0 - pow(10.0, pow((Refblack - Refwhite) * 0.002 / 0.6, Dispgamma / 1.7) ))
Gain = 255 / (1 - pow(10 , ( pow( (Refblack-Refwhite) * 0.002/0.6) , (Dispgamma/1.7)) ) )
对我来说看起来像 Matlab 代码
在C中,类似的东西
#include <math.h>
float Gain=0;
...
Gain = 255 / (1 - powf(10, powf(((Refblack-Refwhite) * 0.002/0.6), (Dispgamma/1.7));