Confreaks
Solving an overdetermined system of linear equations via pseudoinverse matrices allows basic spreadsheet cells to invert camera response curves and reconstruct high dynamic range photographs.
AI-assisted summary of !!Con 2017: HDR Photography in Microsoft Excel?! by Kevin Chen — original source. Check the original for full context.
Source published:
Key ideas
- Kevin Chen demonstrated that foundational high dynamic range (HDR) photography algorithms can be executed entirely within Microsoft Excel by modeling the reconstruction as an overdetermined system of linear equations. (0:00)
- Because camera sensors exhibit nonlinear response curves, merging bracketed exposures requires recovering the inverse response function using a Moore–Penrose pseudoinverse. (3:08)
- Transforming Excel into a functional raster display using square cells and conditional formatting across eight exposure sheets consumed approximately 13 gigabytes of RAM. (7:06)
- The final radiance calculation required writing an expansive formula in Sublime Text, successfully recovering blown-out stained-glass window details inside Excel. (9:59)
Detailed notes
## Background Presented by Kevin Chen at !!Con 2017 and published on YouTube by Confreaks on May 18, 2017, this talk demonstrates how to build an end-to-end High Dynamic Range (HDR) photography pipeline entirely inside Microsoft Excel. As detailed in the video description, Chen explains the foundational linear algebra behind HDR imaging algorithms—specifically solving systems of linear equations—and jokingly frames the spreadsheet implementation as the ultimate enterprise-ready alternative to specialized software.
## TL;DR Chen demonstrates how high dynamic range photography merges bracketed exposures by resolving the camera's nonlinear response curve into a system of linear equations ($Ax = b$). Because Excel lacks native support for non-square matrix pseudoinverses, he uses an algebraic decomposition to recover the inverse camera response function. He then imports eight exposure brackets into separate spreadsheet tabs, turning the cell grid into a functional raster display using conditional formatting gradients. After assembling a massive formula drafted in Sublime Text to compute a weighted radiance map, Excel successfully computes and renders a composite HDR image that restores blown-out details in church stained-glass windows.
## Atmosphere & style The presentation is a hilarious blend of deadpan technical comedy and genuine computational ingenuity, playing straight into corporate office satire. Chen maintains an earnest, lighthearted delivery as he juxtaposes complex camera sensor physics with vintage WordArt, 13-gigabyte RAM spikes, and absurdly oversized spreadsheet formulas. Watching it feels like a joyful hackathon stunt where rigorous image science meets deliberate software misuse, culminating in a triumphant, applause-filled payoff when the spreadsheet actually renders a readable photograph.
## Bulletin - [00:00](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=0s) Kevin Chen demonstrated that foundational high dynamic range (HDR) photography algorithms can be executed entirely within Microsoft Excel by modeling the reconstruction as an overdetermined system of linear equations. - [03:08](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=188s) Because camera sensors exhibit nonlinear response curves, merging bracketed exposures requires recovering the inverse response function using a Moore–Penrose pseudoinverse. - [07:06](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=426s) Transforming Excel into a functional raster display using square cells and conditional formatting across eight exposure sheets consumed approximately 13 gigabytes of RAM. - [09:59](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=599s) The final radiance calculation required writing an expansive formula in Sublime Text, successfully recovering blown-out stained-glass window details inside Excel.
## Key takeaways - [00:00](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=0s) High dynamic range photography resolves scenes with extreme highlight and shadow contrasts by capturing and blending multiple bracketed exposures. - [00:00](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=0s) The fundamental principle of reciprocity dictates that doubling the shutter duration admits twice as much light into the camera. - [01:46](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=106s) Digital cameras exhibit nonlinear response curves, meaning doubling exposure time does not simply double stored JPEG pixel values. - [01:46](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=106s) The implementation relies on foundational 1990s research by Debevec and Malik from UC Berkeley on recovering high dynamic range radiance maps. - [03:08](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=188s) The camera's response can be expressed mathematically as g(Z) = ln(radiance) + ln(Δt), where g represents the unknown inverse response function. - [03:08](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=188s) Evaluating sample pixels across multiple shutter speeds forms an overdetermined system of linear equations Ax = b. - [03:08](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=188s) Because Excel lacks native non-square matrix inversion, the Moore–Penrose pseudoinverse was implemented using the algebraic expansion (A^T A)^-1 A^T. - [07:06](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=426s) Excel was turned into a raster display by resizing cells into small squares and applying color gradient conditional formatting over the raw integer data. - [07:06](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=426s) Handling eight sheets of conditionally formatted raw image data required 13 gigabytes of RAM, prompting a system reboot. - [07:06](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=426s) To keep the linear system computationally feasible, Chen sampled a targeted subset of pixel coordinates across the image rather than the entire frame. - [09:59](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=599s) The final tone-mapping formula required external drafting in Sublime Text because it was too large for Excel's standard formula bar. - [11:10](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=670s) The final composite successfully reconstructed stained glass imagery depicting Jesus on the cross that was completely blown out in standard exposures.
## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=0s) The Premise: High Dynamic Range in Microsoft Excel
Kevin Chen introduces a classic photography dilemma: taking a picture where highlights are blown out or shadows are crushed, obscuring the detail in the scene. While photographers solve this by shooting bracketed exposures and fusing them using a high dynamic range (HDR) algorithm, Chen connects this to corporate office culture, deadpanning: “And as any business person will tell you the right platform to implement your Solutions is always Microsoft Excel.” He concludes that the only sensible course of action is building an HDR pipeline inside a spreadsheet.
He breaks down the intuitive idea of merging pictures: take two photographs of the same scene where one is brighter than the other, cut out the blown-out portions of the brighter image, and paste in the preserved details from the darker exposure. However, to seamlessly blend them, the pasted darker areas must be brightened up to match the surrounding scene. Doing so requires knowing exactly how much to brighten the pixel values, which leads into camera mechanics.
- Camera shutters open and close to admit light onto the sensor or film. - The fundamental rule of exposure discussed is the principle of reciprocity: keeping the shutter open twice as long allows twice as much light into the camera.
[01:46](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=106s) Camera Response Curves and Nonlinearity
At first glance, doubling the exposure time might seem like a simple arithmetic operation where every pixel value in the image file can simply be multiplied by two. However, digital cameras exhibit nonlinearity: the sensor and onboard image processing pipeline do not map incoming light directly to pixel values on a purely proportional scale. A graph of the camera response curve demonstrates that stepping up the light on the horizontal axis by equal increments yields varying changes in the resulting output JPEG numbers. As Chen points out, “two times more light doesn't mean you're going to get a twice as big number inside your file.”
To combine exposures correctly, one must deduce the camera’s internal response curve. Chen reassures the audience that this problem was solved in the 1990s by researchers at UC Berkeley (referencing the foundational Debevec and Malik paper on recovering high dynamic range radiance maps). However, their paper relies heavily on rigorous mathematical equations, which Chen jokes would bore corporate business stakeholders. To fix this, he frames the solution with emojis, diagrams, and corporate buzzwords, remarking that “now there's a lot of synergy right now.”
```mermaid flowchart LR accTitle: Camera Response Nonlinearity accDescr: Diagram showing how physical scene radiance through exposure time maps nonlinearly into stored digital values.
subgraph Scene["Physical World"] L["Light / Scene Radiance (E)"] DeltaT["Shutter Time (Δt)"] L --> Exposure["Exposure (E × Δt)"] DeltaT --> Exposure end
subgraph Camera["Camera Pipeline"] Exposure -->|"Nonlinear Response F(E × Δt)"| JPEG["Digital Pixel Value (Z)"] end
subgraph Recovery["Inverse Mapping"] JPEG -.->|"Inverse Function g(Z)"| Exposure end ```
[03:08](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=188s) Formulating the System of Linear Equations
To explain how the unknown response curve is reconstructed without intimidating equations, Chen analyzes a single roof pixel across three photos taken at doubling shutter speeds.
- The first pixel starts with a digital brightness value of 31. - Doubling the light for the second shot does not yield 62, but an arbitrary value like 78 due to the nonlinear response. - Doubling the light again for the third shot similarly results in a non-doubled value.
Plotting these data points reveals the relative amount of light separating those specific digital levels. While a single pixel location only provides a few sample points, repeating this measurement across multiple distinct pixel locations throughout the image fills in the gaps, ultimately reconstructing the entire inverse response function, denoted as $g$.
Chen formalizes the relationship mathematically. The digital pixel value $Z$ is generated by an unknown function $f$ operating on exposure, which equals scene radiance (brightness) multiplied by shutter duration ($\Delta t$):
$$Z = f(\text{radiance} \times \Delta t)$$
Because the digital values $Z$ are known and the physical radiance is unknown, the goal is to invert $f$. Defining $g = f^{-1}$ produces an equation for each pixel $i$ in each exposure $j$:
$$g(Z_{ij}) = \ln(\text{radiance}_i) + \ln(\Delta t_j)$$
Chen explains that this is not merely a single equation: “now this actually this equation down here I've written it as one equation but it's actually a template that can be used to create many equations”. Evaluating this template for every sampled pixel across all exposures forms an overdetermined system of linear equations $Ax = b$. Setting up and solving this requires linear algebra. To invert the non-square matrix $A$, a Moore–Penrose pseudoinverse (denoted with a plus superscript) is necessary. Because Microsoft Excel only provides standard matrix inversion functions (`MINVERSE`) for square matrices, Chen searches the web for a workaround, discovering an algebraic decomposition on a site called *Math Asse*:
$$(A^T A)^{-1} A^T$$
He jokes to the audience: “and you know that this equation is legit because it comes from a website called math ass”.
[07:06](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=426s) Building the Spreadsheet Image Engine
With the mathematical formulation established, Chen transitions into Microsoft Excel to construct the solver and visualizer. Raw pixel intensity numbers are pasted into cells across eight sheets corresponding to eight bracketed exposures. To make these grids of raw integers visually intelligible, Chen relies on Excel's conditional formatting, assigning a color gradient from dark to light across the cell ranges and resizing the cells into tiny squares. Zooming out transforms the spreadsheet into a functioning raster display. Chen humorously summarizes the milestone: “so that's the first step to Turning Excel into an image editor.”
Running eight full sheets of conditionally formatted pixel cells quickly consumes 13 gigabytes of RAM. Staying in character as an “obedient Microsoft customer,” Chen reboots his computer to clear memory before proceeding.
- Rather than calculating every pixel across the large images, he selects a subset of sample coordinates across the scene to keep the system tractable. - To document his spreadsheet logic, he uses WordArt instead of regular comments, lamenting that modern Excel lacks the classic styles: “these are all really boring Styles um you know I want like the rainbow one and like the 3D one um but fortunately fifth grade me had the foresight to save one of each type of word art into this file.” - An extraction sheet aggregates the chosen pixel coordinates across all eight exposures, arranging the values into organized columns. - The matrix sheet, zoomed out to 10%, visualizes the giant $A$ matrix by conditionally formatting non-zero values in red to display the matrix structure.
```mermaid flowchart TD accTitle: Excel HDR Processing Pipeline accDescr: The workflow used inside Microsoft Excel to sample pixels, build the A matrix, compute the response function, and output an HDR image.
subgraph DataPrep["1. Exposure Grid & Sampling"] P["8 Bracketed Exposures<br>(Pixel values in cells)"] --> CF["Square Cells + Conditional Formatting<br>(Visual raster preview)"] CF --> Samp["Coordinate Sampling Sheet<br>(Select representative points)"] end
subgraph LinearAlgebra["2. Linear System & Response Curve"] Samp --> MatA["Matrix Assembly Sheet<br>(Sparse A Matrix highlighted in red)"] MatA --> PInv["Pseudoinverse Calculation<br>((A^T A)^-1 A^T)"] PInv --> GFunc["g Function Recovery<br>(Inverse camera response curve)"] end
subgraph Rendering["3. Final Radiance Map"] GFunc --> Subl["Sublime Text Formula<br>(Weighted averaging across 8 shots)"] Subl --> Output["Final Tone-Mapped Canvas<br>(Restored stained-glass detail)"] end ```
[09:59](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=599s) Solving and Tone-Mapping the Final Result
Applying the pseudoinverse formula directly within Excel's formula bar extracts the vector representing the discrete points of the $g$ response function. With the camera response function calibrated, the final radiance map must be reconstructed and displayed. The Excel formula required to map each cell’s pixel value through the recovered $g$ function, normalize by exposure duration, and apply a weighted average across all eight exposures grew too unwieldy for the spreadsheet's native formula bar, forcing Chen to compose it in Sublime Text.
Chen pastes the massive formula into the master sheet. The computation freezes Excel for approximately 30 seconds before rendering the finished composite. The resulting image successfully recovers both shadows and highlights, clearly revealing stained-glass artwork in bright church windows that was completely blown out to pure white in the standard exposures.
[11:10](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=670s) Reconstructed Stained Glass and Endorsements for Microsoft Office
Kevin points to the final high dynamic range image rendered inside the spreadsheet to show that the technique worked. Looking closely at the previously blown-out church window, the newly recovered detail reveals stained glass artwork depicting Jesus on the cross alongside imagery in the neighboring windows. Because the algorithm successfully captured and combined the full range of exposures, the mission is officially complete. Playing into the running joke about enterprise tools, Kevin notes that corporate users everywhere can celebrate the victory: “And so this means we’re successful and our business people are so happy now because they can uninstall Photoshop and only use Microsoft Excel.”
Wrapping up the presentation to audience laughter, Kevin makes a humorous parting request to anyone who enjoyed watching an image processing pipeline built inside a grid of cells. He invites attendees to visit his website, navigate over to his LinkedIn profile, and submit a very specific recommendation: “So that’s all I have, if you like this please go to my website, click on LinkedIn, and don’t forget to endorse me for Microsoft Office.” The talk concludes with a warm round of applause from the audience.
## Notable quotes > [01:46](https://www.youtube.com/watch?v=bkQJdaGGVM8&t=106s) two times more light doesn't mean you're going to get a twice as big number inside your file. — Kevin Chen
## Mentioned Kevin Chen, Microsoft Excel, !!Con, Confreaks, Columbia University, UC Berkeley, Debevec and Malik, Math Asse, Sublime Text, Adobe Photoshop, Microsoft Office, LinkedIn, WordArt
## Video description HDR Photography in Microsoft Excel?! by Kevin Chen
Have you ever taken a photo with areas that are too bright or too dark? As any photographer will tell you, high dynamic range photography is the right way to solve your problem. And, as any businessperson will tell you, Microsoft Excel is the right platform to implement your solution.
In this talk, I’ll explain the algorithm from one of the foundational papers about HDR imaging — no prior image processing knowledge required. Turns out, it’s just a system of linear equations! So, obviously, the next step is to implement HDR in a spreadsheet. Because we can. The end result reveals how this complicated-sounding algorithm boils down to a few simple ideas.
Kevin is an amateur photographer and Microsoft Office enthusiast. He also studies computer science at Columbia University.
[Source](https://www.youtube.com/watch?v=bkQJdaGGVM8)