GithubHelp home page GithubHelp logo

forevermatt / mosaic Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 103 KB

A set of PHP classes for assembling a mosaic, designed to look like a given guide image, using a set of source images.

PHP 99.41% Makefile 0.19% Gherkin 0.40%

mosaic's Introduction

Mosaic Maker

A set of PHP classes for assembling a mosaic, designed to look like a given guide image, using a set of source images.

Usage

Pick a directory where the temp folder (used for caching source image data) can be kept. Open a command prompt in that folder, and run the following:

php <path/to/cli.php> <path/to/guide-image.jpg> <path/to/source/images/>

Replace the values in angle brackets with actual paths. For example, replace <path/to/cli.php> with something like "C:\code\mosaic\cli.php" (depending on where you cloned this repo to on your computer). Note that any additional command-line parameters are treated as additional folders containing source images to be used for generating the mosaic.

The first time you run this, it will probably take quite some time since it has not yet cached downsized copies of your source images (and therefor it has to do a lot of image resizing). The next (and subsequent) times should be much faster.

Basic Approach

A. Get guide image. B. Get source images. C. Slice up guide image. D. Match up each slice of the guide image with a different source image. E. Assemble and save mosaic.


C.1. Count source images. 2. Slice guide image into no more than that many slices.


D.1. Downsize the slice to 3 pixels by 3 pixels. Record the RGB values of the pixels. 2. Compare that with each of the source images. 3. Make a note of which unused source image matches this slice best.


D.2.a. Downsize the source image to 3 pixels by 3 pixels. Record the RGB values of the pixels. b. Calculate the absolute difference of slice's pixels' colors with this source image's pixels' colors.


E.1. Create a new empty image. 2. Insert each of the source images according to the matches found.


Match accuracy (at a given resolution) = D[1] + D[2] + ... + D[number of pixels]

D = abs(R[a] - R[b]) + abs(G[a] - G[b]) + abs(B[a] - B[b])

Only accuracy calculations at matching resolutions give a meaningful comparison.

Glossary

  • guide image: The image that the mosaic is trying to mimic.
  • slice (aka. guide image slice): A portion of the original guide image.
  • source images: The images being used to recreate the guide image as a mosaic.

License

This software is under the MIT license.

mosaic's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.