{"id":17594902,"url":"https://github.com/dstein64/colortrans","last_synced_at":"2025-10-08T13:32:44.594Z","repository":{"id":62563730,"uuid":"465520759","full_name":"dstein64/colortrans","owner":"dstein64","description":"An implementation of various color transfer algorithms.","archived":false,"fork":false,"pushed_at":"2024-03-17T00:14:06.000Z","size":41,"stargazers_count":17,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-23T03:26:54.941Z","etag":null,"topics":["color-transfer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dstein64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-03T01:03:30.000Z","updated_at":"2024-09-29T21:44:40.000Z","dependencies_parsed_at":"2024-03-17T02:28:28.705Z","dependency_job_id":null,"html_url":"https://github.com/dstein64/colortrans","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"9d6b9bb2ac354bad83bcdf55698297ed1b4662fa"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstein64%2Fcolortrans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstein64%2Fcolortrans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstein64%2Fcolortrans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstein64%2Fcolortrans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dstein64","download_url":"https://codeload.github.com/dstein64/colortrans/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221776158,"owners_count":16878490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color-transfer"],"created_at":"2024-10-22T07:20:35.133Z","updated_at":"2025-10-08T13:32:44.508Z","avatar_url":"https://github.com/dstein64.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build][badge_thumbnail]][badge_link]\n\n# colortrans\n\nAn implementation of various algorithms for transferring the colors from a reference image to a\ncontent image while preserving the qualitative appearance of the content image (i.e., color\ntransfer).\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/dstein64/media/blob/main/colortrans/content.jpg?raw=true\"\u003e\n    \u003cimg src=\"https://github.com/dstein64/media/blob/main/colortrans/content_thumbnail.jpg?raw=true\" height=\"164\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/dstein64/media/blob/main/colortrans/reference.jpg?raw=true\"\u003e\n    \u003cimg src=\"https://github.com/dstein64/media/blob/main/colortrans/reference_thumbnail.jpg?raw=true\" height=\"164\"/\u003e\n  \u003c/a\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://github.com/dstein64/media/blob/main/colortrans/output.jpg?raw=true\"\u003e\n    \u003cimg src=\"https://github.com/dstein64/media/blob/main/colortrans/output_thumbnail.jpg?raw=true\" width=\"536\"/\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\nInstallation\n------------\n\n#### Requirements\n\n- Python 3.8 or greater (earlier versions may work, but are not tested)\n\n#### Install\n\n```sh\n$ pip3 install colortrans\n```\n\n#### Update\n\n```sh\n$ pip3 install --upgrade colortrans\n```\n\nCommand-Line Usage\n------------------\n\nThe program can be used from the command line.\n\nThe general command line usage is shown below.\n\n```sh\n$ colortrans [--method METHOD] [--single-precision] CONTENT REFERENCE OUTPUT\n```\n\n`CONTENT` is the path to the content image, `REFERENCE` is the path to the style image, and `OUTPUT`\nis the path to save the output image.\n\n`METHOD` specifies the color transfer algorithm. The following methods are supported:\n\n1. `lhm` Linear Histogram Matching [1] (default)\n2. `pccm` Principal Components Color Matching [2, 3]\n3. `reinhard` Reinhard et al. [4]\n\nIf the optional `--single-precision` flag is present, 32-bit floats will be used instead of 64-bit floats.\n\nIf the launcher script was not installed within a directory on your PATH, colortrans can be launched by\npassing its module name to Python.\n\n```sh\n$ python3 -m colortrans [--method METHOD] CONTENT REFERENCE OUTPUT\n```\n\nLibrary Usage\n-------------\n\nThe algorithms can also be used directly from Python programs. Each of the methods listed above has\na corresponding function, `transfer_METHOD`, taking two NumPy arrays corresponding to the content\nand reference image, respectively. The arrays have `HxWxC` data ordering (channels-last). The functions\nalso take an optional keyword argument, `single_precision`, a boolean that specifies whether 32-bit\nfloats will be used instead of 64-bit floats (defaults to `False`).\n\n#### Example\n\n```python\nimport colortrans\nimport numpy as np\nfrom PIL import Image\n\n# Load data\nwith Image.open('/path/to/content.jpg') as img:\n    content = np.array(img.convert('RGB'))\nwith Image.open('/path/to/reference.jpg') as img:\n    reference = np.array(img.convert('RGB'))\n\n# Transfer colors using different algorithms\noutput_lhm = colortrans.transfer_lhm(content, reference)\noutput_pccm = colortrans.transfer_pccm(content, reference)\noutput_reinhard = colortrans.transfer_reinhard(content, reference)\n\n# Save outputs\nImage.fromarray(output_lhm).save('/path/to/output_lhm.jpg')\nImage.fromarray(output_pccm).save('/path/to/output_pccm.jpg')\nImage.fromarray(output_reinhard).save('/path/to/output_reinhard.jpg')\n```\n\nReferences\n----------\n\n[1] Hertzmann, Aaron. \"Algorithms for Rendering in Artistic Styles.\" Ph.D., New York University,\n2001.\n\n[2] Kotera, Hiroaki, Hung-Shing Chen, and Tetsuro Morimoto. \"Object-to-Object Color Mapping by Image\nSegmentation.\" In Color Imaging: Device-Independent Color, Color Hardcopy, and Graphic Arts IV,\n3648:148–57. SPIE, 1998.\n\n[3] Kotera, Hiroaki. \"A Scene-Referred Color Transfer for Pleasant Imaging on Display.\" In IEEE\nInternational Conference on Image Processing 2005, 2:II–5, 2005.\n\n[4] Reinhard, Erik, Michael Adhikhmin, Bruce Gooch, and Peter Shirley. \"Color Transfer between\nImages.\" IEEE Computer Graphics and Applications 21, no. 5 (July 2001): 34–41.\n\n[badge_link]: https://github.com/dstein64/colortrans/actions/workflows/build.yml\n[badge_thumbnail]: https://github.com/dstein64/colortrans/actions/workflows/build.yml/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdstein64%2Fcolortrans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdstein64%2Fcolortrans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdstein64%2Fcolortrans/lists"}