def pool(): tempdirname = tempfile.mkdtemp() pm.rainbow_of_squares(tempdirname, range_params=(0, 256, 30)) pool = pm.make_pool(os.path.join(tempdirname, '*.png')) def delete_dm(): shutil.rmtree(tempdirname) return pool
def pool(): tempdirname = tempfile.mkdtemp() pm.rainbow_of_squares(tempdirname, range_params=(0, 256, 30)) pool = pm.make_pool(os.path.join(tempdirname, "*.png")) def delete_dm(): shutil.rmtree(tempdirname) return pool
def basic_mosaic(filename): from skimage.io import imread image = imread(filename) import photomosaic as pm # Generate a collection of solid-color square images. pm.rainbow_of_squares('pool/') # Analyze the collection (the "pool") of images. pool = pm.make_pool('pool/*.png') mos = pm.basic_mosaic(image, pool, (30, 30), depth=1) from skimage.io import imsave imsave(filename[:-4] + '_basic_mosaic' + filename[-4:], mos)
def gen_pic(): target = '28387.jpg' image = imread(target) dims_list = [(150, 150,), ] # Analyze the collection (the "pool") of images. # pool = pm.make_pool('guinnesscaps/*.jpg') # Generate a collection of solid-color square images. pm.rainbow_of_squares('pool/', range_params=(0, 256, 128)) # Analyze the collection (the "pool") of images. pool = pm.make_pool('pool/*.png') for dims in dims_list: mos = pm.basic_mosaic(image, pool, dims, depth=1) imsave('mosaic_{}.png'.format(target), mos)
from skimage.io import * #read and write images in various formats import sys # for runtime environment import photomosaic as pm from skimage import data #standard test images (image processing) image = data.chelsea()# get chelsea.png #change the img as needed imsave('image.png',image) mosaicSize=(int (sys.argv[1]),int(sys.argv[2])) pm.rainbow_of_squares('square/') #Generate 5832 small solid-color tiles for experimentation and testing into folder 'square/' squarePool=pm.make_pool('square/*.png') mosaic=pm.basic_mosaic(image,squarePool,mosaicSize) outputFile= sys.argv[3] if len(sys.argv)==4 else 'mosaic.png' imsave(outputFile,mosaic)
import os import photomosaic as pm POOL_DIR = '/tmp/photomosaic-docs-pool/' pm.rainbow_of_squares(POOL_DIR) pool = pm.make_pool(os.path.join(POOL_DIR, '*.png')) pm.export_pool(pool, os.path.join(POOL_DIR, 'pool.json'))