Skip to content

kalyaninagaraj/Domino-Mosaics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Domino Mosaics a la Robert Bosch (and Ken Knowlton)

About

This repository is home to optimization and image processing code that approximates a given image (could be color or grayscale) with a mosaic in complete sets of double-nine dominoes.

     

For example, consider the image on the left of a young Hank Marvin from his days with The Shadows. Code in this repository was used to generate two mosaics (see picture in the middle and on the right -- zoom in to see the tiles), each in 12 complete sets of 55 double-nine dominoes, as a pointillistic representation of the black-and-white photo of Hank.

To learn more about domino mosaics, both the art form and its interpretation as the solution to an integer program, watch mathematician-artist Robert Bosch of Oberlin College give this talk at Google.

Instructions To Create Your Own Domino Mosaic

  1. First, create a library of images for each domino in a set of 55 double-nine dominoes.

    • CODE: Code/Octave/createDominoSet.m

    • TO RUN CODE:

      1. Open Terminal and change current directory to Code/Octave/.
      2. Open Octave by entering octave at the terminal.
      3. To generate images of black domino tiles with white dots, run the octave code by entering createDominoSet('white'). To generate images of white dominoes with black dots, change input argument to 'black'.
    • OUTPUT: A MATLAB (and Octave) compatible .mat file in Data/Domino_Set_Images.

    • Run code once for each tile color. The images (more precisely, a cell array of matrices representing the domino images) are saved to Data/Domino_Set_Images/dominoes_with_white_dots_V7.mat and Data/Domino_Set_Images/dominoes_with_white_dots_V7.mat.

  2. Next, choose a target image. Crop the image to accomodate multiple complete sets of dominoes -- the exact number needs to be calculated manually and will depend on the cropped image dimensions. Then run this next code to perform some image processing and obtain a compressed, grayscale version of the image.

    • CODE: Code/Octave/preprocessImage.m

    • TO RUN CODE:

      1. Open Terminal and change current directory to Octave_scripts.
      2. Open Octave by entering octave.
      3. Run code by entering preprocessImage ('HM').
    • INPUT:

      1. Input parameter 'HM' directs the code to look for the target image HM.jpg (cropped photo of Hank) in Data/Target_Images/.
      2. The code will ask the user to manually enter (i) dimensions m and n of the domino portrait. These dimensions are such that mn = 110s, where s is the number of complete sets used in the image, and (ii) k, the size of each square cell, such that mk equals the height (in pixels) and nk equals the width (also in pixels) of the cropped image. For example, for Hank's potrait, set m to 40, n to 33, and k to 10. This means, in the next step, the optimization code will be using s = 12 complete sets of double-nine dominoes to generate the final mosaic.
    • OUTPUT: A scaled and compressed image file Data/Compressed_Images/HM.txt in the form of a matrix of integers ranging from 0 and 9.

  3. Finally, approximate a greyscale image with s sets of double-nine dominoes by solving a binary integer program.

    • CODE: Code/Julia/ModuleDominoes.jl

    • TO RUN CODE:

      1. Open Terminal and change current directory to Code/Julia/.
      2. Open Julia by entering julia at the command line.
      3. Enter the following commands.
      julia> include("ModuleDominoes.jl")
      julia> using .Dominoes
      julia> dominoes("HM", "white", "constrained")
      
    • INPUT: The input parameter "constrained" indicates that all dominoes in the s complete sets, 55s to be precise, will be used to generate the final mosaic. Setting this last parameter to "unconstrained" indicates to the code that the mosaic is to be built from an unlimited supply of dominoes, which naturally does not make for an interesting optimization problem. The second input parameter (in this example, 'white') indicates the color of the dots on the dominoes.

    • OUTPUT: The code will generate the image Data/Mosaic_Images/HM_white_constrained.png, a mosaic in black domino tiles with white dots.

Code Credits

@kalyaninagaraj

Photo Credit

The image of Hank Marvin is cropped from a group photo of The Shadows that appears in the public domain.

References

  1. This book review in the Scientific American of Robert Bosch's book Opt Art is a great start if you're diving into Bob's world of pointillism-via-optimization.
  2. Details on how to model the integer program can be found in the article "Constructing Domino Portraits" in "Tribute to a Mathemagician".
  3. Check out all of Bob Bosch's Mathematical Art and the art of his inspiration, Ken Knowlton.

About

Domino mosaics a-la Robert Bosch and Ken Knowlton

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published