Skip to content

Commit 7269e8d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent cda603e commit 7269e8d

File tree

2 files changed

+292
-263
lines changed

2 files changed

+292
-263
lines changed

colour_checker_detection/examples/examples_detection_inference.ipynb

+246-230
Large diffs are not rendered by default.

colour_checker_detection/examples/examples_detection_segmentation.ipynb

+46-33
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
"\n",
6161
"from colour_checker_detection import (\n",
6262
" ROOT_RESOURCES_EXAMPLES,\n",
63-
" detect_colour_checkers_segmentation)\n",
63+
" detect_colour_checkers_segmentation,\n",
64+
")\n",
6465
"\n",
6566
"colour.plotting.colour_style()\n",
6667
"\n",
@@ -114,15 +115,16 @@
114115
],
115116
"source": [
116117
"COLOUR_CHECKER_IMAGE_PATHS = glob.glob(\n",
117-
" os.path.join(ROOT_RESOURCES_EXAMPLES, 'detection', '*19*.png'))\n",
118+
" os.path.join(ROOT_RESOURCES_EXAMPLES, \"detection\", \"*19*.png\")\n",
119+
")\n",
118120
"\n",
119121
"COLOUR_CHECKER_IMAGES = [\n",
120122
" colour.cctf_decoding(colour.io.read_image(path))\n",
121123
" for path in COLOUR_CHECKER_IMAGE_PATHS\n",
122124
"]\n",
123125
"\n",
124126
"for image in COLOUR_CHECKER_IMAGES:\n",
125-
" colour.plotting.plot_image(colour.cctf_encoding(image));"
127+
" colour.plotting.plot_image(colour.cctf_encoding(image))"
126128
]
127129
},
128130
{
@@ -166,20 +168,19 @@
166168
"SWATCHES = []\n",
167169
"for image in COLOUR_CHECKER_IMAGES:\n",
168170
" for colour_checker_data in detect_colour_checkers_segmentation(\n",
169-
" image, additional_data=True):\n",
170-
" \n",
171-
" swatch_colours, swatch_masks, colour_checker_image = (\n",
172-
" colour_checker_data.values)\n",
171+
" image, additional_data=True\n",
172+
" ):\n",
173+
" swatch_colours, swatch_masks, colour_checker_image = colour_checker_data.values\n",
173174
" SWATCHES.append(swatch_colours)\n",
174-
" \n",
175+
"\n",
175176
" # Using the additional data to plot the colour checker and masks.\n",
176177
" masks_i = np.zeros(colour_checker_image.shape)\n",
177178
" for i, mask in enumerate(swatch_masks):\n",
178-
" masks_i[mask[0]:mask[1], mask[2]:mask[3], ...] = 1\n",
179-
" \n",
179+
" masks_i[mask[0] : mask[1], mask[2] : mask[3], ...] = 1\n",
180+
"\n",
180181
" colour.plotting.plot_image(\n",
181-
" colour.cctf_encoding(\n",
182-
" np.clip(colour_checker_image + masks_i * 0.25, 0, 1)));"
182+
" colour.cctf_encoding(np.clip(colour_checker_image + masks_i * 0.25, 0, 1))\n",
183+
" )"
183184
]
184185
},
185186
{
@@ -260,9 +261,10 @@
260261
}
261262
],
262263
"source": [
263-
"D65 = colour.CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']\n",
264+
"D65 = colour.CCS_ILLUMINANTS[\"CIE 1931 2 Degree Standard Observer\"][\"D65\"]\n",
264265
"REFERENCE_COLOUR_CHECKER = colour.CCS_COLOURCHECKERS[\n",
265-
" 'ColorChecker24 - After November 2014']\n",
266+
" \"ColorChecker24 - After November 2014\"\n",
267+
"]\n",
266268
"\n",
267269
"colour_checker_rows = REFERENCE_COLOUR_CHECKER.rows\n",
268270
"colour_checker_columns = REFERENCE_COLOUR_CHECKER.columns\n",
@@ -272,35 +274,47 @@
272274
"# See https://github.com/colour-science/colour-checker-detection/discussions/59\n",
273275
"# for more information.\n",
274276
"REFERENCE_SWATCHES = colour.XYZ_to_RGB(\n",
275-
" colour.xyY_to_XYZ(list(REFERENCE_COLOUR_CHECKER.data.values())),\n",
276-
" 'sRGB', REFERENCE_COLOUR_CHECKER.illuminant)\n",
277+
" colour.xyY_to_XYZ(list(REFERENCE_COLOUR_CHECKER.data.values())),\n",
278+
" \"sRGB\",\n",
279+
" REFERENCE_COLOUR_CHECKER.illuminant,\n",
280+
")\n",
277281
"\n",
278282
"for i, swatches in enumerate(SWATCHES):\n",
279-
" swatches_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(\n",
280-
" swatches, 'sRGB', D65))\n",
283+
" swatches_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(swatches, \"sRGB\", D65))\n",
281284
"\n",
282285
" colour_checker = colour.characterisation.ColourChecker(\n",
283286
" os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i]),\n",
284287
" dict(zip(REFERENCE_COLOUR_CHECKER.data.keys(), swatches_xyY)),\n",
285-
" D65, colour_checker_rows, colour_checker_columns)\n",
286-
" \n",
288+
" D65,\n",
289+
" colour_checker_rows,\n",
290+
" colour_checker_columns,\n",
291+
" )\n",
292+
"\n",
287293
" colour.plotting.plot_multi_colour_checkers(\n",
288-
" [REFERENCE_COLOUR_CHECKER, colour_checker])\n",
289-
" \n",
294+
" [REFERENCE_COLOUR_CHECKER, colour_checker]\n",
295+
" )\n",
296+
"\n",
290297
" swatches_f = colour.colour_correction(swatches, swatches, REFERENCE_SWATCHES)\n",
291-
" swatches_f_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(\n",
292-
" swatches_f, 'sRGB', D65))\n",
298+
" swatches_f_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(swatches_f, \"sRGB\", D65))\n",
293299
" colour_checker = colour.characterisation.ColourChecker(\n",
294-
" '{0} - CC'.format(os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i])),\n",
300+
" \"{0} - CC\".format(os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i])),\n",
295301
" dict(zip(REFERENCE_COLOUR_CHECKER.data.keys(), swatches_f_xyY)),\n",
296-
" D65, colour_checker_rows, colour_checker_columns)\n",
297-
" \n",
302+
" D65,\n",
303+
" colour_checker_rows,\n",
304+
" colour_checker_columns,\n",
305+
" )\n",
306+
"\n",
298307
" colour.plotting.plot_multi_colour_checkers(\n",
299-
" [REFERENCE_COLOUR_CHECKER, colour_checker])\n",
308+
" [REFERENCE_COLOUR_CHECKER, colour_checker]\n",
309+
" )\n",
300310
"\n",
301-
" colour.plotting.plot_image(colour.cctf_encoding(\n",
302-
" colour.colour_correction(\n",
303-
" COLOUR_CHECKER_IMAGES[i], swatches, REFERENCE_SWATCHES)));"
311+
" colour.plotting.plot_image(\n",
312+
" colour.cctf_encoding(\n",
313+
" colour.colour_correction(\n",
314+
" COLOUR_CHECKER_IMAGES[i], swatches, REFERENCE_SWATCHES\n",
315+
" )\n",
316+
" )\n",
317+
" )"
304318
]
305319
},
306320
{
@@ -414,8 +428,7 @@
414428
],
415429
"source": [
416430
"for image in COLOUR_CHECKER_IMAGES:\n",
417-
" for colour_checker_data in detect_colour_checkers_segmentation(\n",
418-
" image, show=True):\n",
431+
" for colour_checker_data in detect_colour_checkers_segmentation(image, show=True):\n",
419432
" pass"
420433
]
421434
},

0 commit comments

Comments
 (0)