mirror of
https://github.com/muesli/kmeans.git
synced 2025-10-05 23:56:59 +08:00
Use kmeans.Points in examples
This commit is contained in:
@@ -18,7 +18,7 @@ import "github.com/muesli/kmeans"
|
|||||||
km := kmeans.New()
|
km := kmeans.New()
|
||||||
|
|
||||||
// set up "random" data points (float64 values between 0.0 and 1.0)
|
// set up "random" data points (float64 values between 0.0 and 1.0)
|
||||||
d := []kmeans.Point{}
|
var d kmeans.Points
|
||||||
for x := 0; x < 255; x += 4 {
|
for x := 0; x < 255; x += 4 {
|
||||||
for y := 0; y < 255; y += 4 {
|
for y := 0; y < 255; y += 4 {
|
||||||
d = append(d, kmeans.Point{
|
d = append(d, kmeans.Point{
|
||||||
|
@@ -32,10 +32,9 @@ var (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Create data points in the CIE L*a*b color space
|
// Create data points in the CIE L*a*b color space
|
||||||
d := []kmeans.Point{}
|
|
||||||
|
|
||||||
// l for lightness channel
|
// l for lightness channel
|
||||||
// a, b for color channels
|
// a, b for color channels
|
||||||
|
var d kmeans.Points
|
||||||
for l := 30; l < 255; l += 16 {
|
for l := 30; l < 255; l += 16 {
|
||||||
for a := 0; a < 255; a += 16 {
|
for a := 0; a < 255; a += 16 {
|
||||||
for b := 0; b < 255; b += 16 {
|
for b := 0; b < 255; b += 16 {
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
// set up "random" data points (float64 values between 0.0 and 1.0)
|
// set up "random" data points (float64 values between 0.0 and 1.0)
|
||||||
km := kmeans.New()
|
km := kmeans.New()
|
||||||
d := []kmeans.Point{}
|
var d kmeans.Points
|
||||||
for x := 0; x < 255; x += 4 {
|
for x := 0; x < 255; x += 4 {
|
||||||
for y := 0; y < 255; y += 4 {
|
for y := 0; y < 255; y += 4 {
|
||||||
d = append(d, kmeans.Point{
|
d = append(d, kmeans.Point{
|
||||||
|
Reference in New Issue
Block a user