Skip to main content

help to do color correction on images based on color checker card classic 24 patch.

Project description

Color Correction Logo

Color Correction


version downloads python-version Try color-correction using - Google Colab read - docs

Package formerly published as color-correction-asdfghjkl on PyPI. The name has been simplified for better accessibility and professional recognition.

This package is designed to perform color correction on images using the Color Checker Classic 24 Patch card. It provides a robust solution for ensuring accurate color representation in your images.

📦 Installation

pip install color-correction

🏋️‍♀️ How it works

How it works

⚡ How to use

from color_correction import ColorCorrection

# Step 1: Define the path to the input image
image_path = "asset/images/cc-19.png"

# Step 2: Load the input image
input_image = cv2.imread(image_path)

# Step 3: Initialize the color correction model with specified parameters
color_corrector = ColorCorrection(
    detection_model="yolov8",
    detection_conf_th=0.25,
    correction_model="polynomial", # "least_squares", "affine_reg", "linear_reg"
    degree=3,  # for polynomial correction model
    use_gpu=True,
)

# Step 4: Extract color patches from the input image
# you can set reference patches from another image (image has color checker card)
# or use the default D50
# color_corrector.set_reference_patches(image=None, debug=True)
color_corrector.set_input_patches(image=input_image, debug=True)
color_corrector.fit()
corrected_image = color_corrector.predict(
    input_image=input_image,
    debug=True,
    debug_output_dir="zzz",
)

# Step 5: Evaluate the color correction results
eval_result = color_corrector.calc_color_diff_patches()
print(eval_result)
Sample Evaluation Output
{
    "initial": {
        "min": 2.254003059526461,
        "max": 13.461066402633447,
        "mean": 8.3072755187654,
        "std": 3.123962754767539,
    },
    "corrected": {
        "min": 0.30910031798755183,
        "max": 5.422311999126372,
        "mean": 1.4965478752947827,
        "std": 1.2915738724958112,
    },
    "delta": {
        "min": 1.9449027415389093,
        "max": 8.038754403507074,
        "mean": 6.810727643470616,
        "std": 1.8323888822717276,
    },
}
Sample Output Debug Image

Sample Output

🔎 Reporting

import cv2

from color_correction import ColorCorrectionAnalyzer

# input_image_path = "assets/cc-19.png"
input_image_path = "assets/cc-1.jpg"

report = ColorCorrectionAnalyzer(
    list_correction_methods=[
        ("least_squares", {}),
        ("linear_reg", {}),
        ("affine_reg", {}),
        ("polynomial", {"degree": 2}),
        ("polynomial", {"degree": 3}),
        # ("polynomial", {"degree": 4}),
        # ("polynomial", {"degree": 5}),
    ],
    list_detection_methods=[
        ("yolov8", {"detection_conf_th": 0.25}),
    ],
)
report.run(
    input_image=cv2.imread(input_image_path),
    reference_image=None,
    output_dir="report-output",
)
Sample Report Output

Sample Benchmark Output

📈 Benefits

  • Consistency: Ensure uniform color correction across multiple images.
  • Accuracy: Leverage the color correction matrix for precise color adjustments.
  • Flexibility: Adaptable for various image sets with different color profiles.

🤸 TODO

  • Add Loggers
  • Add detection MCC:CCheckerDetector from opencv
  • Add Segmentation Color Checker using YOLOv11 ONNX
  • Improve validation preprocessing (e.g., auto-match-orientation CC)
  • Add more analysis and evaluation metrics (Still thinking...)

📚 References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

color_correction-0.0.1rc5.tar.gz (6.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

color_correction-0.0.1rc5-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

Details for the file color_correction-0.0.1rc5.tar.gz.

File metadata

  • Download URL: color_correction-0.0.1rc5.tar.gz
  • Upload date:
  • Size: 6.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for color_correction-0.0.1rc5.tar.gz
Algorithm Hash digest
SHA256 f9ef3fbc32db55a78448d57c2942545541b62fafbb1d06d09ab7bbfed181f350
MD5 27974f8ccacbff207933fc0e54abc2ea
BLAKE2b-256 589a0126c0003fa3003fa2ba08e84d108eda84bbc4f9b5ef8507def3e3d0893a

See more details on using hashes here.

File details

Details for the file color_correction-0.0.1rc5-py3-none-any.whl.

File metadata

File hashes

Hashes for color_correction-0.0.1rc5-py3-none-any.whl
Algorithm Hash digest
SHA256 cefdcb98fe49aad313cb435310e9bb4d86faef611d4ba2b0f7922742ff7edc09
MD5 78b432f848ac6c40996921a5377b419b
BLAKE2b-256 cac8c8400a869359af1f4233b24c8aaff280aab8f7b75fc8a447f3820ad437d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page