|
|
Log in / Subscribe / Register

Shoot two exposures at once with Magic Lantern

By Nathan Willis
July 23, 2013

Developers from the Magic Lantern (ML) project have enabled a previously undiscovered capability in high-end Canon digital cameras: the ability to record images and video at two different exposure levels in every frame. Post-processing is required to blend the exposures into a seamless image, but the result is a single shot that covers essentially the entire range of brightness that the camera sensor is capable of seeing. That means high contrast scenes are visible without sensor noise, without motion artifacts, and without stacking multiple shots in a high dynamic range (HDR) blending program.

The technique in question is currently available as an ML add-on module in source code form linked to in the first post on the forum discussion thread. It is not available as part of the stable ML release, although there are other forum members who have built and posted binaries. A separate utility (currently Windows only, but usable with Wine) is required to convert the camera output into a standard image or video file.

Sensors and sensibility

ML began as an effort to implement extra features for Canon's EOS 5D Mark II cameras—specifically, features to improve the camera's usability when shooting video. Subsequently, the project has taken on creating builds for other camera models with similar internal chip architectures, such as the 5D Mark III and the 7D, and developers have crafted modules that extend the cameras' functionality in ways beyond user interface improvements. The 5D Mark III, in particular, has gained some significant functionality through the ML team's work. For example, back in May the project implemented a raw video recording mode that allowed users to film uncompressed video (at 24 frames per second) at greater-than-1080p resolutions.

Canon's factory firmware shoots video at 1080p, tops, in H.264 compressed format. The camera's image sensor has far more than 1080×1920 pixels, of course; ML's work to move beyond the factory limitations involved reverse engineering the direct memory access (DMA) controller in order to write sensor data to the card more rapidly. As part of that process, ML began mapping out the camera's registers. Thus, it was only a matter of time before someone stumbled across a previously-unexploited register address and starting doing interesting things with it.

ML developer Alex "a1ex" Dumitrache discovered one such register on the chip that controls the CMOS sensor's "ISO rating" (which emulates the light sensitivity of different film speeds). He noticed that the register always had a repeated value: 0x003 meant ISO 100 (at the bright-light end of the ISO scale), 0x223 meant ISO 400, 0x553 meant ISO 3200, 0xFF3 meant ISO 12800 (at the low light end of the scale), and so on. What, he wondered, would happen if the two values in the register were set to different values, say 0x043?

The answer, it turns out, is that half of the sensor's scan lines will be read at ISO 100, and the others at ISO 1600. These lines are interlaced in pairs, with lines 0 and 1 at one ISO setting followed by 2 and 3 at the other setting, and so forth. This pairing is because the sensor's red, green, and blue pixels are arranged in pairs of lines; a two-by-two square of four pixels is required to get a full RGB triple for any one sample point. The reason that this interlaced setting is possible is that the 5D Mark III has an eight-channel sensor readout, where most Canon cameras have a four-channel readout. The 7D model also has an eight-channel sensor readout, so Dumitrache was also able to perform the dual-ISO sensor setting on that camera. So far, those are the only two camera models to support the feature.

Dumitrache wrote up the finding in a white paper [PDF] that goes into considerable detail on what happened next. Saving the half-and-half exposure frame as a file was no trouble, but it took far more work to figure out how best to interpolate the data in a meaningful way. If the two ISO settings are significantly different (as they presumably would be for the stunt to be worth doing), then an object that looks properly-exposed in one would look way too bright or too dark in the other. The darker exposure has less sensor noise, but the brighter exposure has better saturation and color fidelity. In addition, the two exposures are recorded with mismatched white points and black levels, and despite the nice round numbers of ISO ratings, the CMOS image sensor does not respond in simple ways to exposure changes.

He eventually worked out an algorithm to mix pixels from both exposures in the image midtones, and transition smoothly to a single exposure each for the shadow and highlight areas. This initially meant that highlights and shadows were at half the vertical resolution of the midtone parts of the image, with existing lines doubled to fill in for the missing ones. Naturally, this line doubling can create image artifacts (especially in areas like high-contrast edges).

Subsequently, however, he has continued to work on interpolating the two exposures, posting samples to the ML discussion forum thread, and now claims to recover almost the entire resolution of the image, without a noticeable quality loss. There are a variety of sample images in the discussion thread that showcase how the technique compares to a single-ISO exposure. A particularly good example is Jay Birch's photo. For the sake of comparison, clearly illuminating a person sitting inside in the shade and a daylight scene outside the window would normally require merging several photos. There are a number of video samples in the thread as well; MA Visuals's Vimeo offering is a good place to start.

Usage and impact

For now, Dumitrache's command line conversion tool cr2hdr is required to convert the dual-ISO frames into Digital Negative (DNG) format. The tool is licensed as GPLv2+, but it is still under development. So far the blending algorithm is hardcoded in; as he makes adjustments he updates the posted version of the file, but there are no user-tweakable switches.

The frames are recorded to the storage card with the .CR2 file extension used by the cameras for normal shots, but they obviously deviate quite a bit from the "correct" CR2 format. Once converted, stills can be opened in any raw photo tool that supports DNG, which includes most of the free software applications (such as UFraw, Rawstudio, or Darktable). Video editing may be trickier; at least, no one on the ML forum appears to have attempted any dual-ISO video on Linux.

Using the dual-ISO module on the camera is straightforward: one sets the "base" ISO on the camera's physical dial, and the second (or "recovery") ISO in the dual-ISO menu added by the module. The technique does not work with the camera's "Auto ISO" mode. But the big plus is that a shot taken in dual-ISO mode is captured all at once. There are other ways to take two exposures and blend them together, but they come with serious trade-offs.

For example, ML can automatically "bracket" shots: record two sequential frames at different exposures, so that they can then be blended together with a software tool like Hugin or Luminance HDR. ML can even record "HDR video," which it does by taking alternate frames at different exposure levels, then merging them together in pairs.

The drawback of both of these options is that the two exposures merged are taken at different times—only slightly different times, admittedly, but still different. Blending them when they are not perfectly aligned costs image detail. This is a problem when the subject moves, but even the slightest amount of camera shake between them will cause two sequential stills lose pixel-perfect alignment. Thus, even though the ML dual-ISO shot sacrifices some scan lines in the extreme tones of the image, the two-shot approach loses resolution when the images are merged as well. For video, the problem is even worse, since a moving object will introduce jitter when the sequential frames are merged. There are other products on the market (such as the top-dollar RED digital cinema cameras) that can shoot "HDR video", but they too merge sequential frames.

In addition, Dumitrache contends that the dual-ISO blending algorithm in his command-line tool produces more natural results than merging two bracketed shots anyway. Almost everyone is familiar with the "radioactive" look of poorly-merged HDR conversions; the dual-ISO approach does not suffer from that flaw. In part, Dumitrache is simply confident that his blending algorithm produces nicer results than many tone-mapping alternatives, but the math is different, too: his does not have to blend any overlapping pixels. Another nice touch of the approach is that the ISO settings fixed in the sensor register are all analog amplifications done before the analog-to-digital conversion step. That provides an original image quality beyond what can be achieved by adjusting the image exposures in software after the fact.

The practical questions for interested photographers to ask are when taking a dual-ISO shot makes sense and what settings to use. The 5D Mark III's sensor is reported to have a 14-stop dynamic range (i.e., total light-to-dark range), but any one ISO setting only captures a portion of that. Shooting at ISO 100 grabs almost 11 stops, with higher ISOs performing worse and worse. To get the other three stops missed by ISO 100, Dumitrache recommends shooting a recovery exposure of ISO 1600. At higher speeds, there is not any more dynamic range to squeeze out of the sensor, and there is noticeably worse rendition of the midtones.

As to what pictures to take, there are certainly a handful of obvious scenarios in which a dual-ISO image is sure to result in a better photo than a single exposure (one might note, for instance, that almost all of the sample images in the forum thread involve an interior room next to a bright window). But if the original scene doesn't have 14 stops of dynamic range in it, trying to capture them is overkill. That does not detract from the practical value of this new feature, however: the ML team has come up with a remarkable new feature, one that—so far—no other product has matched, free software or otherwise.

It would be nice to see support for these dual-ISO exposures in the various open source photo and video editing applications, but it is not yet clear how feasible that is. On the one hand, ML is a niche project for aftermarket features only. But on the other, if the ML project keeps up this kind of development, it might not stay a niche project for very long.


to post comments

Shoot two exposures at once with Magic Lantern

Posted Jul 23, 2013 17:56 UTC (Tue) by halla (subscriber, #14185) [Link] (5 responses)

That's a _really_ cool hack... I wonder how long before Canon realizes they can offer it too :-)

Shoot two exposures at once with Magic Lantern

Posted Jul 23, 2013 18:45 UTC (Tue) by yodermk (subscriber, #3803) [Link] (4 responses)

Agreed. ML is amazing; I recently installed it on my 60D and it is a huge improvement.

I had been debating between getting a 6D or a 5D3, but the RAW video hack in May caused me to definitively decide on the 5D3. (Hopefully next month if the Canon Loyalty Program cooperates!) This just adds more sugar to it.

Of course, Canon might pull something to shut it down at some point. They've pretty much said no one should dare try this on the 1D line. Probably too late for them to stop it on the 5D3 but better get that one, because they might lock down the 5D4 more.

OTOH this gives them a nice advantage over Nikon.

Shoot two exposures at once with Magic Lantern

Posted Jul 23, 2013 19:48 UTC (Tue) by halla (subscriber, #14185) [Link] (2 responses)

They'd be crazy to shut this down... A completely free and specific for their hardware R&D department -- and everyone who wants to use it has to give them money. Life doesn't get better!

Shoot two exposures at once with Magic Lantern

Posted Jul 23, 2013 23:18 UTC (Tue) by rahvin (guest, #16953) [Link] (1 responses)

Canon hasn't shown a desire to shut down mods and it's been going on a lot longer than the current crop. There have been community modified firmware's for dozens of different cameras even down to the point and shoot variety going all the way back to some of the first digital camera's canon produced and they've never tried to shut the community down, at least that I'm aware of. It would be trivial for them to implement security measures to shut down the mod'ing but they haven't bothered and I doubt they ever will.

As you said free publicity and R&D along with the ability to declare your warranty void. It's a win-win for them any way you look at it. The only thing I could ever see them limiting was firmware that added features of more expensive cameras, which I don't even think is possible given the hardware differences.

Shoot two exposures at once with Magic Lantern

Posted Aug 22, 2013 8:33 UTC (Thu) by freddyh (guest, #21133) [Link]

[quote]The only thing I could ever see them limiting was firmware that added features of more expensive cameras, which I don't even think is possible given the hardware differences.[/quote]

It is possible for the lower end cameras that lack features like bracketing or flash value lock, as you don't need any specific hardware support for that.
I agree that lots of other features cannot be ported to older/less fancy hw.

Shoot two exposures at once with Magic Lantern

Posted Jul 23, 2013 19:57 UTC (Tue) by n8willis (subscriber, #43041) [Link]

I still wish to go on the record as contending that the 1D comment has been drastically over-interpreted; they asked a marketing person, who gave a snap answer that did not seem informed by either firmware-replacement efforts or by the legality of reverse engineering.

That said, I believe this N-channel sensor readout difference also underscores how superficial the comparison was between the 1Dc and 1Dx -- the comparison that prompted the aforementioned "legal backlash" meme about the 1D.

Nate

Shoot two exposures at once with Magic Lantern

Posted Jul 24, 2013 6:50 UTC (Wed) by kyanh (guest, #28894) [Link] (1 responses)

Nothing similar in my Pentax world ;)

Shoot two exposures at once with Magic Lantern

Posted Jul 25, 2013 8:05 UTC (Thu) by tuomasjjrasanen (guest, #86050) [Link]

Pentax Hacking Community has been silent for some time: http://pentax-hack.info/index.html

The intersection of photographers and hackers is quite small already, let alone the set of photographing Pentax-hackers. Canon dominates in both second-hand markets: hardware and software.

Shoot two exposures at once with Magic Lantern

Posted Jul 25, 2013 13:34 UTC (Thu) by MKesper (subscriber, #38539) [Link] (1 responses)

Every camera should have a mode like this. :)

Shoot two exposures at once with Magic Lantern

Posted Jul 25, 2013 19:42 UTC (Thu) by nettings (subscriber, #429) [Link]

yup. i actually based my purchase decision on MagicLantern availability. so canon, in case you were wondering, those guys scored a sale for you :)

Shoot two exposures at once with Magic Lantern

Posted Aug 1, 2013 5:47 UTC (Thu) by yeti-dn (guest, #46560) [Link]

It's a cool hack, no doubt. But looking at the gallery at magiclantern.fm, I wonder whether it's really so great to make photographs that look like rendered in a raytracer with inadequate light model. The gallery contains a few nice shots but most range between odd and awful...

Not two *exposures* but two *gains*

Posted Aug 2, 2013 12:35 UTC (Fri) by pieleric (guest, #51846) [Link] (1 responses)

This article is misnamed. The algorithm doesn't shoot at two exposure times, but at two different _gains_ (or "ISO" in photography jargon).

It does more or less the same effect, but that means all the pixels are exposed the same duration, which is important when there is motion in the image. Also, image sensors have usually 2 to 4 gains available, which limits the available combinations compared to exposure times which are pretty unbounded.

Not two *exposures* but two *gains*

Posted Aug 22, 2013 8:37 UTC (Thu) by freddyh (guest, #21133) [Link]

The article is correctly named. It doesn't say the algorithm shoots at two exposure *times*, it says it shoots at two exposures.

f/4, 1/100th, ISO 100 is another exposure than f/4, 1/100th, ISO 1600.


Copyright © 2013, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds