GithubHelp home page GithubHelp logo

imclab / imgscaper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexjc/imgscaper

0.0 1.0 0.0 664 KB

Generate unique 2D textures from example images and a specification with this command-line tool.

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

imgscaper's Introduction

ImageScaper

A command-line tool for generating unique 2D textures procedurally given example images and a specification. It's a patch-based algorithm that repeatedly splats areas from the example image into the generated output image.

Input/Output Example

Usage

1. Find Input Examples

The best types of inputs are high-resolution photos or textures that are significantly larger than the target output. It's recommended you save these in a lossless format such as PNG. Manually touching up or post-processing the example input also helps generate great looking output.

Currently, only images with relatively uniform hues (e.g. desert, ocean, rocks, forest, grass, etc.) will work well. Image sizes up-to 2560x1440 were tested with the current code.

2. Specify Desired Output

The output image will match the resolution and luminosity of your input specification as a greyscale image. Currently, all pixels must be specified (no alpha) and the source material will be drawn from the same image type.

3. Generate ImageScapes

Once you have all the dependencies installed, run the tool via Python or directly from a wrapper script:

imgscaper input.jpg spec.jpg output.png

This takes about one minute to process currently, for an image of size 1920x1080 with a significantly larger input and the default parameters.

Description

Here's how the algorithm currently works:

  1. The example input image is blurred using a gaussian filter and each of the resulting pixels are binned based on their luminosity.

  2. The input example is broken up into patches stored in buckets based on the luminosity of the center pixel (blurred).

  3. A first pass of the output is generated based on the input specification, looking up the average color (incl. hue and saturation) for the desired luminosity.

  4. Random pixel coordinates are chosen in the target image, and a suitable patch is searched randomly from the source image; one of the top 5 best patches is selected.

  5. The luminosity of the target image is replaced from the source image, but the hue and saturation are preserved as they were initially set.

  6. After a specified number of iterations, the algorithm terminates and returns the image as it is. Use the API to get animated images!

If you have any questions, feel free to ask me on Twitter as @alexjc.

imgscaper's People

Contributors

alexjc avatar

Watchers

 avatar

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.