Skip to main content

Color Luminance Map Script

What it Does

For this entry we will cover how to run the Color Luminance Map Script.  This script takes a simple png (the map) and takes all the colors along a row and maps them to the luminance for each pixel on another image (sort of like an advanced Colorize).



Install Python

If you don't have Python installed already, you will first need to install Python.

Download the Script

You can find the script and some example images in github here: https://github.com/makeshoppro/psp_tools/tree/master/color_luminance_map

Click on the color_luminance_map.py file.

On the new screen right-click on the [RAW] button and select Save Link As...

To download the example images, simply click on them and then click the [Download] button.  When the image is presented, you can right-click on them and select Save Image As...

Install a library

To the run the script, you'll need to install one library.  If you have installed this library for another script, you can skip this step.

First we need to open a command prompt.  To do this, you can type cmd in the address bar as show below.  And when you hit [Enter] a command prompt should come up.


In the command prompt, simply type pip install imageio

If you have the library installed already, you'll see the following screen.  If not, you'll see the library begin to install.


Run the Script

Now that we've installed the necessary library, in the same command prompt window we can test the script out by typing the following command:

   python color_luminance_map.py bw.png skin_map.png

and if the script runs as expected, you should see the following output:


Once the script completes a new file colored_img.png should be generated.

If this does not work, you may need to retrace your steps and see if you missed any details along  the way.

Making your Own Map

When creating your own map file, recognize that the dark pixels of the image will correlate with the pixels on the left side of the map image, and the lighter pixels will correlate with the right side of the map image.

The map image must be 255 pixels in width, but can be any height at least 1 row high.

This script is meant for creating more realistic skin tones, but it can also be used to generate creative effects.  For example, using a rainbow map produced this image:


Comments