Skip to content

A web application to generate color gradients using the CAM02-UCS colorspace.

License

Notifications You must be signed in to change notification settings

crowsonkb/gradient-maker3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gradient_maker

A web application to generate color gradients using the CAM02-UCS colorspace. (See also: CIECAM02 and Its Recent Developments.)

Input colors are converted to the CAM02-UCS JMh (cylindrical) space and interpolation is performed. The resulting sequence is then converted to Jab (rectangular) format for gamut mapping. Projected gradient descent is employed, with two terms in the loss function: one term representing fidelity of an in-gamut Jab color in isolation to its ideal Jab color, the other penalizing deviations from the first differences of the ideal Jab color sequence. The second term keeps the sequence of colors spatially consistent. The CAM02-UCS forward transform was implemented in Theano for speed and Theano also differentiates the forward transform. The reverse transform is not needed explicitly. The resulting sequence of RGB colors lies inside the sRGB gamut.

Requirements: Python 3.5+, aiohttp, numpy, scipy, Theano, ucs. See requirements.txt for details. Theano will need a C compiler and Python 3 development headers installed (on Debian/Ubuntu, the packages build_essential and python3-dev). On MacOS, Homebrew's Python 3 will work.

Running it: python3 -m gradient_maker [--host HOST] [--port PORT]. On first run, the srgb_to_ucs() and opfunc() functions need to be translated from Theano to C and compiled. This can take several minutes but the result is cached for future quick startup. For best performance, run it on the CPU (THEANO_FLAGS=device=cpu): Theano can compile it to use a GPU but this was found to run slower.