C2pm - 颜色到像素映射
1 分•作者: Yukesh_J•17 天前
我制作了一种名为 C2PM(颜色到像素映射)的小型实验性图像格式。
它不按线性顺序存储像素,而是存储:<p>颜色 → 该颜色出现的像素索引列表<p>所以它本质上是对图像数据应用了倒排索引。
它并非旨在与 PNG/JPEG 竞争——仅仅是对替代表示方式的探索。<p>为什么要这样做?<p>给定颜色的所有像素的 O(1) 查找<p>对像素艺术工具、调色板操作、区域遮罩很有趣<p>对某些“颜色 = 类别”的计算机视觉任务有用<p>可内省的结构(易于分析颜色分布)<p>它不是什么:<p>未压缩<p>未针对一般摄影优化<p>不适用于流媒体/实时使用<p>v1 纯粹是结构性的且无损的<p>实现:<p>用 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/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/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://github.com/yukeshj2006/C2PM-Color-to-Pixel-Map-Image-Format-v1