修正色调排序

This commit is contained in:
2024-11-15 11:58:54 +08:00
parent bddb184c78
commit cc5471284e
2 changed files with 41 additions and 7 deletions

View File

@@ -13,6 +13,12 @@ type RGB struct {
R, G, B int
}
// 根据每个聚类中心包含的颜色数量进行排序
type cluster struct {
center RGB
count int
}
// 计算两个 RGB 颜色的欧氏距离
func distance(c1, c2 RGB) float64 {
return math.Sqrt(float64((c1.R-c2.R)*(c1.R-c2.R) + (c1.G-c2.G)*(c1.G-c2.G) + (c1.B-c2.B)*(c1.B-c2.B)))