Image-to-Art Portraits¶
Transform photographs into striking generative artwork. Each technique uses Scene.from_image() and a different approach to visualize the image data.
Classic Dot Art¶
Map brightness to dot radius — the fundamental image-to-art technique:
scene = Scene.from_image("MonaLisa.jpg", grid_size=45, cell_size=9)
for cell in scene.grid:
r = cell.brightness * 0.48
if r > 0.033:
cell.add_dot(radius=r, color="#ffffff")
Color Dot Art¶
Preserve the original image colors for a vibrant result:
for cell in scene.grid:
r = cell.brightness * 0.45
if r > 0.025:
cell.add_dot(radius=r, color=cell.color, opacity=0.7 + cell.brightness * 0.3)
Halftone Effect¶
Invert the mapping — dark areas get large dots, simulating print halftone:
scene.background = "#0a0a0a"
for cell in scene.grid:
r = (1 - cell.brightness) * 0.5 # Inverted!
if r > 0.0375:
cell.add_dot(radius=r, color="#e0e0e0")
Line Art¶
Replace dots with diagonal lines. Width maps to brightness:
for cell in scene.grid:
width = cell.brightness * 3
if width > 0.2:
cell.add_diagonal(width=width, color=cell.color, opacity=0.5 + cell.brightness * 0.5)
Color Mosaic¶
The most direct approach — fill each cell with its sampled color:
Shape Art¶
Choose different polygon shapes based on brightness bands:
for cell in scene.grid:
b = cell.brightness
size = 0.4 + b * 0.4
if b < 0.3:
verts = Polygon.square(size=size)
elif b < 0.6:
verts = Polygon.hexagon(size=size)
else:
verts = Polygon.star(points=6, size=size, inner_ratio=0.5)
cell.add_polygon(verts, fill=cell.color, opacity=0.6 + b * 0.4)