Sunday 11 September 2016

Purple flares and grid pattern on xtrans: Why its there and how to remove it

There have been a few discussions and posts over the years about a phonomenon on some digital cameras where a grid pattern is appearent in purple flares when pixel peeping. Here is a discussion on the topic from a few years back, that time about a Sony camera.
Now it has become appearant that the effect can occure in xtrans sensors as well. A few months ago Mathieu att Mirrorlessons wrote an article on it. I first read about it on a discussion a few days ago and have been doing some digging since, here is what i know and what have been able to find out the last couple of days.


Purple flare effect in general

Purple flare origins when there are strong light sources in line of sight of the front lens. The source can be, but doesnt have to be, in the frame to cause a flare. If its outside the frame, a well made shade usually helps on a prime. On a zoom lens the shade has to be made to protect only the widest end and if one zooms in, a light source outside the frame can still be in line of sight from the front lens. Filters and dirty front lenses will usually increase the effect.

Flares can usually be avoided, but sometimes they look really good and thats when the real problem occure. If you want it there it has to be well rendered in your photo.

Film vs digital

On film this is usually not a problem unless you scan the negative. If one makes an RA4 copy, a well placed purple flare looks awesome. On a digital camera or a scanned image, things get more complicated. Purple flares over highlights usually work ok, but on shadows, and gray to black highlights in particular, they often become problem. On every camera i have been using (doesnt include sigmas) and every scanner i have used (which are a lot) what always happen is that the post processing latitude turns to almost zero if such a flare is present. Any pushing, pulling, sharpening or even white balance shift will make it look horribly ugly if you dont treat it carefully. Further more, if shot with a digital camera, usually the tolerance for cropping decreases a lot too. To much cropping and one of several kinds of artifacts are bound to appear. It can, for example, be clotting, loss of contrast or that part of the image just gets a different look. On xtrans files is it the grid pattern.

Why?

Mixing bright colour with dark gray is obviously not easy. Try to imagine it yourself. However, when its done right it can look very pleasant. I like to do in postprocessing my darkroom prints. On most papers it doesnt work at all. When it works, its because the papers have a structure like tiny hills and valleys. The black silver then only forms its shade of gray of the photo on the mountain tops in the highlights. Then i can rub colour down in the valleys without desturbing how much silver that should be visible. Even with such a paper it only works in the highlight areas of the photo, in shadow areas the silver reaches down in the shadows and there can be no mix. Digital images face very much the same kind of problems, a single pixel cant be both bright purple and dark grey at the same time. To create something that looks like that, some pixels have to have one property and others the other one. With some clever maths and enough pixels, this is fixable if you start with a picture that have all the colour information for every pixel. But ouch, a digital sensor doesn't have that. Every pixel only have one colour, and its green in 50% of the time on a bayer sensor and even more on an xtrans one. To a green pixel, purple looks almost black. So the amount of pixels the clever maths have to work with is seriously reduced in a purple flare.

The grid pattern

Why does xtrans form a grid pattern? To answer that we have to take a look at the xtrans pattern, so here it is.


As you can see, every fifth green pixel have a different coloured pixel on its side and a green one at its corners. However, four out of five green pixels only have differently coloured pixels at two of the sides. Demosaicing is complecated stuff and ill give you a very very simplyfied version on how it works from one of the green pixels perspective when being faced with purple light.

First it looks to its own information and sees black. Then it asks its longside neighbours. Half of them say black, one says slightly red, and one slightly blue. Including itself, a 3 to 2 majority vote black. Then it asks its corner neighbours and gets the same answer, 3 to 2 for black. The 5th green pixel gets another ansew from its longside neighbours, 4 to 1 majority says its not black which changes its mind.


Now lets look closely at an affected picture converted with lightroom and compare to the xtrans pattern. 

The result is the complete opposite of the prediction, but the pattern remains as the algorithm seems to overcompensate when there is not enough data. I have now looked at the output from several different raw converters including the in-camera one. Every single one creates this reverse pattern in the purple flares. Clearly some tweaking of the demosaicing algorithm in affected areas would be in order. It would still need the mix of brighter and darker pixels to keep the luster, but they have to be scrambled somehow.

Is this a problem worth bothering about?

Yes and no. It only shows this clear when pixel peeping and the kind of screen you use also affects how visible it is. However, when trying to post process a photo with a purple flare by any means to achive sharpening, cropping, clarity, opening up the shadows or changing the contrast, it is always the flare areas that sets the limit of how much one can do. If i was at charge at Fuji, i would dedicate some resources to investigate it and if i was in charge at Silkapix id definetly see it as a chance to show the world i was still ahead of Adobe.

Does it affect my pictures as a photographer? Almost never, and when it does, i know how to fix it in post for almost every case.

The post production solution

Lets start with a picture. This is from the x-pro2 with a 10-24 with a street lamp slightly in front of me, shining down on the camera from above . It wasnt in the frame, but the shade didnt cover my lens enough to keep the light from reaching my front lens. 

Here is a 1:1 crop, it dosnt look pretty at all:
(it uses the adobe standard profile with no modifications but slight clarity and slight dehaze to exagurate the effect)



From lightroom i then right click on the image and chose "Open as smart object in Photoshop". In fotoshop i select the whole image and apply box blur with the minimum strenght of 1, (I use gaussian blur 2 if the pattern appears as diagonal rather than horisontal/vertical). I then close photoshop and click save.

Here is the result that then automatically opens up i Photoshop as a PSD file next to the RAF:
The grid is gone and the loss of detail is much like using a sensor with aa-filter.

Here you can download the before and after pictures side by side. It is a crop at approximatly 1/4 of an xtrans III file.

Happy shooting with purple flares again!

P.S.
In Mathieus article there are pictures with a diagonal pattern as well. I have not been able to recreate that pattern. Could someone, please, mail me (roos@swedish.photography) a RAF of such a photo so that i can investigate it further?

No comments:

Post a Comment