Generate dice mosaics from jpeg/png images.
Default options will attempt to read from 'input.jpg' in the current directory, scale the image by 0.05, then convert each pixel to grayscale before generating a dice mosaic using black die(w/ white dots) and saving the dice mosaic to 'output.png'.
Example: ./dice-mosaic -i examples/moon.jpg -o examples/moon_black_dice.png
For all white die(w/ black dots) use the '-g w' flag.
Example: ./dice-mosaic -i examples/moon.jpg -o examples/moon_white_dice.png -g w
Here is an example of a mixed(white and black) die mosaic that was processed with increased contrast and brightness, and scaled to the largest resolution possible while not exceeding 48,000 die. Additionally the option -l [filename], indicates that the program should output a text file containing a map of dice values.
Example: ./dice-mosaic -i examples/sg.jpg -o examples/sg_dice.png -b 8 -c 1.17 -g m -m 48000 -l examples/sg.txt
-i [filename]
-
Input image(jpeg/png) filename or path.
-
Default is 'input.jpg'
-
Output image filename or path. Default output format is .png.
-
Default is 'output.png`
-
Factor to scale input image by. Aspect ratio is preserved. Must be greater than 0. After scaling, each pixel cooresponds to a single dice. (this is the default scaling behavior if -x, -w, -h or -m, are not specified)
-
Default is 0.05
-
Cannot be used in conjunction with -w, -h, or -m.
-
Alternative scaling option, will scale an image to a specified number of die in width while preserving aspect ratio. Must be an integer greater than 0.
-
Cannot be used in conjunction with -x, -h, or -m.
-
Alternative scaling option, will scale an image to a specified number of die in height while preserving aspect ratio. Must be an integer greater than 0.
-
Cannot be used in conjunction with -x, -w, or -m.
-
Alternative scaling option, will scale the input image as large as possible while not exceed the specified number of die. Aspect ratio is preserved. Must be an integer greater than 0.
-
Cannot be used in conjunction with -x, -w, or -h.
-
Will output a text file containing a list of dice values, at the specified path.
-
For all black die(w/ white dots) use './dice-mosaic -g b'. (this is the default if -g is not specified)
-
For all white die(w/ black dots) use './dice-mosaic -g w'.
-
For a mix of black and white die use './dice-mosaic -g m'.
-
Set the output image format to JPEG and set JPEG quality setting. Integer from 0-100. High quality is 80-90.
-
Cannot be used in conjunction with -p.
-
Set the output image format to png. (this is the default if -j or -p is not specified)
-
Cannot be used in conjunction with -j.
-
Change the contrast. a > 1 means more contrast, 0 < a < 1 means less contrast.
-
The value of a pixel is determined by the following function: f(x) = a(x) + b
-
Default is a=1.0
-
Change the brightness.
-
The value of a pixel is determined by the following function: f(x) = a(x) + b
-
Default is b=0.0
-
Set the resolution of the dice that make up the mosaic. [dice_resolution] is the length of the sides of each dice. Must be an integer that is at least 12.
-
Default is 40
-
When this input is given the program will calculate the total cost of the mosaic. (Assumes USD)
-
When this input is given the program will calculate the total size of the mural. (Assumes inches) (0.63in (16mm) is most common)
You are welcome to compile the code from source, otherwise here are instructions for how to get started with the provided compiled binaries.
Linux or Windows:
-
Clone repository
git clone https://github.com/lmarzen/dice-mosaic.git
or download and extract ZIP. -
Open a terminal(or command prompt on Windows) in the folder that contains the dice-mosaic program.
-
Run the program by typing
./dice-mosaic
if on linux ordice-mosaic_x86.exe
if on windows 32-bit ordice-mosaic_x64.exe
if on windows 64-bit, followed by any valid arguments. -
Done.