You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d625028
Browse filesBrowse the repository at this point in the historyBrowse files
Added introduction to /book/voronoi-mosaic.mdx as well as tested Katex formatting. Still need to add image files and format tables. Using Placeholders for now
# Voronoi Mosaics with Adaptive Sampling and Segment Anything Model (SAM)
12
+
13
+
## Abstract
14
+
15
+
Using Voronoi Diagrams and Meta’s neural network, the Segment Anything Model (SAM), we can transform any image into a stained glass mosaic by defining boundaries
16
+
based on an area's significance due to brightness and edge factors.
17
+
18
+
## Chapter Goals
19
+
20
+
By the end of this chapter you should:
21
+
22
+
- Know what a Voronoi Diagram is and why it is so important
23
+
- Build a density field for an image using brightness and edge factors
24
+
- Create a piece of Voronoi Mosaic art by coding in Python
25
+
- Use Meta’s Segment Anything Model (SAM) to generate an object mask
26
+
- Combine SAM's object masks with adaptive sampling to build mosaics that respect object boundaries
27
+
28
+
## Introduction
29
+
30
+
Look at any photograph for more than a second and you'll notice something obvious that most image-processing pipelines quietly ignore: not all of it matters equally.
31
+
A portrait holds its story in the eyes, the corner of a smile, or the tiny lines that make up a dress’ weave; whilst the plain cement wall behind the subject could
32
+
be summarized in a single stroke and nobody would object. Humans categorize their attention this way instinctively. In this chapter, we're going to teach a computer
33
+
to do the same thing, using the technique of Voronoi Diagrams.
34
+
35
+
Image Here
36
+
37
+
The oldest record of the idea comes from René Descartes, sketching out the starry skies by partitioning the space by proximity to the nearest star, in order to map
38
+
the range of influence of the celestial bodies. Fast forward to 1854, during the cholera outbreak in London, English physician John Snow mapped every home to the
39
+
nearest water pump in the city, creating a map of “cells,” each with a water pump at its center. Comparing this map with the map of household deaths, he found the
40
+
vast majority lied in the “cell” of the Broad Street pump. The pump-by-pump territories he sketched were, in effect, Voronoi cells, one of the earliest practical
41
+
life and death applications of the idea before anyone had named it. In today's world, this idea has been constantly adapted to fields far beyond epidemiology.
42
+
In computer science, Voronoi cells power nearest neighbor search and mesh generation, letting a robot or a game engine instantly work out which point between a
43
+
charging dock, a checkpoint, or a Wi-Fi router it is closest to. In biology, the same geometry describes how cells pack themselves into tissue: each nucleus behaves
44
+
like a generating point, pushing outward until it collides with its neighbors, which is why a cross-section of skin or plant tissue under a microscope looks uncannily
45
+
like a Voronoi diagram. And in architecture, the pattern has been used deliberately, the ceiling and façade of Beijing's National Aquatics Center for the 2008
46
+
Olympics, were designed around a Voronoi lattice meant to echo the irregular geometry of soap bubbles. The same math has been used endlessly since centuries ago.
47
+
48
+
Table Here
49
+
50
+
The name itself didn't arrive until 1908, when the mathematician Georgy Voronoi formally generalized the construction to arbitrary dimensions while working on the geometry of quadratic forms, and formalized the definition of Voronoi diagrams as “a partition of space into regions where each region contains all points closest to one generating point, compared with all other generating points.”
51
+
52
+
In other words, the user chooses a type of scattered point, and categorizes space by which scattered point it is closest to.
53
+
54
+
Mathematically, let \(X\) be a metric space with distance function \(d\), where \(x \in X\). Given a set \(S\) of sites \(\{p_1, p_2, \ldots, p_n\} \subset X\), we define a cell with \(p_i\) as its “seed” or “central point” as
55
+
56
+
$$
57
+
V_i = \left\{x \in X \mid d(x, p_i) \le d(x, p_j)\ \forall j \ne i \right\}.
58
+
$$
59
+
60
+
The diagram is simply the collection of \(V_i\) for all \(n\).
61
+
62
+
Table Here
63
+
64
+
From this historical method of describing star fields and disease prevention, we are going to use it to describe pixels, turning an image into a field of “significance”
65
+
that lets us decide where we scatter the points in order to create a Voronoi mosaic.
0 commit comments