colors

extract colors from pictures
git clone git://git.2f30.org/colors.git
Log | Files | Refs | README | LICENSE

commit 9b9bc15a79d495a140ede7fd33dfa9bb4ed149aa
parent 8fca640bea4ef2e99450992827f4aa54d53eb707
Author: sin <sin@2f30.org>
Date:   Tue Jun  9 17:35:54 +0100

Use taxicab metric for k-medians

Diffstat:
colors.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/colors.c b/colors.c @@ -40,9 +40,15 @@ distance(struct point *p1, struct point *p2) { int dx, dy, dz; - dx = (p1->x - p2->x) * (p1->x - p2->x); - dy = (p1->y - p2->y) * (p1->y - p2->y); - dz = (p1->z - p2->z) * (p1->z - p2->z); + if (mflag) { + dx = abs(p1->x - p2->x); + dy = abs(p1->y - p2->y); + dz = abs(p1->z - p2->z); + } else { + dx = (p1->x - p2->x) * (p1->x - p2->x); + dy = (p1->y - p2->y) * (p1->y - p2->y); + dz = (p1->z - p2->z) * (p1->z - p2->z); + } return dx + dy + dz; }