Abstract
Standard sRGB-JPEG images are widely used due to their compatibility and small file size, but they undergo non-linear processing that discards the original linear RAW sensor data essential for many computer vision tasks. This paper introduces a method to embed a compact 64 KB metadata payload into a standard JPEG file, enabling the reconstruction of the original RAW data with over 99.7% accuracy. By modeling the camera's internal Image Signal Processor (ISP) as a reversible pipeline and utilizing a modified breadth-first octree for efficient gamut mapping, the proposed approach maintains full JPEG compatibility while providing high-fidelity RAW information for scientific and computational photography applications.
Introduction
Most digital cameras convert high-precision RAW sensor data into 8-bit sRGB JPEGs to optimize for human viewing and storage. This "photo-finishing" process involves non-linear tone mapping, color space transformations, and gamut mapping. While visually appealing, these transformations are problematic for computer vision algorithms—such as photometric stereo, deblurring, and light measurement—that rely on the linear relationship between pixel intensity and scene radiance.
Existing solutions often require massive RAW files (25MB+), specialized software, or bulky sidecar files. This research addresses the challenge by creating a "self-contained" JPEG that stores the necessary parameters to invert the ISP pipeline within the image's own metadata.
Methodology: Reversing the ISP Pipeline
The core of the approach is treating the camera's ISP as a reversible sequence of operations. To reconstruct RAW data from an sRGB input, the system estimates and inverts four primary components: inverse tone mapping, white balance, color space transformation, and gamut mapping.
Inverse Tone Mapping and Color Correction
The method uses spline fitting to linearize the non-linear brightness curves (inverse tone mapping). It then estimates the matrices required to map sensor-specific colors back from the standard sRGB space (color correction and white balance).
Efficient Gamut Mapping via Octree Partitioning
The most challenging step is inverting gamut mapping, which handles how the camera "squeezes" out-of-gamut colors into the sRGB range. To model this complex mapping within a strict 64 KB metadata limit, the authors introduced a Modified Breadth-First Octree.
Unlike standard depth-first octrees, the breadth-first approach allows for precise control over the number of control points (bins). It adaptively samples more points in regions with high color density and fewer in sparse regions. This ensures that the most critical mapping data is preserved within the tiny storage budget.
Metadata Embedding
The parameters are stored in the JPEG's COM (Comment) segment. A bit-stuffing technique is employed to avoid null characters (0x00), ensuring the file remains a valid, standard-compliant JPEG that can be opened by any image viewer.
Results and Applications
The method was evaluated on several datasets, including RAISE and camera-specific sets from Canon, Nikon, and Sony. The reconstructed RAW images achieved an average error of less than 0.3% (RMSE ~0.002). The 64 KB overhead represents a negligible increase (approx. 0.6%) in file size for high-quality JPEGs.
Beyond reconstruction accuracy, the authors demonstrated that tasks like white balance correction and image deblurring perform significantly better when using the reconstructed RAW data compared to processing the original sRGB pixels directly.
Conclusion and Future Work
This work provides a practical bridge between the convenience of JPEG and the utility of RAW data. While highly effective, the method is limited by pixel clipping (where saturated data is lost) and may require adaptation for modern smartphone "computational photography" which uses local, non-global tone mapping. Future research may explore bi-directional optimization to improve both the forward and backward ISP mappings.
Summary updated