Skip to content

Automate the conversion of images to pixel-art ready to be handcrafted into pixel-beads!

License

Notifications You must be signed in to change notification settings

Chipdelmal/PixArt-Beads

Repository files navigation

PixArt Beads

This repo contains some python scripts that should be useful in transforming images into pixel-beads images and handcrafts!

Some of the main features are:

  • Color quantization: with the option to use number of colors, provided or user-defined color palettes.
  • Image downscale: take an image and downsize it to a desired number of pixels.
  • Color mapping: manually change colors to do things like remove the background.
  • Color counts: count the number of beads of each color that are needed for our handcraft.

Instructions

IMPORTANT NOTE: For a step-by-step use of the scripts, please have a look at the provided demo after installing the dependencies.

To use the scripts first install the required dependencies either through the REQUIREMENTS files (txt/yml), or manually:

pip install numpy
pip install Pillow
pip install matplotlib
pip install opencv-python

Give the bash script executable permissions:

chmod +x main.sh

And then run it as follows:

./main.sh $PTH $IMG $DWN $UPS $DBG
  • PTH: Folder in which our image(s) are stored along with the palettes and color mapper.
  • IMG: Image name for the file to be processed.
  • DWN: Width in pixels for our output image (leave as 0 if no downscaling is desired).
  • UPS: Upscaler multiplier for the plots (10, the suggested value, will multiply the dimensions of the downscaled images by ten when exporting the output).
  • DBG: Debug mode (leave as 0 if no intermediary output is desired, and as 1 to have each intermediate plot exported).

This will take the IMG in the set PTH along with all the *.plt files stored in the directory and the CMapper.map, and generate a nested output folder (in the same directory) with the bead plots. Alternatively, we can use the batch.sh file to process all the images stored in the same directory:

./batch.sh $PTH $DWN $UPS $DBG

Finally, the script can also be called from python with:

python main.py $PTH $IMG $PAL $DWN $UPS $DBG

where an additional parameter PAL is needed for the color palette filename (if set to a number instead of a .plt file, it will instead quantize to the provided number of colors.

Available Palettes

Some nice color palettes are included in the scripts, but if you have the hex colors of your beads, please follow this link for information on how to use them in your handcraft! A subset of the included palettes is shown but follow the link for the full list:

CodePaletteSource
CoolWood_8https://lospec.com/palette-list/coldwood8
Gray2Bit_4https://lospec.com/palette-list/2-bit-grayscale
IslandJoy_16https://lospec.com/palette-list/island-joy-16
MF_16https://lospec.com/palette-list/mf-16
Mist_GBhttps://lospec.com/palette-list/mist-gb
NEShttps://lospec.com/palette-list/nintendo-entertainment-system
Nostalgia_36https://lospec.com/palette-list/nostalgia36
Super_16https://lospec.com/palette-list/super16
Sweetie_16https://lospec.com/palette-list/sweetie-16

Author

For more info, have a look at my accompanying blog post describing the processing pipeline!


Héctor M. Sánchez C.