Harren.us  
Coloring Book
Site Map
 

Steve's Coloring Book

The Program

The Coloring Book program will take a photo, and will create output files which will allow you to color, e.g., with colored pencils, a picture representing the original photo. The Coloring Book program is written in Java, so it will run on any operating system that supports Java, e.g., Windows, Mac, Linux, etc. (see Installation Instructions below). The program, along with its source code, is offered free and "as is".

As of April 26, 2020, this is a new (almost a complete re-write) version of the previous program. The algorithm for colorizing images has been changed (i.e., improved). The two examples below illustrate the improvement.

Example #1

Example 1 Original Photo     Example 1 Old Version Colorized Photo     Example 1 New Version Colorized Photo

The left-hand picture is a photograph of Scarlett Johansson. The old version of the Coloring Book program colorized this photo as shown by the center picture. The new version produces the right-hand picture. As can be seen, the new version, as compared to the old, enhances the colors, and accentuates the details, of the photograph.

Example #2

Example 2 Original Photo     Example 2 Old Version Colorized Photo     Example 2 New Version Colorized Photo

The left-hand picture is a photograph of Elizabeth Taylor. The old version of the Coloring Book program colorized this photo as shown by the center picture. The new version produces the right-hand picture. As before, the new version, as compared to the old, enhances the colors, and accentuates the details, of the photograph.

Colorization Algorithm

The algorithm which is used to colorize the pictures utilizes the ideas of the RGB (red,green,blue) and HSL (hue,saturation,lightness) color spaces. The theory of these two color spaces, and the formulas for transforming a color point from one space to the other, is contained in this document.

While this is not the Coloring Book program, from the HSL RGB.jar link directly below, you can download a little program which helps one visualize the (h,s,l) and (r,g,b) color spaces. The program has six sliders to adjust the color, it displays the color of the color point, and also transforms between the two color spaces. In this little HSL RGB program, the ranges of the (h,s,l) coordinates are the same as in the theory document of the previous paragraph, but the ranges of the (r,g,b) coordinates are from 0 to 25510 = ff16 = one byte, as opposed to from 0 to 1.

Download HSL RGB.jar  (10,805 bytes) to your Desktop,
and then double-click on the "Java" icon.

In any case, the RGB pixels of the original photograph are transformed to the HSL space, and the user (via two sliders) can adjust the lightness and saturation coordinates of the photograph until optimal results are achieved. The lightness and saturation adjusted pixels are transformed back to the RGB system (which is how images are represented on a computer screen) and then the program sets each pixel of the photograph to one of twelve colors (i.e., red, yellow, blue, green, orange, purple, brown, light brown, peach, grey, black or white), whichever one is closest to the lightness/saturation-adjusted color.

Limiting the colorized image to contain at most twelve colors is what allows for the calculation of a line drawing based on the image, where the lines separate the different colors. This line drawing is quite analogous to a page in a coloring book. The end user can print out this line drawing, and color it, e.g., with colored pencils.

Examples of Output from the Program

Based on an image that has been colorized by the Coloring Book program, as described above, two files, in .svg (or Scalable Vector Graphics [SVG]) format, are output by the program. One is a vector fill drawing (which is just the colorized image converted to SVG format). The other is a vector line drawing i.e., the page to color. The main point of the vector fill drawing is for it to be a guide to use when one colors the vector line drawing.

The SVG format is supported by most browsers, e.g., Chrome. So, one can view and/or print the two vector drawings using such a browser. Also, these vector drawings may be imported into other SVG manipulator programs, such as Inkscape.

Example #1

Based on the above right-hand (colorized) image of Scarlett Johansson in the The Program section above, the Coloring Book program outputs the vector fill drawing, and the vector line drawing. Here is the result of the author coloring the vector line drawing with colored pencils.

Example #2

Based on the above right-hand (colorized) image of Elizabeth Taylor in the The Program section above, the Coloring Book program outputs the vector fill drawing, and the vector line drawing. Here is the result of the author coloring the vector line drawing with colored pencils.

Comments

Images which work best with the program are not highly detailed; they should have only one or two main objects of interest: e.g., a portrait, a picture of two people, a picture of one or maybe two objects, etc. Images more complex than this are either too complicated to color, or will have too low of a resolution to tell what the objects are.

It is of interest to note that the colored images obtained (as well as the vector fill drawings) have an optimal viewing distance, which the author has found to be around ten to fifteen feet. When viewed at this optimal distance, the colored images look quite realistic. On the other hand, when viewed too closely, the images look quite "jerky" or overly discretized; and when viewed from a farther distance, they look too blurry.

Installation Instructions

Executable

  1. Click on the Coloring Book.jar link below and download the file to your Desktop.

  2. To run the program, double click on the downloaded "Java" icon. That's it!

Coloring Book.jar   (34,084 bytes)

Source Code

  1. Click on the Coloring Book Source.jar link below and download the file to your Desktop.

  2. From the command prompt type:
    jar xfv "Coloring Book Source.jar"
    
  3. The folders Coloring Book Source and META-INF should be created. The folder Coloring Book Source will contain the source (.java) files and a file ReadMe.txt.

  4. At this point, you can go ahead and delete the Coloring Book Source.jar file and the META-INF folder.

Coloring Book Source.jar   (28,883 bytes)

Problems with the Program

If you have any problems with the program, or any comments about it, you can e-mail steve@harren.us.

 
Coloring Book
Harren.us
Math Rocks!