Diagonal interpolation correction artifacts with AMaZE Demosaicing

@cuniek Thanks for the explanations and the pointer to the part of the amaze code. I’ll try it later today :slight_smile:

Jacek, can you give a more detailed opinion on this …
I mean …

  • What is the ideal WB which would help a demosaicer do a better job ?.
  • Would a variable WB help ? … I mean to not use WB multipliers calculated from all the frame but from a relativelly small tile around.

How do you explain the fact that especially on diagonals, Amaze amplifies Red and Blue while DCB looks to amplify Green ?.

@ilias_giarimis I was investigating how DCB works with different WB (using DCRAW code) and it turned out that settings that were the closest to light source temperature gave the best results. I was testing sunlight and bulb shots, nothing really exotic (no LED lights). I believe (that’s the right word) that WB that keeps all 3 channels unclipped is the optimal choice (tell me if this is similar to Your findings).

As for variable WB: I think it may work if there are highlights and shadows with different light source on the shot (in this case lumimance is the criteria). Didn’t test that.

I was experimenting with using different WB (very simple channel multiplier) on different areas of photo, but it worked only on monohue areas and failed miserabely on every single edge. I didn’t find method that set a good area boundary (edge detection) for my approach. After some time I quited.

As for different colors on diagonals: My method is using horizontal or vertical interpolation of green only, AMAZE is using R and B values to interpolate green diagonally. We also have different missing colors interpolation, and DCB is trying not to overshoot green pixels (if this happen, missing colors interpolation is giving overshooted red and blue). My method is less prone to CA, while AMAZE has other advantages.

I hope I helped.

@samuelchia, thanks for the split files. Here are my thoughts, though this may take a while, new to Gimp…

Some comments. There’s the rule in digital sampling that the frequency being sampled must be less than half the sampling frequency. I know the anti-alias filter is there to enforce this, but I can’t help think that the “sampling frequency” here is 2x2 pixels and the sky-rock boundary is only a few pixels thick. Therefore there is always going to be noise on the boundary.

Your logic seems to be 1) there are unpleasant artifacts in the final image, 2) you remember there is possibly a weakness in amaze (diagonals), 3) Focus Magic highlights these, therefore 4) it must be amaze causing the problems. I suspect FM is the problem. @cuniek has alluded similarly. The product makes a big thing about deriving a car number id out of a blurred plate, and rescuing terrible exposures, but is it for fine art?

I’ve put your images in Gimp and compared them, but honestly, I’m not much the wiser (though obviously my untrained eye is not helping…). For others reading this thread, here are some screen grabs of one tiny section from the photo.

  1. “Bare” amaze (no chromatic ab. correction, no false colour correction steps). I see nothing wrong with this so far.
  2. Add in chrom.ab. and 1 false colour step. Now looking very reasonable.
  3. Apply unsharp mask, raduis 1, amount 200, everything sharpened with no halo control.
  4. Compare this with your FM result -

    (3) does not have the extreme colours and aggressive edge (though it does have an unwanted halo).
    The above is why I think the FM sharpening is the problem.

If you want top top quality perhaps a medium format sensor is needed?!

There is a cure for the edge of course. I expect you know this, but for anyone who doesn’t, one trick is to take the finished image and put a sharp version layer on top of the unsharpened image. Then with a small soft brush, trace over where sky meets land on the top layer and delete the sharp boundary. This gives a good result since it mimmicks the natural diffusion we see. Here is a larger part of the photo done this way -

Zoom in, I think it stands up quite well.
You will probably say it’s not for me to say how you process your prints, and that’s fair enough, but we all should be a bit practical and all this Amaze stuff seems a bit over the top when you have a very simple workaround.

@cuniek, I looked at your NEF file, but I honestly can’t see anything wrong! Yes there’s some purple fringing / aberration, but I can’t see these elusive artifacts (except for @heckflosse 's example). What is meant by stairsteps please? Obviously if you make a diagonal out of squares, it’s going to look like steps, beyond that I don’t get it.
Here is a bare amaze section and then with 1 step, chr.ab and Defringe in the colour tool (as you had).


Again, these sections are miniscule parts of the photo.
Where are the artifacts please?

I know little about demosaicing, I was just interested by this thread. Perhaps Amaze can be improved. But if you did something special for diagaonals, would it cause new problems in some other situation? Where do you stop? - special processing for corners, circles, squares, hair?!

Cheers

That was my thought, too. Amaze (and Capture 1) reveals the weakness of Focus Magic, not the other way around. Focus Magic simply cannot handle an image as sharp as what Amaze puts out, it may be tailored to the softer ACR output.

Personally, in my shooting, I use Amaze with no sharpening at all. Perhaps if I used Adobe software then that wouldn’t be feasible, and that’s why an ecosystem of sharpening solutions is necessary.

1 Like

That is completely the wrong thinking. There is no ‘possibility’ of a weakness in AMaZE’s diagonals. Emil has already confirmed that AMaZE does indeed produce diagonal ringing artifacts, and I showed to him the same examples as I showed here. There is no dispute there. I am not using Focus Magic to help myself see where the artifacts are, I use it to help others see where the artifacts are, and then tell them to see it again without sharpening, because that it much harder to see.

By avoiding artifacts as early as possible in the workflow, one is able to edit images more robustly, and enlarge them further than otherwise possible. I make large prints of my work, and I do not want to limit myself unnecessarily on how large I can go. The artifacts are not inherent to the camera, just how the data is interpreted (DCB does not have such artifacts, but has other problems). So it seems maybe this can be resolved.

There are so many flaws to this kind of thinking, it would be difficult to address each issue without digressing from this thread with several thousands of words.

The problem is not knowing where to look, and not knowing what to look out for. Here is a crop from Jacek’s DSC4042.NEF file, which clearly shows the diagonal ringing. No sharpening, all settings zeroed except for 2 steps of false color supression, which did not change the artifacts visibly but got rid of the offending and distracting false color artifacts. You should be able to very clearly see the diagonal ringing along the roof’s edge in AMaZE, which is completely not present in the DCB. I added a helpful line overlay below the AMaZE crop to highlight where and how long the ringing width is. DCB was with enhancement activated - DCB without enhancement is horrible and unusable.

https://drive.google.com/open?id=0B5AXKSbQEPuFNGg0cEc4UHlxenM

It is possible to see this in the crop I provide too, there is a green color on the edge of the DCB rendition. It is also on all the high contrast, thin edge details like in the fine branches you show. This is one of the issues I noted with DCB, when one has almost neutral-color edges. AMaZE gives the more correct color for the edge, especially in the roof edge (harder to say for sure in the fine branches). This green-bleeding artifact with DCB because of the way it interpolates green values (thanks for the explanation Jacek), is one reason I am not willing to switch to using DCB. I didn’t wish to cloud the already complicated thread with more issues. Already we have folks here (strangely) unwilling to accept Emil Martinec’s own admission that AMaZE does produce ringing diagonal artifacts and he wishes to resolve this if he can spare the time.

They are here, as highlighted with the white lines to show the approximate length of the ringing and the position. In the other fine structures you cannot see them in this crop because the detail is going about in all directions. See how the white line overlays are on an edge that is quite strongly diagonal?

Same here, though much harder to see. There is not so much ringing in this example as there are just diagonal artifacts where single pixels coalesce into single-pixel-width 45-degree strings.

I don’t think that folks are unwilling to accepts Emil’s admission about existing artifacts in Amaze. They are just not able to see them! Which does not mean they don’t exist! And which probably means they are not relevant for most of the folks here (including me, at least for my photo work). But as I already wrote in a pm to @cuniek we will try to improve the amaze output based on his knowledge of dcb code and my knowledge of amaze code.

Edit: My priority for this is less than my priority for pixelshift coding, so don’t expect any serious improvement during this week!

Thanks for the encouragement Ingo. :slight_smile: Although they clearly say there is no problems with AMaZE, only with Focus Magic. Indeed the problem often is being able to see the problem in the first place. That’s the bane of a scientist’s or engineer’s or designer’s life. Or pretty much everything else! If I could connect my brain to another person’s with electrodes or something that can send brain waves across and let them experience what I do, this whole exercise will be so much easier. Perhaps one day technology will take us there.

It is true that these issues are generally too small to bother with for most folks. Unfortunately my standards of work are pretty stratospheric. :wink:

I really appreciate it. Thank you for looking into this. I am also (finally) looking at the AMaZE and DCB demosaicing math in the code (from the link you provided above), and if I notice anything, I’ll sound it out too. But otherwise I would prefer to observe from this point, not being anywhere near an expert at demosaicing math or coding. Lest I begin to spout nonsense…

I think I have you beat: trying being a writer when the new Dan Brown book or 50 Shades of Gray come out. They’re beat sellers, many many copies sold.

Yet I barely consider 50 Shades to be written in the English language. Madness!

Sorry, I don’t understand what you are trying to say here. Though I agree that most writing is worthless. Like most photographs (yes, even mine) are worthless.

I’ve done some demosaicing experiments in GMIC.

I found that diagonals benefit from interpolating the colour channels (or the colour differences) diagonally first, based on the orientation information from the green channel, and then horizontally or vertically based on green channel or local direction estimates.

Here you can see the results of two of my demosaicing experiments compared to other algorithms. My first experiment (Mine 1)has some ringing artefacts similar to those described in this thread. My second experiment (Mine 2a) renders less fine detail but has less ringing. It also has a refinement step (Mine 2b) which pulls out more details but will introduce zipper artefacts if overdone.Both experiments use the diagonal first interpolation I mentioned above.

Raw file here: https://dl.dropboxusercontent.com/u/10782279/DSC_6553.NEF

1 Like

Fascinating!! Thank you for this example. Unfortunately for 2a and 2b, there is a lot of false detail and aliasing artifacts near and at Nyquist.

Also in both 2a and 2b, along the main diagonal lines, the line goes from sharp pixels to a fuzzier edge, then becomes sharp again, then becomes fuzzy again. ‘Mine 1’ does not suffer from that at all and actually, to me looks the best here. Even better than AMaZE which also has the sharp-fuzzy-sharp issue. ‘Mine 1’ looks to have much less severe ringing than AMaZE. Hardly anything really. That’s a stunning result!

Is this your own original demosaicing algorithm or did you modify/base it off an existing one?

Edit: The DCB example is without enchancement I presume? It looks awful. With enhancement it looks closer to ACR, which has the 2x2 pixel jaggies.

Edit 2: It looks like you modified AMaZE? If ‘Mine 1’ is AMaZE, but with diagonal line interpolation before horizontal and vertical, it looks to me to be an unqualified success! I think it’s just what I was looking for.

It is a simpler algorithm and only looks to avoid zipper artefacts when choosing the interpolation direction, not false colours and aliasing. It is possible to add a consideration of false colours and aliasing when choosing the interploation direction.

In 2a and 2b the missing green values are interploated without considering the values of the red and blue pixels. In Mine 1 the algorithm considers the correlation between the colours which allows better details.

These are my own algorithms. Although I expect I have repeated things from other algorithms without knowing it.

Yes, that is correct. The DCB example has no enhancement.

Do you mind sharing a crop of this region using the ‘Mine 1’ algorithm? It is too difficult to judge the ringing artifacts on single pixel width detail, one needs more region of flat color on either side of an edge to see the ringing develop. As we see in the below crop, AMaZE produces the ringing as expected.

Thank you for the insight. Did you notice how AMaZE goes from magenta to green to magenta along those diagonals? While ‘Mine 1’ is virtually completely free of that color shifting issue, and is almost completely uniform and color stable.

Thanks!

Here is the crop. I used RT to convert the image without any false colour suppression and without any colour profile so that it is a fair comparison.

A diagonal line that is close to 45 degrees will go through mostly green pixels and then mostly red and blue pixels, so it is hard to get the correct colour. My demosaicing suffer from is to some degree.

Thank you. I may have to retract what I said earlier about the lack of ringing. I see that the ringing is actually worse in some ways with your algorithm, spreading further from the edge with higher contrast than AMaZE. Also, AMaZE produces better rendition of noise patterns and single pixel fine detail. In other ways your algorithm is better, see below.

True. Even so, your result is way cleaner than AMaZE regarding false colour in the diagonals. Very impressive.

Hello.

@RawConvert
I wish there was no artifacts, but they are there. Some of them are HUGE, like this moire and wrong interpolation directions (all images are AMAZE, between 200 and 400% zoom, with typical USM, no CA correction)

stairstep effect (where long nearly diagonal line is made of long, perfectly diagonal sections).

zipper artifacts (edge is not a line, but a… zipper)

or 2x2 blocks (this is DCB)

Of course things are greatly improved when image is properly postprocessed.

@samuelchia
I think You can stop posting more examples, everybody here knows what You are reffering to, the reason for some argument is that examples You show are exhibiting visible artifacts only when oversharpened. In all other cases they are well hidden and even skillfull RT users have hard time spotting them. There is a bit of confusion when You write You dont sharpen that much in real life, and say You can not live with those artifacts (visible only when oversharpend). Showing an 8 pixel long diagonal edge that consist of diagonal lines and calling it a “problem” is not helping too.

To sum things up:

  • AMAZE is creating not perfect rendering of diagonal lines (period).
  • Me and @heckflosse will try to improve (but not at expens of other issues)
  • Problems You have can be minimized by proper image processing (as I showed before)
  • If You need help processing files, You should explain what is Your target look (seems You want to greatly improve local contrast, and this leads me to the question if you tried wavelets?) and target size. Most sigle pixel issues are not visible even when printed at 160dpi (I know this can start a new discussion, thats why I wrote most).
  • For fine art prints it is always necessary to do some manual retouching. Your needs seem to be extreme, be prepared to correct things using other software. Once again, it would be nice if You share Your experience with huge prints. How big they are, what was original resolution, what is actually visible on a print
  • Last but not least, the “ringing” you are reffering to is a result of natural, optical behavior of a lens. It is then obscured by bayer pattern on a sensor, amplified by demosaicing algorithm (which creates 2/3 of informaion You see on a photo - accept some imperfections), and then by sharpening.

I know this is not solving Your problem, but unless You have an idea how to improve RT code, all You can do (for now) is to hide artifacts and accept imperfections. Believe me - noone will notice if photos are great :wink:

“Sharpness is a bourgeois concept” (HCB)

I’m sorry, I couldn’t resist…

1 Like