Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

Latest commit

 

History

History
50 lines (35 loc) · 1.71 KB

index.md

File metadata and controls

50 lines (35 loc) · 1.71 KB

legofy

What is legofy?

It's a simple python function to convert an image into a a lego-like image. It started long ago as a practical exercise to learn some simple Python functionality (e.g. PyPI packaging) but it's now retired in favor of JuanPotato's Legofy.

Usage

A simple example can be generated by using an array with random values:

import numpy
from legofy import legofy
from matplotlib import pyplot

im = numpy.random.rand(10, 10)
im_lego = legofy(im)
_ = pyplot.imshow(im_lego, interpolation='none', origin='lower')

Random

But I want to do it with my profile picture, how can I do it?!

import scipy
from legofy import legofy
from matplotlib import pyplot
import urllib
import cStringIO

url = 'http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/161px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg'
im = misc.imread(cStringIO.StringIO(urllib.urlopen(url).read()))
im = misc.imresize(im, (50, 33), interp='nearest')
im = 1-(255-im)/(255)
im_lego = legofy(im)
_ = pyplot.imshow(im_lego, interpolation='none', origin='lower')

Monalisa

License information

See the file LICENSE for information on this software, terms & conditions for usage and a disclaimer of all warranties.