Skip to content

evancoons22/Voronoi-Stippling-React

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voronoi Stippling with web worker in React

Upload an image to produce a stippling based on brightness values that improves iteratively. After the stippling is created, the Rust-api-Traveling-Salesman backend can be used to create a shortest path between points (NP hard!!). This was built with React and Rust.

Try it here

Summary

A web worker chooses a random stippling and iteratively imporve those points. At each iteration, the centroids are updated based on the brightness of the points around it. In other words, we find all the points closest to the centroid, but instead of updating the centroid based on the mean of the closest points, the centroid is updated based on a weighted average with the brightness values of the points. Over many iterations, the centroids converge towards the darkest regions, and the image appears. See this research, also linked below as #1.

The Rust TSP api is an experiment with an NP hard problem. The api does not use brute force, but rather hill climbing. This can be changed by replacing hill_climbing with brute_force in main.rs. With many points in the stippling, a perfect (or even good) solution is almost impossible.

Example

This was inspired by the TSP art challenge solution of 100,000 points over the Mona Lisa.

  1. other article 1
  2. other article 2

Sources used:

  1. voronoi stippling
  2. d3
  3. d3 github repo
  4. voronoi wiki
  5. Rust travelling_salesman v1.1.22

About

Use a weighted K-means algorithm to get an optimal image "stippling"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published