danielballan / photomosaic

Assemble thumbnail-sized images from a large collection into a tiling which, viewed at a distance, gives the impression of one large photo.
http://danielballan.github.io/photomosaic/docs/
BSD 3-Clause "New" or "Revised" License
57 stars 13 forks source link

API redesign #6

Closed danielballan closed 8 years ago

danielballan commented 9 years ago

Here is an alternative API, using plain Python objects as much as possible.

Update: Revised in next comment

pool = SqlImagePool('path')
# partition is a function that returns a list of Tile objects
tiles = partition(img, dimensions, ...)  # tiles should be analyzed during their init
# more verbose tuning API might make it less mysterious, more customizable
palette = compute_palette(img_historgram(img))
tiles = tune(tiles, palette)  # returns a copy of the tiles
mosaic = match(tiles, pool, ...)
# mosaic is a dictionary mapping each tile object to an image_id from the pool
result_img = assemble(mosaic, tiles, pool, ...)

By putting the tile<->pool_img assignment in a dict instead of in the Tile's state, we can hold more than one mosaic option at once.

danielballan commented 9 years ago

Summarizing ideas from phone conversation:

*Here is a well-reserached color conversion utility (incidentally by Nathaniel Smith, a core dev on numpy). It includes CAM02-UCS and other perceptually uniform spaces, as well as spaces that simulate color blindness. https://github.com/njsmith/pycam02ucs

danielballan commented 8 years ago

Some of these ideas -- the good ones ;- ) -- were incorporated in #9.