Giter Site home page Giter Site logo

imclab / mozaik-hack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from talis/mozaik-hack

0.0 1.0 0.0 97 KB

Hackday project: Select/upload any picture. The pixels in the picture are analysed to work out the colour. Use pictures posted to twitter, instagram etc to fill each pixel. So each picture is scanned to determine the dominant colour and this is matched against a pixel in the image. Essentially the mosaic will remain active and get filled in piece by piece as pictures are found and the colours match. Specific twitter hashtags can be used to provide the source of images used.

mozaik-hack's Introduction

Mozaik

Original idea as described by rh:

Select/upload any picture. The pixels in the picture are analysed to work out the colour. Use pictures posted to twitter, instagram etc to fill each pixel. So each picture is scanned to determine the dominant colour and this is matched against a pixel in the image. Essentially the mosaic will remain active and get filled in piece by piece as pictures are found and the colours match. Specific twitter hashtags can be used to provide the source of images used.

Initial data set

  • We're using 1M book jackets as a starting source
  • Each jacket is sampled to find it's average colour, then various values for the colour are stored from 24 down to 8bit.
  • The jackets and their metadata are loaded into the database. A seperate collection is maintained indexed by a 24bit colour value which holds an array of pointers to jackets that average to that colour

Producing the Mozaiks

  • You can start from either an ISBN or uploading an image.
  • The image is divided down into a matrix - default 1 pix = 1 cell (called the cellWidth)
  • Images > 200px wide are scaled using a bigger cellWidth
  • Each cell's average colour is taken, the average colour is converted to a range of values from 24 down to 8bit equivalent
  • The database is queried to find a picture match @ 24 bit. If there are >1, one is randomly chosen
  • If a 24bit jacket is not available, we move on to the next closest match, right down to 8bit
  • Using the matrix, a grid of images is rendered in the browser that approximates the original but is made up of '000s of book jacket images
  • You can click on each jacket and re-mozaik that to discover more images

The tech

  • PHP + MongoDB implementation
  • Images stored within Mongo using GridFS
  • Using php-resque workers to perform the initial load
  • Using GD library for the image processing
  • Using F3 for the web app

The API

  • /isbn/@isbn - Get a book jacket matching @isbn
  • /isbn/@isbn.json - Get the metadata about the book jacket
  • /isbn/@isbn/colors.json - Get the color matrix for an image which underpins the mozaik
  • /colors/@color/images.json - Get data about of images matching the @color.
  • /colors/@color/image - Get a single random image matching the @color. If no image exists that matches exactly will walk down approximations of matches right down to 8bit approximation. The image is served with a X-Talis-Mozaik-ISBN and X-Talis-Mozaik-Quality headers, the latter tells you how close the colour match was from highest down to lowest
  • /colors/@color/image/mozaik - Redirect to a new mozaik of a random image matching the @color

The UI

  • /isbn/@isbn/mozaik - A simple HTML page representing a mozaik of the bookjacket matching @isbn

mozaik-hack's People

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.