Rewrite equation in c
Gain = 255 / (1 - 10 ^ ((Refblack-Refwhite) * 0.002/0.6) ^ (Dispgamma/1.7))
Is that a computer language, i开发者_开发问答t looks like c but exclusive or floats doesnt compute. Can anybody convert that to c?
thanks
In many languages, ^
is exponentiation. That's the pow()
, which has the following prototype in math.h>
:
double pow(double x, double y);
This computes x raised to the y:th power. So, this makes the equation convert to:
#include <math.h>
Gain = 255 / (1 - pow(10, pow(((Refblack-Refwhite) * 0.002/0.6), (Dispgamma/1.7))));
I guess they mean: Gain = 255 / (1.0 - powf(10, powf((Refblack-Refwhite) * 0.002/0.6), Disgamma/1.7)))
Because ^ is normaly xor operator in C. As others used pow it will only use int:s and return a int. man 3 pow for more information.
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)) ) )
Looks like Matlab code to me
in C, something like that
#include <math.h>
float Gain=0;
...
Gain = 255 / (1 - powf(10, powf(((Refblack-Refwhite) * 0.002/0.6), (Dispgamma/1.7));
精彩评论