Code Monkey home page Code Monkey logo

button-mosaic's Introduction

Button Mosaic

Wheat Field with Cypresses - Vincent van Gogh

Button mosaic of the painting 'Wheat Field with Cypresses' by Vincent van Gogh

The Great Wave off Kanagawa - Hokusai

Button mosaic of the painting 'The Great Wave off Kanagawa' by Hokusai

The Scream (1910) - Edvard Munch

Button mosaic of the painting 'The Scream' (1910) by Edvard Munch

Report

A report describing this work in more detail is available here.

Usage

Set the MATLAB working directory to the source directory to use the program. The simplest use is then:

[mosaic, corrected] = buttonMosaic(image);

where the input image is the RGB-image that should be reproduced and the outputs mosaic and corrected are the resulting mosaics with and without color correction. For more advanced use, see source/examples.m and settings.

Settings

The program settings consists of two structs, circle_packing_settings and mosaic_settings.

circle_packing_settings
Field Explanation
min_radius Minimum Radius
num_clusters Number of perceptually distinct color regions that the image should be segmented to. The image segments are used to determine the size and position of circles.
max_radius Maximum circle radius.
radius_reduction_start Radius where circle radii will start being asymptotically reduced towards max_radius.
smooth_est_scale Image crop factor when estimating settings for the anisotropic diffusion image smoothing. Large images has to be cropped to complete this step in reasonable time.
label_close_radius Radius of circular structuring element used for pre-filtering the segmented image using morphological close.
label_min_area Regions or holes below this area are removed from the segmented image in the pre-filtering step.
mosaic_settings
Field Explanation
scale Scale factor for the mosaic. If the input is 256x512 and scale is 2, then the resulting mosaic will be 512x1024.
AA Anti-Aliasing supersampling factor. The mosaic is scaled by this factor and then downsampled by the same factor to reduce aliasing.
button_history The size of the buffer that keeps track of previously used buttons.
similarity_threshold The program picks the best button match not contained in the button history if it is within this similarity threshold compared to the best button match. This can be used to increase button variety.
min_dominant_radius Circle radii above or equal to this uses dominant color matching to match buttons. Mean color matching is used for radii smaller than this.
unique_button_limit Unique Button Limit

Unique Button Limit

The program has a setting to control the number of unique buttons used in the reproduction, mosaic_settings.unique_button_limit. The program picks the most perceptually important buttons needed to reproduce the given reference image using K-means in CIELAB space, similar to Lloyd-Max quantization using the LBG-algorithm.

Images reproduced with different number of unique buttons

Images reproduced with different numbers of unique buttons.

Minimum Radius

The number of total buttons used in the reproduction can also be controlled by changing the minimum circle radius, circle_packing_settings.min_radius. The number of total buttons increases quadratically with decreasing minimum radius.

Images reproduced with different numbers of total buttons

Images reproduced with different numbers of total buttons.


Circle-packing GIF with diffrent minimum circle radius

Circle packing with mimimum radius decreasing one pixel each frame.

Requirements

The following products are required to run the program:

Name Version
Matlab R2019b (9.7)
Image Processing Toolbox 11.0
Statistics and Machine Learning Toolbox 11.6

License and Attributions

I've created the database of buttons by splitting, cropping, masking and resizing images of buttons sourced from various places. All source images are licensed to permit sharing and adaption and I've attributed the creators of these images under attributions below.

Attributions

I've sourced the images of buttons from the following creators:

Creator: https://www.flickr.com/people/93410621@N05
License: https://creativecommons.org/licenses/by-nc-sa/2.0/
 
Creator: https://www.flickr.com/people/106074308@N06/
License: https://creativecommons.org/licenses/by/2.0/
 
Creator: https://www.flickr.com/people/volvob12b/
License: https://creativecommons.org/publicdomain/zero/1.0/
 
Creator: https://www.flickr.com/people/twenty_questions
License: https://creativecommons.org/licenses/by-nc/2.0/
 
Creator: https://www.flickr.com/people/markmorgantrinidad
License: https://creativecommons.org/licenses/by/2.0/
 
Creator: https://www.flickr.com/people/presley_m/
License: https://creativecommons.org/licenses/by-nc-sa/2.0/
 
Creator: https://www.flickr.com/people/130331218@N03/
License: https://creativecommons.org/licenses/by-nc-sa/2.0/
 
Creator: https://www.flickr.com/people/mag3737/
License: https://creativecommons.org/licenses/by-nc-sa/2.0/
 
Creator: https://www.flickr.com/people/deanhochman/
License: https://creativecommons.org/licenses/by/2.0/
 
Creator: https://www.flickr.com/people/littlelixie/
License: https://creativecommons.org/licenses/by-nc/2.0/
 
Creator: https://www.flickr.com/people/obd-design
License: https://creativecommons.org/licenses/by-nc-sa/2.0/
 
Creator: https://www.pexels.com/
License: https://creativecommons.org/publicdomain/zero/1.0/
 
Creator: https://pikrepo.com/
License: https://creativecommons.org/publicdomain/zero/1.0/
 
Creator: https://pixabay.com/
License: https://creativecommons.org/publicdomain/zero/1.0/
 
Creator: https://pixbay.com/
License: https://creativecommons.org/publicdomain/zero/1.0/
 
Creator: https://pixnio.com/
License: https://creativecommons.org/publicdomain/zero/1.0/
 
Creator: http://www.readyelements.com/
License: https://creativecommons.org/publicdomain/zero/1.0/
 
Creator: https://www.flickr.com/people/salvagenation
License: https://creativecommons.org/licenses/by-nc-sa/2.0/
 
Creator: https://www.flickr.com/people/14903992@N08
License: https://creativecommons.org/licenses/by-nc/2.0/
 
Creator: https://www.flickr.com/people/shellysblogger/
License: https://creativecommons.org/licenses/by-nc-sa/2.0/
 
Creator: https://www.flickr.com/people/thevintagesailor/
License: https://creativecommons.org/licenses/by-nc/2.0/
 
Creator: https://www.flickr.com/people/23882161@N03/
License: https://creativecommons.org/licenses/by-nc/2.0/
 
Creator: https://www.flickr.com/people/welshkaren
License: https://creativecommons.org/licenses/by-nc/2.0/
 
Creator: https://www.flickr.com/people/30478819@N08/
License: https://creativecommons.org/licenses/by/2.0/

The reproduced paintings and photos are all in the public domain, but some of the source images of buttons are licensed under the share-alike license CC BY-NC-SA 2.0. The reproduced images are therefore licensed under:

https://creativecommons.org/licenses/by-nc-sa/4.0/

I've bumped the license to the latest 4.0 version since these are compatible and because this is suggested by CC.

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.