Hi Johannes
For now, I am working on denoise profile's anscombe transform, not one for
rawdenoise (this may come later). Sorry if that was unclear.

Basically, I'd like to have a variance closer to 1 for shadows.
The basic idea I have is to use a linear approximation of the sqrt for
shadows, while using the real sqrt for the rest of data.

Let me go into some details.
I will simplify a bit and stay in the case of a simple poisson
distribution, but the principles are the same for generalized anscombe
transform.
Also, note that I did not know at all how anscombe transform worked about a
month ago, so if there are mistakes in the reasoning feel free to comment.

The anscombe transform is built on a taylor expansion of the variance:
if we call f the transform:
var(f(X)) is approximately equal to:
var(f(u)+f'(u)*(X-u)) which is equal to:
f'(u)^2*var(X)
where u is the mean.
As for poisson noise, u=var, we get:
var(f(X)) is approximately equal to f'(u)^2*u, and we want that equal to 1
Taking f(x) = 2*sqrt(x), we get f'(x)=1/sqrt(x)
Thus f'(x)^2 = 1/x
Thus f'(u)^2*u = 1/u*u = 1
The principle for generalized anscombe transform is the same, except we
have u = a*var + b.

Ok, now, why do we get variance higher than 1 for values close to 0?
Well, as said before var(f(X)) is approximately equal to
var(f(u)+f'(u)*(X-u)).
But it seems that the other terms of the Taylor expansion have an influence
when x is small.
Yet, considering them makes the formula way harder to develop:
var(f(u)+f'(u)*(X-u)+f''(u)/2*(X-u)^2+...)=?
A possible solution is to keep f = sqrt where it works, i.e. for values
significantly higher than 0, and take f(x) = dx+e for values close to 0.
With f=dx+e, the nice thing is that f'', f''', etc are all null, so they
cannot impact the variance and make it higher near 0.
Thus, var(f(X)) = var(f(u)+f'(u)*(X-u))
The less nice thing is that:
var(f(X))=f'(u)^2*var(X)=d*d*u
whereas u will vary depending on the darkness of the zone of the image we
are considering.
Thus, we need to find the value of d and e at a point which is close enough
to zero, so that the approximation remain good enough. We choose d and e to
ensure the continuity with the sqrt function and first derivative at this
particular point x0.

Our transform becomes:
f(x) = dx+e if x < x0
or sqrt(x) if x >= x0

For backtransform, we first consider the unbiased inverse of sqrt, then if
the result is lower than x0, we replace it by the algebraic inverse of dx+e
(with is unbiased as this function is linear. That's also why I considered
a linear approximation, even if a second order approximation seems to work
too in practice: I have not yet understood how to find an unbiased inverse
for non linear formulas.)

In pratice, it seems to work well but the x0 point has to be carefully
chosen (not too high, or the dark areas will be denoised way too much, not
too low, or we will loose the purpose of having this).
It seems that the position of the x0 we should take depend on the "a"
parameter of the generalized anscombe transform.
And... I don't know yet how, this is the current state I have ;-)

Cheers,
rawfiner

Le mer. 27 févr. 2019 à 09:57, johannes hanika <hana...@gmail.com> a écrit :

> hi,
>
> let me know how you go with the anscombe transform, that sounds
> important. in principle we should run it before black point
> subtraction, to be able to correctly extract the zero-mean values for
> black. the current transform wouldn't work with such data, however.
>
> cheers,
>  jo
>
> On Thu, Feb 21, 2019 at 8:49 AM rawfiner <rawfi...@gmail.com> wrote:
> >
> > Hi Andreas
> >
> > This is currently paused. I may come back to this in some time ;-)
> > I have found various ways to improved denoising performance without
> requiring this, that's why I have not worked on this since a few months.
> >
> > Basically, currently my priority is now to improve denoiseprofile.
> > For instance, you may have noticed the coarse grain slider for non local
> means in master.
> > I have some other changes ongoing, you can test some of them on branch
> rawfiner-denoise-profile-updates on my git
> https://github.com/rawfiner/darktable/tree/rawfiner-denoise-profile-updates
> > Basically I use it like this :
> > - I put the patch size to 4
> > - I increase the coarse grain noise slider until no very coarse chroma
> noise remains (some fine grain chrominance noise can remain)
> > - then I increase the details slider to my taste
> > - I fix the remaining chroma noise with the equalizer
> > Note that with these changes, I am mostly using only one instance of
> denoiseprofile, without any particular blending mode.
> > It works very well for medium and high iso, but is not perfect for very
> high iso. In such case, it can be combined with denoise bilateral to get
> nice results.
> >
> > I am also currently working on improving the anscombe transform which is
> associated with the profile to get closer to our goal to have a variance of
> 1 everywhere (currently we have some big spike above 1 in the shadows,
> which is a problem as shadows are usually what we want to denoise the most)
> >
> > Cheers,
> > rawfiner
> >
> > Le jeu. 21 févr. 2019 à 08:03, Andreas Schneider <a...@cryptomilk.org> a
> écrit :
> >>
> >> On Wednesday, 5 September 2018 21:34:21 CET rawfiner wrote:
> >> > Hi!
> >>
> >> Hi rawfinder,
> >>
> >> > Some of you may now that I am working on a raw denoising algorithm.
> >> > One of the hard thing was that prior to demosaic, the algorithms are
> >> > computed on unscaled data, while after demosaic the algorithms can
> compute
> >> > a preview on a downscaled image, which is easier in terms of speed.
> >>
> >> what happended to your work, any news?
> >>
> >>
> >> Thanks,
> >>
> >>
> >>         Andreas
> >>
> >>
> >
> >
> ___________________________________________________________________________
> darktable developer mailing list to unsubscribe send a mail to
> darktable-dev+unsubscr...@lists.darktable.org
>

___________________________________________________________________________
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org

Reply via email to