{"by":"aaronestrada","descendants":0,"id":48419065,"score":35,"text":"This is an upgrade of a tool I created 15 years ago in Python to learn OOP and solve some inadequacies in the HDR stacking tools I could find at the time. The problem was, none of them were really &quot;batch friendly&quot;. None of them properly preserved the metadata I wanted them to stuff into the output file. There were probably some other reasons also, I just can&#x27;t remember them now.<p>It got the job done, but was very slow. Python was what I knew at the time and even with NumPy, I was limited in the speed I could squeeze out of it. (I also made some very specific, conscious, architectural choices to be extra frugal with RAM, which impacted performance further.)<p>This new version is <i>SUBSTANTIALLY</i> faster than the old one. This time around the exercise was more about having some fun in Lisp using an AI agent REPL skill I created and exploring SIMD in SBCL via the built-in sb-simd library.<p>It uses LibRaw (via its C API wrapper and CFFI) for reading and and a custom multi-threaded pure Lisp implementation of (a subset) of OpenEXR I created for writing the output files. The threading helps speed up the otherwise expensive deflate based codec and goes a long way towards speeding up the end-to-end pipeline. The core processing &#x2F; compositing logic is pure Lisp.<p>Cool features:<p>* Buffer parallel (threaded) LibRaw reads<p>* Frugal use of memory (RAW read as 16 bit INT and is only upcast to float during actual stacking)<p>* AVX2 acceleration of 16 bit INT up-cast and HDR stacking loop<p>* Threaded OpenEXR writes<p>* EXIF to EXR metadata preservation of the &quot;center&quot; exposure bracket, which essentially forwards meaningful telemetry regarding the radiometric &quot;reality&quot; of the scene when it was photographed downstream to subsequent consumers.<p>You can learn more about it and the &quot;algorithm&quot; it uses from the repo. The math for HDR stacking is really very simply if you know basic compositing and understand how digital camera sensors work.","time":1780697832,"title":"Show HN: I created a RAW to HDRI stacker in (mostly) Common Lisp","type":"story","url":"https://github.com/IBL-tools/rawtohdri"}