About the project
KARC – an image codec, built from scratch
KARC stands for “Kotsch Adaptive Region Codec” – a content-adaptive image compression method, written entirely in Python and running CPU-only. This page explains how it came to be, what it can do and where its limits lie.
The path
From research to a working codec
KARC was not assembled from a finished library. Every building block – colour transform, transform, quantisation, entropy coding – was implemented from scratch and secured with unit tests. Three steps led there.
-
1
30 research sources
The starting point was 30 downloaded research sources on image compression, transform coding and perceptual quality. They formed the basic understanding of which ideas are worth pursuing – and which trade-offs modern codecs make.
-
2
Multi-agent design (111 agents)
Building on the sources, the method was designed in a multi-agent process with 111 agents. Different agents worked in parallel on sub-questions – from region classification to entropy modelling – and consolidated their decisions into one consistent overall design.
-
3
From-scratch implementation with unit tests
The design was implemented from scratch across 10 modules – in pure Python with NumPy, OpenCV and Pillow. Every module is backed by unit tests: the colour transform is bit-exactly reversible, the DCT matches OpenCV, the rANS coder is bit-exact, and the full codec roundtrip is tested.
Structure
Ten modules, all with tests
KARC is split into ten clearly delineated areas. Each area has its own responsibility and its own tests.
- 01Colour transform (YCoCg-R)
- 02Segmentation & classification
- 03Transform (DCT / PLANE)
- 04Quantisation
- 05Learned models (tables)
- 06Context & entropy (rANS)
- 07Rate control
- 08Bitstream format
- 09Integration
- 10Evaluation & tests
An honest look
What KARC can do – and what it cannot
The honest conclusion: KARC beats JPEG and JPEG 2000, but trails WebP and AVIF. The full numbers, including BD-PSNR and BD-SSIM, are in the test reports.
Beats the standards
In a benchmark on 20 Kodak images, KARC beats the classic standards: against JPEG (optimize=True) it wins the PSNR-based BD-rate on 18 of 20 images; against JPEG 2000 (OpenJPEG, default settings) on all 20.
Behind WebP and AVIF
Against the modern codecs WebP and AVIF, however, KARC clearly falls behind and wins none of the 20 images there. That is expected – these codecs are the result of years of industrial optimisation.
Reference implementation
KARC is also a pure-Python reference implementation, CPU-only. It is built to demonstrate the idea cleanly and transparently – not for production-grade speed.
Outlook
Where it could go
Perceptual masking
Steer bits more deliberately to where the eye notices errors – and save them where structure masks them. This is the most immediate lever for better SSIM scores.
Learned bases / VQ
Beyond the fixed DCT: learned transform bases or vector quantisation that adapt to typical image content better than a generic frequency basis.
Who
Behind KARC
KARC was developed by Arthur Kotsch together with Claude – in 2026. It is a research and learning project with the goal of truly understanding a complete compression method by building and testing it from scratch.