Skip to main content

ColorizeXL

Python implementation of the following paper by Anat Levin, Dani Lischinski, Yair Weiss, puublished in SIGGRAPH04.

We have adapted their technique to make it suitable for large images, by using overlapping patches with annotations.

Installation:

pip install colorizexl

Usage

Colorization of Black & White images

Previous to using the package, you have to setup the following:

  • original black & white image
  • annotation color image (please check details in the paper)

Recolorization of color images

Previous to using the package, you have to setup the following:

  • original color image
  • annotation image (please check details in the paper): white where the color stays the same, different color where you want to recolorize

Command line

Call the colorizexl.py from command line, to colorize or recolorize images.

python colorizexl.py --annotated=<path_to_annotated_image> --grayscale=<path_to_image_to_(re)colorize> --output=<path_to_(re)colorized_image> --recolorize=True/False

Python code

from colorizexl import ColorizeXL

colorizer = ColorizeXL(
        input_grayscale_name, input_annotation_name, recolorize=False
    )

output = colorizer.colorize(step_size=patch_size, overlap=overlap, n=neighbour)

Customization

From Python you have the options to finetune the following parameters:

  • step_size (default 100), defines the size of the square patches
  • overlap (default 2), defines the overlap of the patches
  • n (default 10), defines the radius of the neighbours in a circle for computing the color

Package organization

colorizexl

Contains the ColorizeXL class, the engine behind the (re)colorization. Its functioning is as follows:

  • __colorize: will take an image and an annotation as inputs and will colorize the image; it will return a colorized image
  • colorize: main entry point in the algorithm, this method will split the initial image in patches and send them to __colorize. It will also take care of the overlaps to ensure smooth transition between colorized regions
  • colorize_no_patch: wrapper for __colorize method, this function is the initial implementation of the algorithm, which is slow and will crash for large images

notebooks

Contains the notebooks used for experimenting:

  • CS445_usage: example code for colorizing and recolorizing images (example images from the original paper are provided); output of the example images can be seen here
  • CS445_master: our inital experiments with colorization
  • CS445_patch_sort: experiments with intelligent sorting of patches to be recolorized

tests

Contains the test code used for fine-tuning and evaluating our package.

  • test_hyperparameters: loops over the hyperparameters (patch size, overlap and neighbours) to compute the MSE (mean squared error), SSIM (structural similarity) and PSNR (peak signal to noise ratio); from these, we have mainly relied on MSE; it also saves an image for each combination, to allow manual selection of the most pleasing visual effect
  • test_timing: downscales a large image by a factor of 0.1 to 1.0 (step 0.1) and measures the time needed for computation (please note that the images resulting from downscaling will not necessarily be of a high quality); execution time of our code scales linearly with the number of pixels to recolorize
  • test_timing_no_patch: similar to test_timing but using a one-shot colorization; this original method presents an exponential increase in time per pixels to be colorized

Metadata

Release files for colorizexl 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colorizexl 0.2.1
File Size Uploaded Provenance Actions
colorizexl-0.2.1.tar.gz 479.2 kB Without provenance Details for colorizexl-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for colorizexl 0.2.1
File Interpreter ABI Platform Actions
colorizexl-0.2.1-py3-none-any.whl Python 3 none any Details for colorizexl-0.2.1-py3-none-any.whl

Total release size: 957.9 kB

Release files / colorizexl-0.2.1.tar.gz

Download URL colorizexl-0.2.1.tar.gz
Size 479.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b63ed9362a4bd8af3ecb715042f1676903daf97dae732cd4cbd1ab90e6303921
BLAKE2b-256 checksum
How to use checksums
6388d90d47dd6fc40c787f19ac38439ed1cc5ae7eea51a914eff7b64989515fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / colorizexl-0.2.1-py3-none-any.whl

Download URL colorizexl-0.2.1-py3-none-any.whl
Size 478.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
454dc74f66c9d734beb4e5e235a4f2591eb262121ca124a5547f99432c813f70
BLAKE2b-256 checksum
How to use checksums
d13315af08fddfd9ca3b5f843873b65a92227021af38eebfb23f1f9557049d70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Security for colorizexl 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page