Giter VIP home page Giter VIP logo

mosaic's Introduction

Mosaic Generator

This script is a simple mosaic generator. It uses a random greedy algorithm to pack as many images as possible into a canvas for a given size.

Dependencies:

The following python packages are needed:

  • argparse
  • PIL
  • numpy
  • json

Inputs:

The main input to the script is a directory of png images. Ideally, each image should have transparent background to achieve tighter packing.

Usage:

Assuming all input images are in image_directory and we would like to pack them into a 2000px by 1800px canvas:

./generate_mosaic.py -W 2000 -H 1800 image_directory output.png

where -W and -H option specifies the output canvas width and height, ideally the canvas should at least be 4x larger than a typical image in the image_directory. The scale of each image is chosen at random. However, the script does take a list of preferred image names from the user. The preferred images will be packed first and are more likely to be larger than the rest of the images.

Examples:

The following examples are generated with this script:

Thingi10K: Thingi10K Poster

Tetrahedral Meshing in the Wild (Siggraph 2018): TetWild

Decoupling Simulation Accuracy from Mesh Quality (Siggragh Asia 2018) Decouple

Poly-Spline Finite Element Method (ToG 2019) polyfem

LayerCode: Optical Barcodes for 3D Printed Shapes (Siggraph 2019) layercode

Computer Graphics Forum (Volume 37 Issue 1) Cover image

If you have used Mosaic to generate a figure, please let me know and I can include your example here.

Author:

Qingnan Zhou
Adobe Systems

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.