Skip to main content

Luminance and histogram matching tools

Project description

Neural-Tools

Tools made for usage alongside artistic style transfer projects based on the Controlling Perceptual Factors in Neural Style Transfer research paper by Leon A. Gatys, Alexander S. Ecker, Matthias Bethge, Aaron Hertzmann, and Eli Shechtman.

In-depth information about how to perform Scale Control and Color Control, including the Neural-Style parameters used in the examples, can be found on the wiki. The Color Control feature is broken down into two different features known as Luminance-Only Style Transfer, and Color Matching. The Scale Control feature focuses on separating style image content/shapes, and style image textures.

Linear Color Transfer

The match_color function's code comes from the very talented Leon Gatys' code here. This script was developed to help enable Scale Control in Neural-Style, but it can be used for anything else that requires linear color transfer. Supported image formats include: jpg, jpeg, png, tiff, etc...

Scale Control examples made with Neural-Style, can be viewed here.

Installation:

pip install neural-tools

Or:

pip3 install neural-tools

Usage:

Basic usage:

linear-color-transfer --target_image target.png --source_image source.png

Advanced usage:

linear-color-transfer --target_image target.png --source_image source.png --output_image output.png --mode pca --eps 1e-5

Parameters:

  • --target_image: The image you are transfering color to. Ex: target.png

  • --source_image: The image you are transfering color from. Ex: source.png

  • --output_image: The name of your output image. Ex: output.png

  • --mode: The color transfer mode. Options are pca, chol, or sym.

  • --eps: Your epsilon value in scientific notation or normal notation. Ex: 1e-5 or 0.00001.

Examples:

Source Image:

Target Image:

Output Image:

See here for how to use this script for Scale Control.

Linear Color Transfer is also used for Color Matching Style Transfer:

See here on the wiki, for more details on Color Matching Style Transfer.



Luminance Transfer

This script was developed to help enable colour control in Neural-Style, also known as "Luminance Transfer". This script uses code from Leon Gatys' code here. Supported image formats include: jpg, jpeg, png, tiff, etc...

Luminance transfer/Color Control examples made with Neural-Style, can be found here.

How It Works:

Currently, all available models are trained on images with the RGB/BGR color space. An image's luminance can represented in the form of gray scale color space image, which can be converted to RGB format for Neural-Style. After the gray scale images are run through Neural-Style, re-applying the color to your output is done with the use of the LUV color space.

Basically due to pre-trained model limitations, gray scale images are used to transfer luminance, and a color space supporting luminance is used to transfer the colors back to the finished output.

Installation:

pip install neural-tools

Or:

pip3 install neural-tools

Usage:

Basic usage:

lum-transfer --content_image content.png --style_image style.png

Advanced usage:

lum-transfer --cp_mode lum --content_image content.png --style_image style.png --org_content content.png --output_style_image output_style.png --output_content_image output_content.png

Parameters:

The required input images and the output images, are dependent on the --cp_mode option that you choose:

  • --cp_mode: The script's mode. Options are lum, lum2, match, match_style.

Mode: lum

  • --content_image: Your content image. Ex: content.png

  • --style_image: Your style image. Ex: style.png

  • --org_content: Your original unmodified content image. Ex: original_content.png

  • --output_content_image: The name of your output content image. Ex: content_output.png

  • --output_style_image: The name of your output style image. Ex: style_output.png

Mode: match

  • --content_image: Your content image. Ex: content.png

  • --style_image: Your style image. Ex: style.png

  • --output_style_image: The name of your output style image. Ex: style_output.png

Mode: match_style

  • --content_image: Your content image. Ex: content.png

  • --style_image: Your style image. Ex: style.png

  • --output_content_image: The name of your output content image. Ex: content_output.png

Mode: lum2

  • --output_lum2: The name of your output image from Neural-Style. Ex: out.png

  • --org_content: Your original unmodified content image. Ex: original_content.png

  • --output_image: The name of your output image. Ex: output.png

Examples:

The style image is adjusted to match the content image:

After Neural-Style:

Final ouput image:


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

neural-tools-0.0.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distributions

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

neural_tools-0.0.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

neural_tools-0.0.4-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2Python 3

neural_tools-0.0.4-py2-none-any.whl (9.7 kB view details)

Uploaded Python 2

File details

Details for the file neural-tools-0.0.4.tar.gz.

File metadata

  • Download URL: neural-tools-0.0.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.2

File hashes

Hashes for neural-tools-0.0.4.tar.gz
Algorithm Hash digest
SHA256 97ae882a33837ba43a2e536d06f4af2ba28c9fa261992c897ae27c960960fa79
MD5 4fbce011ade2ce8b44870df33f8a5200
BLAKE2b-256 0465b19bb7647f57b30fb9abdc7172c38e428ff8fd7ad2db074fdc4c6c81f692

See more details on using hashes here.

File details

Details for the file neural_tools-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: neural_tools-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.2

File hashes

Hashes for neural_tools-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b6fe0f57d70e8173a3a8b374c31a6154f260e0a7e30342bb36a2f6a0586259ca
MD5 bad1c54c0c6c625c2c7f9ba40aae522c
BLAKE2b-256 9ebec35da08def4e2aedbbb29dbc52dc9bcf443151f3735289359681daccb236

See more details on using hashes here.

File details

Details for the file neural_tools-0.0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: neural_tools-0.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.2

File hashes

Hashes for neural_tools-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ca4e0913adb44b5e6ffbce7f89f64516ea2cfea058fbbb655e838934695605cd
MD5 a0b160d281ffbac33e19682199d49463
BLAKE2b-256 a9067f8e5db3ce99daa5a897f60bde9f5a5339598fcf8185b65d65c6cfd1fe28

See more details on using hashes here.

File details

Details for the file neural_tools-0.0.4-py2-none-any.whl.

File metadata

  • Download URL: neural_tools-0.0.4-py2-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.2

File hashes

Hashes for neural_tools-0.0.4-py2-none-any.whl
Algorithm Hash digest
SHA256 c25c78fad351eb7d94a36dea19c28ff75544510e54ae38b028d4d793e450c702
MD5 1afe53ee994a0005e6fcb2498dc232d3
BLAKE2b-256 8e8601bf993b4657126a038c04423205d8d99a391efe20a90e1058d746201c41

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