Skip to content

Instantly share code, notes, and snippets.

@sausheong
Created December 28, 2019 12:39
Show Gist options
  • Select an option

  • Save sausheong/df4daf357be16e747136d26a63f11e17 to your computer and use it in GitHub Desktop.

Select an option

Save sausheong/df4daf357be16e747136d26a63f11e17 to your computer and use it in GitHub Desktop.
photo mosaic blog 4
// find the nearest matching image
func nearest(target [3]float64, db *map[string][3]float64) string {
var filename string
smallest := 1000000.0
for k, v := range *db {
dist := distance(target, v)
if dist < smallest {
filename, smallest = k, dist
}
}
delete(*db, filename)
return filename
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment