Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.75k stars 313 forks source link

Improve impulse noise reduction #5148

Open heckflosse opened 5 years ago

heckflosse commented 5 years ago

This issue is about improving impulse noise reduction.

Let me first explain how the current algorithm works:

In first pass it detects impulse noise by comparing the Lab L channel of each pixel with the neighboring pixels.

In second pass it interpolates the detected pixels from 5x5 neighboring pixels weighted by the inverse Lab L difference.

This approach often causes ring artifacts. Here's a first screenshot. Left is without impulse noise reduction, middle is with impulse noise reduction from dev, right is the new code grafik

iliasg commented 5 years ago

@heckflosse Ingo, very good result .. do you use inverse (squared ??) distance weights for the interpolation ?? ;)

Another part of the problem to consider is the fact that when there is a single noisy pixel in the raw data (especially if it's is a red/blue one) the single pixel noise is spead to a 3X3 (??) area by the demosaic process.

Interesting samples .. https://drive.google.com/drive/folders/1Df5zNnK86nrgC3NU5cp3JwPGagKNjS3O?usp=sharing

heckflosse commented 5 years ago

@iliasg

I used this matrix for interpolation:

{1.f / 64.f, 1.f / 25.f, 1.f / 16.f, 1.f / 25.f, 1.f / 64.f} ,
{1.f / 25.f, 1.f / 4.f, 1.f, 1.f / 4.f, 1.f / 25.f},
{1.f / 16.f, 1.f, 0.f, 1.f, 1.f / 16.f},
{1.f / 25.f, 1.f / 4.f, 1.f, 1.f / 4.f, 1.f / 25.f},
{1.f / 64.f, 1.f / 25.f, 1.f / 16.f, 1.f / 25.f, 1.f / 64.f}
heckflosse commented 5 years ago

Another part of the problem to consider is the fact that when there is a single noisy pixel in the raw data (especially if it's is a red/blue one) the single pixel noise is spead to a 3X3 (??) area by the demosaic process.

That's what raw hot pixels detection is for, not impulse denoise (at least in my opinion)

iliasg commented 5 years ago

@heckflosse Aha .. 1/d^4 !! .. are the values at Lab Space with gamma= 1/3 ?. So in linear space it is 1/(x^1/3)^4 = 1/x^4/3 ?.

That's what raw hot pixels detection is for, not impulse denoise (at least in my opinion)

Agree ..

But I was thinking the case of jpegs when no raw hot pixel detection/correction took place (or it was inneffective). Then a single hot pixel will result in a say 3*3 blob (usually with the center pixel extra bright) .. With the current impulse correction only the extra bright pixel is corrected and the blob remains

If we could find a clever algo to correct the full blob would be perfect.

The bad thing is that the spread of the blob depends heavily on the demosaic method

Where can we find the raw file for your screenshots ?.

heckflosse commented 5 years ago

@iliasg

are the values at Lab Space with gamma= 1/3 ?

The values are in Lab space. Don't know which gamma.

Where can we find the raw file for your screenshots ?

https://discuss.pixls.us/t/play-raw-daylight-haze/10491

Btw: there is no real impulse noise in this raw file. I just tried to reduce the bad effect of current interpolation on the water bottom right

The bad thing is that the spread of the blob depends heavily on the demosaic method

Yes, for your example files, a combination of igv demosaic/hot pixel detection/impulse noise reduction gives the best result

iliasg commented 5 years ago

@heckflosse Ingo,

The values are in Lab space. Don't know which gamma.

Normally in all Lab values the t^1/3 is used https://en.wikipedia.org/wiki/CIELAB_color_space#Forward_transformation

Don't bother with this .. I am just trying to match the situation with my way of thinking ;)

Btw: there is no real impulse noise in this raw file. I just tried to reduce the bad effect of current interpolation on the water bottom right

The bad thing is that the spread of the blob depends heavily on the demosaic method

Yes, for your example files, a combination of igv demosaic/hot pixel detection/impulse noise reduction gives the best result

Ingo, thanks for the sample .. with these and other samples I'll try to experiment .. put my thoughts in tact first then "report" ..

For the moment your improvement is fine ..

I was thinking of a possibility to optionally use the algorithm on larger impulses (2x2 - 3x3) maybe with a dual pass .. also usefull would be if we could optionally shrink some impulses (thinking astrophoto) ..

heckflosse commented 5 years ago

@iliasg

For the moment your improvement is fine ..

Ok, I will push it soon and keep this issue open as an umbrella for further improvements.