Skip to content

Instantly share code, notes, and snippets.

View KelSolaar's full-sized avatar
🔅
Bending Light

Thomas Mansencal KelSolaar

🔅
Bending Light
View GitHub Profile
@KelSolaar
KelSolaar / fovCalculator.py
Created March 2, 2014 21:09
FOV Calculator
import math
diagonal = lambda w, h: math.sqrt(w ** 2 + h ** 2)
wr = 36. # Reference 24mm * 36mm sensor.
hr = 24.
dr = diagonal(wr, hr)
w = 7.6 # Current sensor: http://en.wikipedia.org/wiki/Image_sensor_format
h = 5.7
@KelSolaar
KelSolaar / ansiColors.py
Last active August 29, 2015 13:57
ANSI Colors
BACKGROUND_CODES = (("bBlack", "40m"),
("bRed", "41m"),
("bGreen", "42m"),
("bYellow", "43m"),
("bBlue", "44m"),
("bPurple", "45m"),
("bCyan", "46m"),
("bWhite", "47m"),
("bHighBlack", "100m"),
("bHighRed", "101m"),
@KelSolaar
KelSolaar / for_JetBrains.py
Last active August 29, 2015 14:05
Stuff to discuss with JetBrains
# PyCharm will complain the the parameters are missing in docstrings with
# Numpy style docstrings.
def XYZ_to_CIECAM02(XYZ,
XYZw,
LA,
Yb,
surround=CIECAM02_VIEWING_CONDITIONS.get(
'Average'),
discount_illuminant=False):
"""
@KelSolaar
KelSolaar / cie_xyz.py
Created September 10, 2014 05:46
ColorChecker 2005 - Illuminants - CIE XYZ
{'dark skin': np.array([0.07049534, 0.1008, 0.09558313]),
'light skin': np.array([0.4709771, 0.3495, 0.11301649]),
'blue sky': np.array([0.37187544, 0.1836, 0.05327788]),
'foliage': np.array([0.07439008, 0.1325, 0.08761981]),
'blue flower': np.array([0.55702667, 0.2304, 0.01929602]),
'bluish green': np.array([0.72072938, 0.4178, -0.0702604]),
'orange': np.array([0.14092656, 0.3118, 0.31620069]),
'purplish blue': np.array([0.3568546, 0.1126, 0.06520827]),
'moderate red': np.array([0.22536132, 0.1938, 0.172956]),
'purple': np.array([0.10628412, 0.0637, 0.08666374]),
@KelSolaar
KelSolaar / corresponding_chromaticities_prediction.py
Created September 15, 2014 08:39
Colour - Corresponding Chromaticities Prediction
from pprint import pprint
pr = corresponding_chromaticities_prediction_vonkries(2, 'Bradford')
pr = [(p.uvp_m, p.uvp_p) for p in pr]
pprint(pr) # doctest: +ELLIPSIS
[((0.20..., 0.48...), (0.2082014..., 0.4722922...)),
((0.44..., 0.51...), (0.4489102..., 0.5071602...)),
((0.26..., 0.50...), (0.2643545..., 0.4959631...)),
((0.32..., 0.54...), (0.3348730..., 0.5471220...)),
((0.31..., 0.53...), (0.3248758..., 0.5390589...)),
((0.26..., 0.55...), (0.2733105..., 0.5555028...)),
@KelSolaar
KelSolaar / about_rendering_engines_colourspaces_agnosticism.py
Last active August 29, 2015 14:06
3D-PRO - About Rendering Engines Colourspaces Agnosticism
import numpy as np
import colour
from colour.utilities.verbose import message_box
name, data, illuminant = colour.COLOURCHECKERS['ColorChecker 2005']
sRGB_w = colour.sRGB_COLOURSPACE.whitepoint
sRGB_XYZ_to_RGB = colour.sRGB_COLOURSPACE.to_RGB
sRGB_RGB_to_XYZ = colour.sRGB_COLOURSPACE.to_XYZ
adobe98_w = colour.ADOBE_RGB_1998_COLOURSPACE.whitepoint
@KelSolaar
KelSolaar / cqs_tests.ipynb
Created September 22, 2014 15:03
colour - CQS Tests
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KelSolaar
KelSolaar / oecf_check.py
Created September 25, 2014 08:17
Colour - OECF - Check
import numpy as np
import colour
for c in sorted(colour.RGB_COLOURSPACES.values()):
samples = np.linspace(0, 1, 1000)
samples_tf = [c.transfer_function(sample) for sample in samples]
samples_itf = [c.inverse_transfer_function(sample) for sample in samples_tf]
try:
np.testing.assert_almost_equal(samples, samples_itf, decimal=4)
except:
@KelSolaar
KelSolaar / temperature_ramblings.ipynb
Created September 30, 2014 20:49
Colour Temperature Ramblings
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KelSolaar
KelSolaar / Sony_F35_IDT_ramblings.nkp
Last active August 29, 2015 14:07
Sony F35 IDT Ramblings
set cut_paste_input [stack 0]
version 8.0 v1
Read {
inputs 0
file /Users/kelsolaar/Downloads/SonyF35.StillLife.dpx
format "1920 1080 0 0 1920 1080 1 HD"
origset true
colorspace linear
raw true
timecode 02:14:20:19