Projects
C2PM Color-to-Pixel Map Image Format
C2PM (Color-to-Pixel Map) is an experimental image format designed to explore alternative ways of representing raster images by inverting the traditional pixel-centric model.
Instead of storing data as pixel to color, C2PM uses a color-centric index where each color maps to a list of pixel indices.
Each unique RGB color acts as a key mapped to all pixel positions where that color appears. This structure enables constant-time color-based queries and makes the format suitable for analytical and experimental workflows rather than general image compression.
Motivation
Most image formats are optimized for spatial locality and visual decoding. C2PM was created to explore what happens when image storage is optimized for color analysis instead of rendering.
The project investigates how inverted indexing affects storage and access patterns, the tradeoffs between decoding speed and query efficiency, and the limits of non-spatial image representations.
Design Overview
Each unique 24-bit RGB color is stored once. For every color, C2PM stores a list of pixel indices ranging from 0 to width x height - 1.
The file layout consists of a header containing a magic identifier, image width, height, and color count, followed by sequential color entries with associated index arrays.
This design allows direct access to all pixels of a given color without scanning the entire image.
Strengths
C2PM provides O(1) access to all pixels of a specific color and is efficient for color-based analysis, selection, and replacement.
It is well-suited for sparse-color images, segmentation masks, and pixel-art-like data, with a clear separation between color data and spatial layout.
Limitations
The format has high storage overhead due to index lists and slower decoding compared to spatial formats.
It is poorly compatible with traditional spatial compression techniques and is not intended for general-purpose image storage or display.
Implementation
C2PM is implemented in C using binary file I/O and custom data structures.
The implementation prioritizes correctness, clarity, and experimentation over aggressive optimization and serves as a foundation for future variants with compression and hybrid layouts.
Current Status
C2PM is an ongoing experimental project. Planned future work includes index compression using delta and variable-byte encoding, adaptive index bit-width based on resolution, and optional hybrid spatial metadata for faster reconstruction.
Tech Stack
C, Binary File I/O, Data Structures, Systems Design
GitHub Repo