Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
rev: "v6.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -15,33 +15,33 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.4.1
hooks:
- id: codespell
args:
["--ignore-words-list=communicatie,co-ordinates,hart,ist,manuel,te"]
exclude: "BIBLIOGRAPHY.bib|CONTRIBUTORS.rst|.*.ipynb"
- repo: https://github.com/ikamensh/flynt
rev: "1.0.1"
rev: "1.0.6"
hooks:
- id: flynt
args: [--verbose]
- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
rev: "6.0.1"
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.6"
rev: "v0.12.12"
hooks:
- id: ruff-format
- id: ruff
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
rev: 1.20.0
hooks:
- id: blacken-docs
language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pygrep-hooks
Expand Down
7 changes: 4 additions & 3 deletions files/experiments/induction/chromatic_induction_001.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

body {
background: black;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-family:
"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
height: 100%;
overflow: hidden;
Expand Down Expand Up @@ -88,10 +89,10 @@
CANVAS = Snap(WIDTH, HEIGHT);

BLACK_LINES = [];
(BLACK_LINES_DX = 0),
((BLACK_LINES_DX = 0),
(BLACK_LINES_DY = 0),
(LAST_DX = 0),
(LAST_DY = 0);
(LAST_DY = 0));

function linspace(a, b, n) {
if (typeof n === "undefined") {
Expand Down
6 changes: 3 additions & 3 deletions pages/colour-science-for-python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}
],
"source": [
"sd = colour.SDS_ILLUMINANTS.get('FL2')\n",
"sd = colour.SDS_ILLUMINANTS.get(\"FL2\")\n",
"colour.colour_fidelity_index(sd)"
]
},
Expand Down Expand Up @@ -68,8 +68,8 @@
}
],
"source": [
"il = colour.CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50']\n",
"colour.xy_to_CCT(il, method='Hernandez 1999')"
"il = colour.CCS_ILLUMINANTS[\"CIE 1931 2 Degree Standard Observer\"][\"D50\"]\n",
"colour.xy_to_CCT(il, method=\"Hernandez 1999\")"
]
},
{
Expand Down
96 changes: 44 additions & 52 deletions posts/a-plea-for-colour-analysis-tools-in-dcc-applications.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,28 @@
" image = ImageInput.open(path)\n",
" specification = image.spec()\n",
"\n",
" return np.array(image.read_image(FLOAT)).reshape((specification.height,\n",
" specification.width,\n",
" specification.nchannels))\n",
" return np.array(image.read_image(FLOAT)).reshape(\n",
" (specification.height, specification.width, specification.nchannels)\n",
" )\n",
"\n",
"\n",
"def image_plot(image,\n",
" OECF=colour.sRGB_COLOURSPACE.OECF):\n",
"def image_plot(image, OECF=colour.sRGB_COLOURSPACE.OECF):\n",
" vectorised_oecf = np.vectorize(OECF)\n",
" image = np.clip(vectorised_oecf(image), 0, 1)\n",
" pylab.imshow(image)\n",
"\n",
" settings = {'no_ticks': True,\n",
" 'bounding_box': [0, 1, 0, 1],\n",
" 'bbox_inches': 'tight',\n",
" 'pad_inches': 0}\n",
" settings = {\n",
" \"no_ticks\": True,\n",
" \"bounding_box\": [0, 1, 0, 1],\n",
" \"bbox_inches\": \"tight\",\n",
" \"pad_inches\": 0,\n",
" }\n",
"\n",
" aspect(**settings)\n",
" display(**settings)\n",
"\n",
"\n",
"ACES_image = exr_image_as_array('resources/images/SonyF35.StillLife_medium.exr')\n",
"ACES_image = exr_image_as_array(\"resources/images/SonyF35.StillLife_medium.exr\")\n",
"image_plot(ACES_image)"
]
},
Expand Down Expand Up @@ -152,10 +153,10 @@
"\n",
"message_box('Computing \"ACES RGB\" colourspace to \"sRGB\" colourspace matrix.')\n",
"\n",
"cat = colour.chromatic_adaptation_matrix(colour.xy_to_XYZ(ACES_w),\n",
" colour.xy_to_XYZ(sRGB_w))\n",
"ACES_RGB_to_sRGB_matrix = np.dot(sRGB_XYZ_to_RGB,\n",
" np.dot(cat, ACES_RGB_to_XYZ))\n",
"cat = colour.chromatic_adaptation_matrix(\n",
" colour.xy_to_XYZ(ACES_w), colour.xy_to_XYZ(sRGB_w)\n",
")\n",
"ACES_RGB_to_sRGB_matrix = np.dot(sRGB_XYZ_to_RGB, np.dot(cat, ACES_RGB_to_XYZ))\n",
"\n",
"print(ACES_RGB_to_sRGB_matrix)"
]
Expand Down Expand Up @@ -187,7 +188,9 @@
],
"source": [
"ACES_image_shape = ACES_image.shape\n",
"sRGB_image = np.array([np.dot(ACES_RGB_to_sRGB_matrix, RGB) for RGB in ACES_image.reshape((-1, 3))])\n",
"sRGB_image = np.array(\n",
" [np.dot(ACES_RGB_to_sRGB_matrix, RGB) for RGB in ACES_image.reshape((-1, 3))]\n",
")\n",
"sRGB_image = sRGB_image.reshape(ACES_image_shape)\n",
"image_plot(sRGB_image)"
]
Expand Down Expand Up @@ -240,23 +243,18 @@
"\n",
"\n",
"def ACES_to_xy(RGB):\n",
" return colour.XYZ_to_xy(\n",
" colour.RGB_to_XYZ(RGB,\n",
" ACES_w,\n",
" ACES_w,\n",
" ACES_RGB_to_XYZ))\n",
" return colour.XYZ_to_xy(colour.RGB_to_XYZ(RGB, ACES_w, ACES_w, ACES_RGB_to_XYZ))\n",
"\n",
"\n",
"def image_chromaticities_plot(image, to_xy=ACES_to_xy):\n",
" colourspaces_CIE_1931_chromaticity_diagram_plot(\n",
" ['Pointer Gamut', 'sRGB', 'Rec. 2020', 'ACES RGB'],\n",
" standalone=False)\n",
" [\"Pointer Gamut\", \"sRGB\", \"Rec. 2020\", \"ACES RGB\"], standalone=False\n",
" )\n",
"\n",
" alpha_p, colour_p = 0.85, 'black'\n",
" alpha_p, colour_p = 0.85, \"black\"\n",
"\n",
" xy = np.array([to_xy(RGB) for RGB in image.reshape((-1, 3))])\n",
" pylab.scatter(xy[:, 0], xy[:, 1], alpha=alpha_p / 2, color=colour_p,\n",
" marker='+')\n",
" pylab.scatter(xy[:, 0], xy[:, 1], alpha=alpha_p / 2, color=colour_p, marker=\"+\")\n",
"\n",
" display(standalone=True)\n",
"\n",
Expand Down Expand Up @@ -296,14 +294,12 @@
"def sRGB_to_xy(RGB):\n",
" RGB_key = tuple(RGB)\n",
" if not RGB_key in sRGB_CHROMATICITIES_CACHE:\n",
" sRGB_CHROMATICITIES_CACHE[RGB_key] = (\n",
" colour.XYZ_to_xy(\n",
" colour.RGB_to_XYZ(RGB,\n",
" sRGB_w,\n",
" sRGB_w,\n",
" sRGB_RGB_to_XYZ)))\n",
" sRGB_CHROMATICITIES_CACHE[RGB_key] = colour.XYZ_to_xy(\n",
" colour.RGB_to_XYZ(RGB, sRGB_w, sRGB_w, sRGB_RGB_to_XYZ)\n",
" )\n",
" return sRGB_CHROMATICITIES_CACHE[RGB_key]\n",
"\n",
"\n",
"image_chromaticities_plot(sRGB_image, sRGB_to_xy)"
]
},
Expand Down Expand Up @@ -363,9 +359,8 @@
" triangulation = Delaunay(points)\n",
" image_illegal = np.copy(image).reshape((-1, 3))\n",
" legal_colours_mask = np.array(\n",
" [within_boundaries(to_xy(RGB), triangulation)\n",
" for RGB in\n",
" image_illegal])\n",
" [within_boundaries(to_xy(RGB), triangulation) for RGB in image_illegal]\n",
" )\n",
" image_illegal[legal_colours_mask] = 0\n",
" return image_illegal.reshape(image.shape)\n",
"\n",
Expand Down Expand Up @@ -414,30 +409,25 @@
"\n",
"# Computing *sRGB* to *Rec. 2020* colourspace transformation matrix.\n",
"cat = colour.chromatic_adaptation_matrix(\n",
" colour.xy_to_XYZ(sRGB_w),\n",
" colour.xy_to_XYZ(Rec_2020_w))\n",
"Rec_2020_to_sRGB_matrix = (\n",
" np.dot(Rec_2020_XYZ_to_RGB,\n",
" np.dot(cat, sRGB_RGB_to_XYZ)))\n",
" colour.xy_to_XYZ(sRGB_w), colour.xy_to_XYZ(Rec_2020_w)\n",
")\n",
"Rec_2020_to_sRGB_matrix = np.dot(Rec_2020_XYZ_to_RGB, np.dot(cat, sRGB_RGB_to_XYZ))\n",
"\n",
"\n",
"def Rec_2020_to_xy(RGB):\n",
" return colour.XYZ_to_xy(\n",
" colour.RGB_to_XYZ(RGB,\n",
" Rec_2020_w,\n",
" Rec_2020_w,\n",
" Rec_2020_RGB_to_XYZ))\n",
" colour.RGB_to_XYZ(RGB, Rec_2020_w, Rec_2020_w, Rec_2020_RGB_to_XYZ)\n",
" )\n",
"\n",
"\n",
"Rec_2020_image = np.array([np.dot(Rec_2020_to_sRGB_matrix, RGB)\n",
" for RGB in\n",
" sRGB_image.reshape((-1, 3))])\n",
"Rec_2020_image = np.array(\n",
" [np.dot(Rec_2020_to_sRGB_matrix, RGB) for RGB in sRGB_image.reshape((-1, 3))]\n",
")\n",
"Rec_2020_image = Rec_2020_image.reshape(ACES_image_shape)\n",
"\n",
"Rec_2020_image_illegal = (\n",
" mask_legal_colours(np.copy(Rec_2020_image), \n",
" Rec_2020_p, \n",
" Rec_2020_to_xy))\n",
"Rec_2020_image_illegal = mask_legal_colours(\n",
" np.copy(Rec_2020_image), Rec_2020_p, Rec_2020_to_xy\n",
")\n",
"\n",
"# Scaling the data to make it more obvious.\n",
"Rec_2020_image_illegal *= 100\n",
Expand Down Expand Up @@ -477,7 +467,9 @@
}
],
"source": [
"pointer_gamut_illegal_image = mask_legal_colours(sRGB_image, colour.POINTER_GAMUT_BOUNDARIES)\n",
"pointer_gamut_illegal_image = mask_legal_colours(\n",
" sRGB_image, colour.POINTER_GAMUT_BOUNDARIES\n",
")\n",
"\n",
"# Scaling the data to make it more obvious.\n",
"pointer_gamut_illegal_image *= 100\n",
Expand Down Expand Up @@ -519,7 +511,7 @@
}
],
"source": [
"cmfs = colour.CMFS.get('CIE 1931 2 Degree Standard Observer')\n",
"cmfs = colour.CMFS.get(\"CIE 1931 2 Degree Standard Observer\")\n",
"spectral_locus_xy = np.array([colour.XYZ_to_xy(x) for x in cmfs.values])\n",
"\n",
"spectral_locus_illegal_image = mask_legal_colours(sRGB_image, spectral_locus_xy)\n",
Expand Down
Loading