2 ms·
C2PM(Color to Pixel Map)
C2PM (Color-to-Pixel Map) is a new image representation format developed by Yukesh J.
It stores image data using an inverted index structure rather than traditional pixel-linear ordering.
In C2PM, each unique RGB color is stored once, followed by a list of all pixel positions where that color appears.
Formally, the format maps:
Color → {Pixel Indices}
This structure enables several properties:
Design Characteristics
Lossless representation of exact RGB images
Direct access to all pixels of a given color without scanning the entire image
Deterministic binary layout (header + entries + index arrays)
Simple linear decoding algorithm suitable for tooling or analysis
Potential Applications
Pixel-art workflows
Palette-based editing systems
Color-region mask generation
Image segmentation and inverse indexing research
Developer tooling that benefits from color-centric access patterns
Current Scope
C2PM is not a replacement for existing compressed formats (PNG, JPEG) and is not optimized for general photography or real-time rendering.
It is intended as an alternative representation model focused on color organization rather than storage minimization.
Specification & Implementation
A reference implementation (encoder + decoder in C) and a description of the binary layout are available here:
https://github.com/yukeshj2006/C2PM-Color-to-Pixel-Map-Image-Format
Feedback on structural design, potential optimizations, or use-cases is welcome.
- HelloNurse 10mo agoWhy do you think the mentioned "color-centric" image processing operations deserve a specialized file format, rather than building and using a transient index in memory when it is useful? Do you have some special use case in mind? Any interactive application, for instance, can be expected to render the image to the screen (repeatedly); any GPU use for texture mapping needs pixels sorted by location, regardless of whether pixel values are palette indices or explicit colours; many image processing tasks, like segmentation and drawing, need efficient access to pixels at arbitrary locations or near already processed locations.
- Yukesh_J 10mo agoThanks for asking, C2PM isn’t meant to replace raster formats it serves as an intermediate format for workflows where users repeatedly operate on color groups (palette swaps, region recoloring, mask generation, etc). In a standard image, every color swap requires rescanning all pixels. In C2PM, the color to pixel index is already stored, so repeated swaps or multi-color operations become O(1) per color instead of O(P) per operation. It’s designed for tools where color groups matter more than spatial order, not for real-time display or GPU textures.