Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

An implementation based on the paper: Image Compositing for Photographic Lighting

License

Notifications You must be signed in to change notification settings

tjaartvdwalt/light-compositing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

light-compositing

This software package is an implements of the ideas found in the paper User-assisted Image Compositing for Photographic Lighting by Ivaylo Boyadzhiev, Sylvain Paris and Kavita Bala.

This implementation is is alpha state, and contains some bugs, and possibly design flaws. Any pull requests will be gladly accepted by the author.

For more details on the implementation you can take a look at the project report.

Installation

The easiest way to install the package is from the Python Package Index.

pip install light-compositing

Python version

This package has only been tested with Python2. Python3 support is not guaranteed a this time. The exact minimum version of Python is not known at this time, but Python2.7 is recommended.

Dependencies

This package depends on OpenCV. This is the only dependency that needs to be manually installed.

The other dependencies can be automatically installed from the PyPI. These include:

  • NumPy
  • Scipy

Usage

Currently our application does not contain a fully fledged graphical user interface. Each light type is a script that can be run from the command line.

The test_data used in the example commands can be downloaded from here.

Command line options and arguments

Most of the scripts takes a directory argument. This is the directory where the input images are found. We assume that these images are named in the format 000.png ... xyz.png. If no --count option is given, these image files should be the only images in the directory.

Most of the scripts have a --count option, that allows you to set how many of the input images should be used for the calculation.This is useful if you do not want to waste time doing calculations on all the input images. From the results in the paper it seems that setting COUNT > 15 will yield good results in most cases.

All of the scripts have a --verbose option. Setting this option prints debug information.

All of the scripts have a --output option. You can use this option to set the name of the output file you want to generate. If left unset a file name will be based on the light type that was used to generate it. For example running the fill_light script will produce fill_light.png

The edge light, and diffuse color light scripts have an option called --downsample. The option value determines how many times the input images will get down sampled before being passed to the optimization algorithm. The resulting lambdas are then applied to the original sized images. This is useful if you want to get an approximate solution in quick time.

Basis lights

Depending on the size and number of input images used it can take a long time to compute the basis lights. It is best to do this ahead of time, and then use the results as input for the light modifiers. The basis lights only have to be calculated once per set of input images.

Fill light

fill_light test_data/basket

Edge light

edge_light test_data/basket

Diffuse color light

diffuse_color_light test_data/basket

Light modifiers

The light modifiers can be calculated in real time. With further development these scripts could be incorporated into a graphical user interface that allows a user to manipulate the lighting of his image.

Per-Object modifier

The per object modifier takes the output files generated by the fill_light, edge_light and diffuse_color_light scripts as arguments. If these arguments are not specified it uses the default values for each of these lighting types.

The per object modifier has a --mask option that gives the path to a binary image that defines the object of interest. In addition it has --fill --edge and --diffuse options that gives the weight of each lighting type for this modifier.

In this example we give each light type equal weight.

object_modifier --mask test_data/basket_regions/corn.png \
>  --fill 1 --edge 1 --diffuse 1 fill_light.png \
>  edge_light.png diffuse_color_light.png

Soft light modifier

The soft light modifier has a --sigma option that defines the σ value. This value controls how much a particular light is diffused as described in the implementation section.

soft_light_modifier --sigma 0.5 test_data/basket

Regional lighting modifier

The regional light modifier takes an input image as argument instead of an input directory like most of the other lighting types. In addition it has a --beta option that defines the β value. When this value is positive, it emphasizes the bright areas in the input image, and when it is negative it emphasizes dark areas in the input image.

regional_light_modifier --beta 0 my_image.png

Development

We welcome contributions to the project. If you want to help out the easiest way is to contact the author, or simply send a pull request.

The rest of this section gives developer guidelines. It will grow if we get more people involved.

PyPI releases

we use seed to release our package to PyPI

About

An implementation based on the paper: Image Compositing for Photographic Lighting

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages