Simple math:
log2 (x) = logy (x) / logy (2)
where y can be anything, which for standard log functions is either 10 or e.
Answer from Adam Crume on Stack OverflowHi I’m new to the whole high end camera thing. When I first got into shooting videos all the YouTubers were talking about C-log 3 when reviewing canon cameras. I recently for the first time heard about C-log 2. Is the difference that noticeable? What would be the differences?
Videos
What is the difference between Canon Log, Canon Log 2 and Canon Log 3?
The original Canon Log delivers a dynamic range of approximately 12 stops, Canon Log 2 up to 16 stops, and Canon Log 3 up to 14 stops. Canon Log 2 retains more detail in darker areas than Canon Log 3 but also features an elevated noise floor. Canon Log 3 is easier to grade thanks to producing a cleaner image and retains the same amount of highlight information as Canon Log 2.
What is Canon Log used for?
Canon Log is used to capture video footage that has a wider dynamic range and exposure latitude than standard video. The Canon Log tone curve is applied at the point of capture to retain more details in the highlights and shadows compared to standard video.
How does Canon Log help with colour grading in post-production?
Canon Log helps with colour grading as it is recorded at 10-bit colour depth and provides a flat image with low saturation that is an excellent foundation for colour adjustments and HDR workflows. It is easier to match footage shot on different cameras that have been set to Canon Log, enabling clips from Cinema EOS and EOS mirrorless cameras to be combined and colour matched to give a consistent look on a multi-cam shoot.
From here:
Prototype: double log2(double anumber);
Header File: math.h (C) or cmath (C++)
Alternatively emulate it like here
#include <math.h>
...
// Calculates log2 of number.
double Log2( double n )
{
// log(n)/log(2) is log2.
return log( n ) / log( 2 );
}
Unfortunately Microsoft does not provide it.
log2() is only defined in the C99 standard, not the C90 standard. Microsoft Visual C++ is not fully C99 compliant (heck, there isn't a single fully C99 compliant compiler in existence, I believe -- not even GCC fully supports it), so it's not required to provide log2().
#include <stdio.h>
#include <math.h>
int main() {
double x = 42.0;
printf( "log( %f ) = %f\n", x, log2(x) );
return 0;
}
OUTPUT
% ./a.out
log( 42.000000 ) = 5.392317
%
You can also create a helper function which converts to any log base you wish:
Something like this:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double
my_log(double x, int base) {
return log(x) / log(base);
}
int
main(void) {
double x = 42.0;
printf("log(%f) = %f\n", x, my_log(x, 2));
return 0;
}
Compiled with:
gcc -Wall -o logprog logprog.c -lm
Output:
log(42.000000) = 5.392317