Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for "Blackmagic Design" colourspaces. #591

Open
nick-shaw opened this issue May 13, 2020 · 10 comments
Open

Implement support for "Blackmagic Design" colourspaces. #591

nick-shaw opened this issue May 13, 2020 · 10 comments
Assignees
Milestone

Comments

@nick-shaw
Copy link
Contributor

While the colour encodings of Blackmagic cameras are not published, the primaries of the various colour spaces can be displayed on the CIE plot 'scope in DaVinci Resolve.

The transfer functions are available only as 1D LUTs or hard coded internal transforms in Resolve. Can we create colourspaces which use LUTs, rather than functions? Would the LUT table need to be included in the colourspace file, or could it be a separate file?

@nick-shaw nick-shaw changed the title Implement support for Blackmagic Design colour spaces Implement support for Blackmagic Design colour spaces. May 13, 2020
@nick-shaw nick-shaw self-assigned this May 13, 2020
@nick-shaw
Copy link
Contributor Author

Would the correct approach be to add a datasets folder under transfer_functions and declare all the BMD transfer functions as arrays there?

@sobotka
Copy link
Contributor

sobotka commented May 13, 2020

I wonder if the generic log-like approach with breakpoint can be solved for?

@KelSolaar
Copy link
Member

Would the correct approach be to add a datasets folder under transfer_functions and declare all the BMD transfer functions as arrays there?

Sounds good yeah!

Can we create colourspaces which use LUTs, rather than functions?

Sure, the transfer functions are just callables, so any callable will work here!

I wonder if the generic log-like approach with breakpoint can be solved for?

If shown it matches really nicely why not!

@nick-shaw
Copy link
Contributor Author

Work in progress version of Blackmagic colour spaces at https://github.com/nick-shaw/colour/tree/feature/blackmagic

@KelSolaar
Copy link
Member

So here is something we could roll to lazily load the data: https://colab.research.google.com/drive/1RbAhKB8JM_X-LMkSSHY3OukcW1g0O_ni?usp=sharing

The first time you get the value for Luke, the function is evaluated and its output is stored in-place of the original callable. We could use that approach to have the CSV files loaded lazily that way.

@KelSolaar
Copy link
Member

@nick-shaw : I pushed the new colour.utilities.LazyCaseInsensitiveMapping class, so if you rebase, you should get access to it!

Usage should be simple, let me know if you have any issue!

@KelSolaar
Copy link
Member

Occurred to me while creating #648 and #649 that we never finished those!

@KelSolaar KelSolaar modified the milestones: v0.3.16, v0.4.0 Nov 23, 2020
@KelSolaar KelSolaar changed the title Implement support for Blackmagic Design colour spaces. Implement support for "Blackmagic Design" colourspaces. Feb 4, 2021
@KelSolaar KelSolaar modified the milestones: v0.4.0, v0.4.1, v0.4.2 Feb 19, 2022
@cessen
Copy link

cessen commented Apr 25, 2022

An email conversation I had with @sobotka led me here (thanks Troy!). It looks like I've been duplicating some effort. I recently published this:

https://psychopath.io/post/2022_04_23_blackmagic_design_color_spaces

Among other things, I derived very precise formulas for most of Blackmagic's log transfer functions. Just thought I'd let you guys know in case it's useful to you!

@KelSolaar
Copy link
Member

Hi Nathan,

We never rolled those because BMD released Gen 5 and we let the Gen 4 on the side. I reckon this would still be useful to have. Between @nick-shaw, @KevinJW and I, we have three notebooks to fit them using the CLF log functions.

Posting them for reference:

@nick-shaw : What do you reckon we should do?

@cessen
Copy link

cessen commented Apr 25, 2022

Ah, very cool!

It looks like we reported different error metrics. I used relative error, whereas it looks like all the notebooks use absolute difference.

For reference, here are the absolute differences of my fits:

4K Film:

  • Max Error: 0.000001458415273658531
  • Avg Error: 0.00000029467013536211367

4.6K Film Gen 3:

  • Max Error: 0.000009386312422421383
  • Avg Error: 0.0000008939538205329489

Broadcast Film Gen 4:

  • Max Error: 0.000003076915272348657
  • Avg Error: 0.00000041968105470180033

Film:

  • Max Error: 0.000003850075836808742
  • Avg Error: 0.0000004558235031730866

Pocket 4K Film Gen 4:

  • Max Error: 0.0004323775281269704
  • Avg Error: 0.00016814797417333187

Pocket 6K Film Gen 4:

  • Max Error: 0.0005152755684818544
  • Avg Error: 0.00018940072423018247

(Note that my fits for the Pocket Film functions are comparatively poor. See footnote 11 in my post for why. That doesn't change the fact that they are comparatively poor, of course.)

According to this metric, it looks like my fits aren't quite as good as those in the notebooks.

I am curious what the relative errors of the notebooks are, however, as IMO that's a better error metric for color transfer functions: small differences near zero are more important than small differences at larger magnitudes. I suspect your fits are still better than mine even by that metric, but it might be worth checking.

If needed, I'm also happy to convert my fits to the same equation form as the rest of you, for convenience. (Updated to a more standard natural log form in my post.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants