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

[pre-commit.ci] pre-commit autoupdate #64

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
10 changes: 5 additions & 5 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: "v5.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -15,7 +15,7 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
exclude: "BIBLIOGRAPHY.bib|CONTRIBUTORS.rst|.*.ipynb"
Expand All @@ -29,17 +29,17 @@ repos:
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.8.4"
hooks:
- id: ruff-format
- id: ruff
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
rev: 1.19.1
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
476 changes: 246 additions & 230 deletions colour_checker_detection/examples/examples_detection_inference.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"\n",
"from colour_checker_detection import (\n",
" ROOT_RESOURCES_EXAMPLES,\n",
" detect_colour_checkers_segmentation)\n",
" detect_colour_checkers_segmentation,\n",
")\n",
"\n",
"colour.plotting.colour_style()\n",
"\n",
Expand Down Expand Up @@ -114,15 +115,16 @@
],
"source": [
"COLOUR_CHECKER_IMAGE_PATHS = glob.glob(\n",
" os.path.join(ROOT_RESOURCES_EXAMPLES, 'detection', '*19*.png'))\n",
" os.path.join(ROOT_RESOURCES_EXAMPLES, \"detection\", \"*19*.png\")\n",
")\n",
"\n",
"COLOUR_CHECKER_IMAGES = [\n",
" colour.cctf_decoding(colour.io.read_image(path))\n",
" for path in COLOUR_CHECKER_IMAGE_PATHS\n",
"]\n",
"\n",
"for image in COLOUR_CHECKER_IMAGES:\n",
" colour.plotting.plot_image(colour.cctf_encoding(image));"
" colour.plotting.plot_image(colour.cctf_encoding(image))"
]
},
{
Expand Down Expand Up @@ -166,20 +168,19 @@
"SWATCHES = []\n",
"for image in COLOUR_CHECKER_IMAGES:\n",
" for colour_checker_data in detect_colour_checkers_segmentation(\n",
" image, additional_data=True):\n",
" \n",
" swatch_colours, swatch_masks, colour_checker_image = (\n",
" colour_checker_data.values)\n",
" image, additional_data=True\n",
" ):\n",
" swatch_colours, swatch_masks, colour_checker_image = colour_checker_data.values\n",
" SWATCHES.append(swatch_colours)\n",
" \n",
"\n",
" # Using the additional data to plot the colour checker and masks.\n",
" masks_i = np.zeros(colour_checker_image.shape)\n",
" for i, mask in enumerate(swatch_masks):\n",
" masks_i[mask[0]:mask[1], mask[2]:mask[3], ...] = 1\n",
" \n",
" masks_i[mask[0] : mask[1], mask[2] : mask[3], ...] = 1\n",
"\n",
" colour.plotting.plot_image(\n",
" colour.cctf_encoding(\n",
" np.clip(colour_checker_image + masks_i * 0.25, 0, 1)));"
" colour.cctf_encoding(np.clip(colour_checker_image + masks_i * 0.25, 0, 1))\n",
" )"
]
},
{
Expand Down Expand Up @@ -260,9 +261,10 @@
}
],
"source": [
"D65 = colour.CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']\n",
"D65 = colour.CCS_ILLUMINANTS[\"CIE 1931 2 Degree Standard Observer\"][\"D65\"]\n",
"REFERENCE_COLOUR_CHECKER = colour.CCS_COLOURCHECKERS[\n",
" 'ColorChecker24 - After November 2014']\n",
" \"ColorChecker24 - After November 2014\"\n",
"]\n",
"\n",
"colour_checker_rows = REFERENCE_COLOUR_CHECKER.rows\n",
"colour_checker_columns = REFERENCE_COLOUR_CHECKER.columns\n",
Expand All @@ -272,35 +274,47 @@
"# See https://github.com/colour-science/colour-checker-detection/discussions/59\n",
"# for more information.\n",
"REFERENCE_SWATCHES = colour.XYZ_to_RGB(\n",
" colour.xyY_to_XYZ(list(REFERENCE_COLOUR_CHECKER.data.values())),\n",
" 'sRGB', REFERENCE_COLOUR_CHECKER.illuminant)\n",
" colour.xyY_to_XYZ(list(REFERENCE_COLOUR_CHECKER.data.values())),\n",
" \"sRGB\",\n",
" REFERENCE_COLOUR_CHECKER.illuminant,\n",
")\n",
"\n",
"for i, swatches in enumerate(SWATCHES):\n",
" swatches_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(\n",
" swatches, 'sRGB', D65))\n",
" swatches_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(swatches, \"sRGB\", D65))\n",
"\n",
" colour_checker = colour.characterisation.ColourChecker(\n",
" os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i]),\n",
" dict(zip(REFERENCE_COLOUR_CHECKER.data.keys(), swatches_xyY)),\n",
" D65, colour_checker_rows, colour_checker_columns)\n",
" \n",
" D65,\n",
" colour_checker_rows,\n",
" colour_checker_columns,\n",
" )\n",
"\n",
" colour.plotting.plot_multi_colour_checkers(\n",
" [REFERENCE_COLOUR_CHECKER, colour_checker])\n",
" \n",
" [REFERENCE_COLOUR_CHECKER, colour_checker]\n",
" )\n",
"\n",
" swatches_f = colour.colour_correction(swatches, swatches, REFERENCE_SWATCHES)\n",
" swatches_f_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(\n",
" swatches_f, 'sRGB', D65))\n",
" swatches_f_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(swatches_f, \"sRGB\", D65))\n",
" colour_checker = colour.characterisation.ColourChecker(\n",
" '{0} - CC'.format(os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i])),\n",
" \"{0} - CC\".format(os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i])),\n",
" dict(zip(REFERENCE_COLOUR_CHECKER.data.keys(), swatches_f_xyY)),\n",
" D65, colour_checker_rows, colour_checker_columns)\n",
" \n",
" D65,\n",
" colour_checker_rows,\n",
" colour_checker_columns,\n",
" )\n",
"\n",
" colour.plotting.plot_multi_colour_checkers(\n",
" [REFERENCE_COLOUR_CHECKER, colour_checker])\n",
" [REFERENCE_COLOUR_CHECKER, colour_checker]\n",
" )\n",
"\n",
" colour.plotting.plot_image(colour.cctf_encoding(\n",
" colour.colour_correction(\n",
" COLOUR_CHECKER_IMAGES[i], swatches, REFERENCE_SWATCHES)));"
" colour.plotting.plot_image(\n",
" colour.cctf_encoding(\n",
" colour.colour_correction(\n",
" COLOUR_CHECKER_IMAGES[i], swatches, REFERENCE_SWATCHES\n",
" )\n",
" )\n",
" )"
]
},
{
Expand Down Expand Up @@ -414,8 +428,7 @@
],
"source": [
"for image in COLOUR_CHECKER_IMAGES:\n",
" for colour_checker_data in detect_colour_checkers_segmentation(\n",
" image, show=True):\n",
" for colour_checker_data in detect_colour_checkers_segmentation(image, show=True):\n",
" pass"
]
},
Expand Down
Loading