
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
github.com/philoj/tree-palette
An indexed color palette implementation in Go on top of a k-d tree for fast color lookups. Also rank a palette against an image to identify prominent colors.
kd-tree implementation adapted from: kyroy/kdtree
go get github.com/philoj/tree-palette
import "github.com/philoj/tree-palette"
m := NewPalettedColorModel([]color.Color{
// list of colors in the palette
}, false // ignore alpha values
)
equivalentColor := m.Convert(someColor)
Start by implementing treepalette.PaletteColor
and treepalette.Color
interfaces:
// Color express A color as A n-dimensional point in the RGBA space for usage in the kd-tree search algorithm.
type Color interface {
// Dimensions returns the total number of dimensions(3 for RGB, 4 for RGBA).
Dimensions() int
// Dimension returns the value of the i-th dimension, say R,G,B and/or A.
Dimension(i int) uint32
}
// PaletteColor is A Color inside an indexed color palette.
type PaletteColor interface {
Color
// Index returns palette index of the color
Index() int
}
Or use included implementations treepalette.ColorRGBA
and treepalette.IndexedColorRGBA
respectively:
// Unknown color
c := treepalette.NewOpaqueColor(121,201,10)
// Palette colors
p1 := treepalette.NewOpaquePaletteColor(255, 130, 1, 2, "DARK ORANGE") // R,G,B, unique-id, name
p2 := treepalette.NewOpaquePaletteColor(1, 128, 181, 11, "PACIFIC BLUE")
// Create palette
palette := treepalette.NewPalette([]treepalette.PaletteColor{p1,p2}, false)
// Equivalent color
equivalent := palette.Convert(c)
// Convert an image.Image
palettedImage := palette.ApplyPalette(img)
// Rank the palette against all the pixels in an image.Image
colors, colorCount := palette.Rank(img)
fmt.Printf("Most frequent color is %s. It appears %d times.", colors[0], colorCount[colors[0].Index()])
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.