# ColorCorrectionML
ColorCorrectionML is a Python package for color correction of images using machine learning. It uses ML regression methods (linear, least sqaure, and partial least squares regression) to learn the color correction function from a training image with a color checker. The learned function is then applied to correct the color of a test image.
## Installation
```shell
pip install colorcorrectionML
```
## Usage
```python
from ColorCorrectionML import ColorCorrectionML
import cv2
img = cv2.imread('Images/img2.png')
cc = ColorCorrectionML(img, chart='Classic', illuminant='D50')
method = 'pls' # 'linear', 'lstsq', 'pls'
# for linear regression, least square regression, and partial least square regression respectively
show = True
kwargs = {
'method': method,
'degree': 3, # degree of polynomial
'interactions_only': False, # only interactions terms,
'ncomp': 10, # number of components for PLS only
'max_iter': 5000, # max iterations for PLS only
'white_balance_mtd': 0 # 0: no white balance, 1: learningBasedWB, 2: simpleWB, 3: grayWorldWB,
}
M, patch_size = cc.compute_correction(
show=show,
**kwargs
)
# resize img by 2
# img = cv2.resize(img, (0,0), fx=0.3, fy=0.3, interpolation=cv2.INTER_AREA)
img_corr = cc.correct_img(img, show=True)
# img_corr = cc.Parallel_correct_img(img, chunks_=50000, show=True)
```
## Example results
Scatter plot of the original image and the corrected image color values

Color correction results

## TODO
1. Add other reference color values (D55, D65, D70, D75)
2. Add other color charts (ColorChecker24, ColorCheckerSG, ColorCheckerDC)
3. Add other color spaces (CIELab, XYZ, etc.)
4. Add other regression methods (Ridge, Lasso, ElasticNet, etc.)
5. Refine the white balance methods
Raw data
{
"_id": null,
"home_page": "https://github.com/collinswakholi/ML_ColorCorrection_tool",
"name": "colorcorrectionML",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Collins Wakholi",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/3c/64/21b299ab50da533c204f2bb4f8cad181d890cb92f03733907815f896effc/colorcorrectionML-0.0.2.1.tar.gz",
"platform": null,
"description": "# ColorCorrectionML\n\nColorCorrectionML is a Python package for color correction of images using machine learning. It uses ML regression methods (linear, least sqaure, and partial least squares regression) to learn the color correction function from a training image with a color checker. The learned function is then applied to correct the color of a test image.\n\n## Installation\n```shell\npip install colorcorrectionML\n```\n\n## Usage\n```python\nfrom ColorCorrectionML import ColorCorrectionML\nimport cv2\n\nimg = cv2.imread('Images/img2.png')\n\ncc = ColorCorrectionML(img, chart='Classic', illuminant='D50')\n\nmethod = 'pls' # 'linear', 'lstsq', 'pls' \n# for linear regression, least square regression, and partial least square regression respectively\nshow = True\n\nkwargs = {\n 'method': method,\n 'degree': 3, # degree of polynomial\n 'interactions_only': False, # only interactions terms,\n 'ncomp': 10, # number of components for PLS only\n 'max_iter': 5000, # max iterations for PLS only\n 'white_balance_mtd': 0 # 0: no white balance, 1: learningBasedWB, 2: simpleWB, 3: grayWorldWB,\n }\n\nM, patch_size = cc.compute_correction(\n show=show,\n **kwargs\n)\n \n\n# resize img by 2\n# img = cv2.resize(img, (0,0), fx=0.3, fy=0.3, interpolation=cv2.INTER_AREA)\n\nimg_corr = cc.correct_img(img, show=True)\n# img_corr = cc.Parallel_correct_img(img, chunks_=50000, show=True)\n```\n\n## Example results\nScatter plot of the original image and the corrected image color values\n\n\nColor correction results\n\n\n\n## TODO\n1. Add other reference color values (D55, D65, D70, D75)\n2. Add other color charts (ColorChecker24, ColorCheckerSG, ColorCheckerDC)\n3. Add other color spaces (CIELab, XYZ, etc.)\n4. Add other regression methods (Ridge, Lasso, ElasticNet, etc.)\n5. Refine the white balance methods\n",
"bugtrack_url": null,
"license": "",
"summary": "Do color correction of images using machine learning.",
"version": "0.0.2.1",
"project_urls": {
"Homepage": "https://github.com/collinswakholi/ML_ColorCorrection_tool"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3904048a6d3e3d2cc26df26e5810b5b7f0859b33bfe673da0b508b6188bd9a1e",
"md5": "81c3de9ef5db38da737e4b7bb0185d1a",
"sha256": "3ed17dc786c8dc11f66da728063a7d13495ce79d861cd6e792031a0f1e50bcc4"
},
"downloads": -1,
"filename": "colorcorrectionML-0.0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "81c3de9ef5db38da737e4b7bb0185d1a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7444,
"upload_time": "2023-09-20T19:35:27",
"upload_time_iso_8601": "2023-09-20T19:35:27.554259Z",
"url": "https://files.pythonhosted.org/packages/39/04/048a6d3e3d2cc26df26e5810b5b7f0859b33bfe673da0b508b6188bd9a1e/colorcorrectionML-0.0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3c6421b299ab50da533c204f2bb4f8cad181d890cb92f03733907815f896effc",
"md5": "b63f2b631811638533f85d9c856e0837",
"sha256": "576a91a84e605bc9ed16fef8ab889a7b8ce970dd346db3f263684d67b3316e1b"
},
"downloads": -1,
"filename": "colorcorrectionML-0.0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "b63f2b631811638533f85d9c856e0837",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6638,
"upload_time": "2023-09-20T19:35:29",
"upload_time_iso_8601": "2023-09-20T19:35:29.061616Z",
"url": "https://files.pythonhosted.org/packages/3c/64/21b299ab50da533c204f2bb4f8cad181d890cb92f03733907815f896effc/colorcorrectionML-0.0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-20 19:35:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "collinswakholi",
"github_project": "ML_ColorCorrection_tool",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "colorcorrectionml"
}