C2pm-颜色到像素映射

1作者: Yukesh_J4 天前原帖
我制作了一种小型实验性图像格式,称为C2PM(颜色到像素映射)。 它不是以线性顺序存储像素,而是存储: 颜色 → 该颜色出现的像素索引列表 因此,它本质上是应用于图像数据的反向索引。 这并不是为了与PNG/JPEG竞争——只是对替代表示法的一种探索。 为什么要这样做? - 对于给定颜色的所有像素,查找时间为O(1) - 对于像素艺术工具、调色板操作、区域遮罩等非常有趣 - 对于某些计算机视觉任务(其中“颜色 = 类”)非常有用 - 结构可自省(易于分析颜色分布) 它不是: - 不压缩 - 不针对一般摄影进行优化 - 不适合流媒体/实时使用 - v1完全是结构性的且无损 实现: 使用C语言编写。 二进制格式:头部 + (RGB,计数,索引)。 包括编码器 + 解码器(PNG ↔ C2PM)。 MIT许可证。 仓库地址: https://github.com/yukeshj2006/C2PM-Color-to-Pixel-Map-Image-Format-v1
查看原文
I made a small experimental image format called C2PM (Color-to-Pixel Map). Instead of storing pixels in linear order, it stores:<p>color → list of pixel indices where that color appears<p>So it’s essentially an inverted index applied to image data. Not meant to compete with PNG&#x2F;JPEG—just an exploration of alternative representations.<p>Why bother?<p>O(1) lookup for all pixels of a given color<p>Interesting for pixel-art tools, palette manipulation, region masks<p>Useful for certain computer-vision tasks where “color = class”<p>Introspectable structure (easy to analyze color distribution)<p>What it’s not:<p>Not compressed<p>Not optimized for general photography<p>Not practical for streaming&#x2F;real-time use<p>v1 is purely structural and lossless<p>Implementation:<p>Written in C. Binary format: header + (RGB, count, indices). Includes encoder + decoder (PNG ↔ C2PM). MIT License. Repo: https:&#x2F;&#x2F;github.com&#x2F;yukeshj2006&#x2F;C2PM-Color-to-Pixel-Map-Image-Format-v1