Popular Post Guest JonathanP Posted July 2, 2014 Popular Post Share #1 Posted July 2, 2014 (edited) Advertisement (gone after registration) As we know, the M240 exhibits discolouration (usually a green cast) in the shadows when images are push processed more than about 3 stops. Jim Kasson on his excellent blog spent some time investigating this issue and his summary Leica M240 green shadows with the Sekonic step wedge | The Last Word describes the problem in a nutshell: The M240 exhibits nonlinear response at ISOs 200, 400, and 800, artificially depressing darker tones. The darker the tone, the greater the depression. In my previous noise floor tests, I saw the noise floor to be artificially depressed at these ISOs. and: This is probably the cause of the green shadows, since in most lighting conditions, for most subject matter, the green channel is the strongest. Depressing all the channels nonlinearly leaves the green channel the last one standing, so to speak. Because of the above, the green channel shadow shift is probably more accurately characterized as a shadow shift in the direction of the highest-valued raw channel. From my experience I believe that Jim's analysis is spot on. Now its perfectly possible to adjust an individual image in Lightroom or Photoshop to tune out the green cast reasonably effectively, however because this correction is occurring after the image has been demosaiced (and the non-linear gain error occurs in the mosaic data), you need different adjustments for each image. Inspired by Jim's work I realised that if one could apply gain correction to the mosaic data in the raw file it should be possible to correct all images with one set of adjustments. This means in theory I could simply preprocess any files that were going to be significantly pushed or shadow recovered and not have to make individual colour correction adjustments on each image. Luckily, processing M240 raw files is made a bit easier by the fact that the M240 uses the DNG format and Adobe make a source code DNG library available free in order to encourage adoption of the DNG format. So its possible to write a program that reads a M240 raw file, applies linearisation corrections each channel and then writes an output DNG file ready to load into Lightroom: Whilst developing the program I also noticed that often in deep shadows the red channel in the raw file was clipped, whilst there was still useful data in the green and blue channels. It struck me that I could make an attempt to recover the lost detail in the clipped channel in much the same way that highlight recovery works to fill in structure from the non-clipped highlights. So I added a nearest neighbour interpolation to recover the lost shadow detail, plus a small amount of normal distribution noise to smooth/mask blotches in the deepest recovered shadows. Does it work? Definitely! Here's a quick couple of examples, corrected image on the right. Underexposing 6 stops means we are running out of adjustments in Lightroom, so with a 5 stop push plus 100% shadows adjustment we get: And this is even more underexposed (it needed exposure +5, shadows +100% plus a tone curve in Lightroom). A 50% crop from a dark corner: Yes its very noisy, but the colour cast problem is very effectively dealt with. My intention with real life images is not to have to push them quite this far, but it always good to know that the processing is capable of extracting the maximum from the image. On my Mac mini it only takes 3 seconds to process a M240 raw file, and those examples on my blog only had exposure correction in Lightroom, so it completely removes fiddling with curves to approximate the correction. I'd like to make my little Mac command line program freely available, but would prefer if one or two others could test it first, as I've only had the opportunity to post process files from my own camera so far. Interesting thought: this correction could easily be done in camera, the majority of the work is done by a simple lookup table. Edited July 2, 2014 by jperkins 32 Quote Link to post Share on other sites More sharing options...
Advertisement Posted July 2, 2014 Posted July 2, 2014 Hi Guest JonathanP, Take a look here Correcting the green shadows. I'm sure you'll find what you were looking for!
Guest JonathanP Posted July 2, 2014 Share #2 Posted July 2, 2014 Oh, don't know why my images aren't showing up inline? A more readable version of this is on my blog: Jonathan's World: Fixing the Leica M240 green shadows Quote Link to post Share on other sites More sharing options...
Guest JonathanP Posted July 2, 2014 Share #3 Posted July 2, 2014 To save clicking on the above links, here's the 6 stop push result: Welcome, dear visitor! As registered member you'd see an image here… Simply register for free here – We are always happy to welcome new members! 5 Quote Link to post Share on other sites Simply register for free here – We are always happy to welcome new members! ' data-webShareUrl='https://www.l-camera-forum.com/topic/229863-correcting-the-green-shadows/?do=findComment&comment=2622639'>More sharing options...
Numbers Posted July 2, 2014 Share #4 Posted July 2, 2014 Very cool! WOW. I didnt get all you wrote, but the result speeks for itself. Impressiv that you wrote it. Quote Link to post Share on other sites More sharing options...
Guest JonathanP Posted July 2, 2014 Share #5 Posted July 2, 2014 So basically my program does 2 steps of processing to a raw file and writes the result out to a new raw file: 1. it applies a correction to raw channel data that is approximately an inverse of the gain drop that Jim Kasson measured. This effectively cancels out that non-linearity and removes most of the green shadows. 2. a side effect of (1) is that I end up with a small lift in the lowest pixel values. I can then use this little 'headroom' to 'recover' clipped shadows (where the original value was 0), by interpolation from the nearest neighbour pixels. Think of this as very similar to how Lightroom recovers clipped highlights. Now step (1) could be fixed in firmware, because it can be implemented by lookup table and incorporated into the existing image processing pipeline in the camera. Step (2) may be beyond the capabilities of the camera processor but isn't essential as a significant improvement is obtained by step (1) on its own. Jonathan 8 Quote Link to post Share on other sites More sharing options...
jaapv Posted July 2, 2014 Share #6 Posted July 2, 2014 Very impressive. And useful. Quote Link to post Share on other sites More sharing options...
rscheffler Posted July 3, 2014 Share #7 Posted July 3, 2014 Advertisement (gone after registration) This is great! (BTW, first saw this on Jim's blog) I'd love to see this become broadly available. While I don't often push M240 files that much, there are occasions where it would be very useful... Where I have seen the green shadow cast more frequently is at the ISO 800-1000 range and pushing a file a stop or so. It would seem that as the ISO increases, it takes less push in post to see the green (which makes sense to me). Have you tried your correction at various ISOs and should it work equally well across the board (ISO 200-~800) where the green shadow problem exists? To further what you mentioned, I wonder why Leica chose to push down shadow values like this in the first place? Was it a reaction to the early banding problems seen in preproduction images? From what you've shown, Leica could just as easily 'fix' this problem. Quote Link to post Share on other sites More sharing options...
pieterpronk Posted July 3, 2014 Share #8 Posted July 3, 2014 Where can I buy this program? Seriously though, this look very impressive and if it really works as well as your images show then it should be put into the firmware of the M240. Although I guess there is a chance that Leica chose this green shadow path to sidestep another problem, and that this green shadow is actually the lesser of two evils. In any event I think many people are very interested in at least having the option of post processing in the way you suggest when dealing with underexposed images. So if either Leica decides to use your insights or if you release your program, I think many of us would be very grateful. Keep up the great work you're doing and keep us posted. Quote Link to post Share on other sites More sharing options...
Guest JonathanP Posted July 3, 2014 Share #9 Posted July 3, 2014 Ron, I've done all my work so far at ISO 200, but I did do a cursory check on a ISO800 file - saw some improvement but I've not looked properly to see if it needs a different correction table. I suspect from Jim's analysis that it will work but could be improved with ISO specific tables. It would be easy to update the code to do that. I don't know why the M240 has this characteristic - was it by design or just a bug/not of high enough priority? I guess we'll never know, and probably best to avoid another thread here descending into a bug/feature downward spiral The good thing is (made easier by the decision to use DNG rather than a proprietary raw format) that we can make a reasonable effort to fix the problem in post processing. So whilst I'd like Leica to fix the camera, its not the end of the world if they don't. Its clear though that the CMOSIS sensor in the M is being held back a little by the image processing pipeline. Jonathan 1 Quote Link to post Share on other sites More sharing options...
Guest JonathanP Posted July 3, 2014 Share #10 Posted July 3, 2014 Pieter, My intention is to make the program available free of charge. I was inspired by Jim's detailed analysis which he freely published - it would be wrong to commercialise a development on the back of his work. The only reason I haven't put up a download link at the moment is I'd like a couple of other people to test it first, after all I have only examined files produced by my camera (but based on the results Jim published I am expecting one set of corrections to work well enough with all cameras). If anyone wants to help beta test this for Mac*, please let me know! At present it is Mac only I'm afraid, as I don't have any Windows development tool, but in the long term I wouldn't be adverse to making the source code available for porting to other platforms. Jonathan * its a command line program, but easy to use. Just don't expect any fancy user interface at the moment 16 Quote Link to post Share on other sites More sharing options...
thrid Posted July 7, 2014 Share #11 Posted July 7, 2014 This is really impressive. Thanks for putting in the time and effort. Someone really needs to pass this along to Leica.... Quote Link to post Share on other sites More sharing options...
JimKasson Posted July 17, 2014 Share #12 Posted July 17, 2014 If you look at some raw histograms, you can see (sort of) what's going on. Many camera manufacturers present their raw data just as it comes off the ADC, with an offset that represents black. The raw developer is then responsible for subtracting the black level. That means that the raw developer can change the level subtracted. Here's a Sony a7S dark frame histogram. It's in speed priority continuous shutter mode, so the 13th and 14 bits are AWOL: Notice that the average count is about 512, and that we can see in the histogram a classical Gaussian probability density function. In RawDigger, you can see the whole histogram by setting the black level to 0: Now look at an M240 dark frame at 1/4000 second and ISO 1000: Just about everything is at the lowest bucket. If we go to log scale for the vertical, we can see that there's some information higher than that, but that it's a lot less than half a Gaussian PDF: If we back way out on the horizontal scale, we can see that the noise actually extends quite high: So the dark levels are truncated in the camera, and they're truncated at a level somewhat above true black. Thus the utility of programs like Mr Perkins'. Congratualtions on a job well done. Jim 2 Quote Link to post Share on other sites More sharing options...
thrid Posted July 18, 2014 Share #13 Posted July 18, 2014 If you look at some raw histograms, you can see (sort of) what's going on. Many camera manufacturers present their raw data just as it comes off the ADC, with an offset that represents black. The raw developer is then responsible for subtracting the black level. That means that the raw developer can change the level subtracted.Jim Jim, is this something that Leica can or should address with a firmware update? Is this something that RAW converters like LR etc need to address? I've only had my 240 for about a week and noticed the green shadows almost immediately. IMO this is not a trivial issue. Luckily this is something that can be addressed in post, as jperkins has admirably done. But I think we would all would prefer to not have to deal with this issue by preprocessing our images, before working on them in something like Lightroom. Quote Link to post Share on other sites More sharing options...
tobey bilek Posted July 18, 2014 Share #14 Posted July 18, 2014 Should not have to, but make a luminosity mask, invert so darks are proportionately selected, apply magenta. Make a color profile for each iso setting. Leica needs to hire some color engineers. Perhaps poach some from Canon or Nikon. Quote Link to post Share on other sites More sharing options...
thrid Posted July 18, 2014 Share #15 Posted July 18, 2014 (edited) Oh, I can fix it, but frankly this is something Leica should address, especially when you consider the cost of a 240 and Leica claiming that they produce professional cameras of the highest caliber. Edited July 18, 2014 by thrid Quote Link to post Share on other sites More sharing options...
JimKasson Posted July 18, 2014 Share #16 Posted July 18, 2014 Jim, is this something that Leica can or should address with a firmware update? I don't know enough about the internal workings of the camera to know if they can address it in firmware. As to whether they should, it depends on the number of people who find it to be a problem. I reported the problem in this forum about 10 months ago: http://www.l-camera-forum.com/leica-forum/leica-m-type-240/298028-leica-m-sensor-low-light-performance-3.html#post2500422 and many, if not most, people thought I was making a mountain out of a molehill. If Leica thinks most people don't consider this behavior a problem, they won't be motivated to fix it, assuming that they can. Is this something that RAW converters like LR etc need to address? I don't know about "need to", but the Lr folks have proven to be fairly good at artfully making up data that's beyond fullscale, and maybe they could apply their expertise to data that's below zero. Sloppily said, but you know what i mean, I hope. II've only had my 240 for about a week and noticed the green shadows almost immediately. IMO this is not a trivial issue. Luckily this is something that can be addressed in post, as jperkins has admirably done. But I think we would all would prefer to not have to deal with this issue by preprocessing our images, before working on them in something like Lightroom. You're right. I've chosen to deal with it by using another camera if I"m going to have to push the shadows hard. Jim Quote Link to post Share on other sites More sharing options...
JimKasson Posted July 18, 2014 Share #17 Posted July 18, 2014 Leica needs to hire some color engineers. Perhaps poach some from Canon or Nikon. Maybe so, but this is not actually a color science problem. It's the result of raw data clipping that turns into a color problem since the four raw channels usually receive different shadow exposure. Jim Quote Link to post Share on other sites More sharing options...
Guest JonathanP Posted July 18, 2014 Share #18 Posted July 18, 2014 Thanks Jim for so clearly showing the clipped black issue, which is why I am attempting to recover some red channel information in a very basic way from the neighbouring non-clipped pixels. I think it's important to remember there's two issues here: (1) non-linear gain somewhere in the sensor->ADC->image processing pipeline and (2) loss of information due to black level clipping. I'm finding the non-linearity to be more of a real world picture problem - now I've started processing more of my images I'm noticing a subtle green's problem in landscape images where I often need to lift the shadows slightly after preserving sky highlights. There's a slightly artificial 'digital' look to greens that have been lifted a little - I think it's the early stages of the non-linearity showing up. I would like to see the non-linearity corrected in a firmware update, as I feel it has a noticeable impact and I believe it can be fixed with low-CPU requirements. As you say, raw processors could tackle the black level recovery if they felt there was a demand for it. I do think its a bit of a shame that out of the camera the image quality is not limited by the sensor*, but by the image processing pipeline. It must be a little frustrating for CMOSIS to keep hearing everyone laud the Sony sensors when theirs isn't getting the best exposure. Jonathan *the non-linearity may of course be in the sensor ADC, but I think it's fair to think of performance as a combination of silicon+software 4 Quote Link to post Share on other sites More sharing options...
JimKasson Posted July 18, 2014 Share #19 Posted July 18, 2014 (edited) I think it's important to remember there's two issues here: (1) non-linear gain somewhere in the sensor->ADC->image processing pipeline and (2) loss of information due to black level clipping. You are right Jonathan. Here's another piece of the puzzle that I discovered yesterday. When I started testing the a7S, I started doing my noise floor measurements in 1/3 stop ISO increments in order to get at when that camera changed conversion gain. I thought I'd take a look at the M240 at 1/3 stop intervals. Here's what I found: http://www.kasson.com/ll/m240 nf vs iso.PNG Notice the kink in the curve? The processing changes between ISO 1000 and ISO 1250. It's even more apparent if you refer the numbers to the input of the pre-ADC amplifier: http://www.kasson.com/ll/m240 nf vs iso corr.PNG Notice that the curve is backwards from most cameras, in which the sensor-referred read noise drops as ISO goes up. I'll be doing a blog post on this with more details some time in the next few days; I'm backed up with the a7S testing. Jim Edited July 18, 2014 by JimKasson 1 Quote Link to post Share on other sites More sharing options...
thrid Posted July 18, 2014 Share #20 Posted July 18, 2014 (edited) I don't know enough about the internal workings of the camera to know if they can address it in firmware. My guess would be, yes.... at least certain aspects of the problem. As to whether they should, it depends on the number of people who find it to be a problem. I reported the problem in this forum about 10 months ago: http://www.l-camera-forum.com/leica-forum/leica-m-type-240/298028-leica-m-sensor-low-light-performance-3.html#post2500422 and many, if not most, people thought I was making a mountain out of a molehill. If Leica thinks most people don't consider this behavior a problem, they won't be motivated to fix it, assuming that they can. Well, the world is a strange place. We'll get a 20 page debate splitting hairs about the difference between CCD and CMOS or the latest Luigi strap, but green shadows don't seem to be much of an issue. I don't know about "need to", but the Lr folks have proven to be fairly good at artfully making up data that's beyond fullscale, and maybe they could apply their expertise to data that's below zero. Sloppily said, but you know what i mean, I hope. I'm not an engineer, but an 'operator with technical understanding' I get what you are saying. Even if this problem is inherent in the hardware, they should be able to compensate for it with software as Jonathan has demonstrated. Or at least I would think they could You're right. I've chosen to deal with it by using another camera if I"m going to have to push the shadows hard. Jim hahaha... yes but that kind of defeats the purpose of going from the D600 to a 240.... Edited July 18, 2014 by thrid 1 Quote Link to post Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.