Color Hamronizer
Introduction
Here is an idea for a color processing tool I had about a year ago. I often like to tone images based on the prevalent colors in an image. What I normally try is to pull adjacent colors towards a selected color in order to get a more harmonious image. This can be done with various tools from various softwares (eg. in Rawtherapee’s LAB-Tool I use the HH curve). But it would be nice if I could select the color (the other colors are pulled towards) directly in the image.
I have written a little Python script which works on very small images, but I would like to see it usable for larger (normal) images as well. I started to refresh my non existing C++ skills in attempt to maybe integrate it into RT someday, but this is not realistic as work and family take up to much time at the moment to do anything else with some intensity.
So I will share the idea and the existing script here to maybe inspire somebody!
Basic Idea
The idea is to take a color space like LAB, which has a two dimensional color plain (A, B) detached from the luminosity (L). The idea is to select a so called pull color from the image itself, and all other colors are then pulled towards the pull color. The amount of pull is defined by a strength. If two or more pull colors are selected, then each other color is pulled towards its closest pull color.
So how do I define a “closest” color?
That depends on the color space. Ideally it is done in a color space like LAB were you have a plane that defines all the colors and is detached from the luminosity.
Rough Script
A very rough working script in python using OpenCV is available here:
The program allows to select pull colors by clicking on the image itself. It allows up to three pull colors.
- The first pull color is selected by a left mouse click.
- The second pull color is selected by a right mouse click.
- The third pull color is selected by a click on the mouse wheel.
You can set the strength of the pull, the number of pull points and a blur, which I will explain later.
The program basically looks where the selected pull color is located in Lab’s AxB-plane an geometrically selects which colors are pulled towards which pull color.
Examples
The first row of images shows the effect of selecting one pull color. On the left is the original image.
I select one color and gradually increase the strength from left to right.
[outflie_cl1_str]
The next row shows the effect of selecting two colors with 100% strength. The first image has no blur. Then blur is increased towards the right.
[outfile_cl2_blur]
The next row shows two colors selected with a full blur and then the strength is decreased.
[outfile_cl2_str]
Examples with a real image
The next imagess show possible applications to a real image.
Here I select the red from the coat and increase the strength:
[outimage_cl1_row]
Next I select the red from the coat and the blue from the jeans and apply full strength at first and then gradually increase the blur:
[outimage_cl2_str100_bl0_2_4_8]
Here again the red and blue colors selected with a blur of 4 while increasing the strength from 0 to 100:
[outimage_cl2_bl4_str0_20_40_60_100]
Last I select a third color, the green grass. The strength is set to 100 and the blur is increased from 0 to 4. The original image is on the right for comparison.
[outimage_cl3_str100_bl0_2_4_original]
Further ideas
- Select one color from image and automatically create the other pull colors based on color harmonies (complementary, tertiary, etc…)
- make it possible to select wether a pull color will just adjust the tone of other colors while keeping it’s saturation, or if it should also change the saturation
- make it possible to select the colors from a color gradient instead of selecting them from the image.
- and obviously make so that everything stays within gamut…