darktable-org / dtdocs

darktable user manual
GNU General Public License v3.0
74 stars 74 forks source link

astrophoto denoise #400

Open phweyland opened 2 years ago

phweyland commented 2 years ago

We have difficulty to understand this text:

This is accomplished by averaging each pixel with some surrounding pixels in the image. The weight of such a pixel in the averaging process depends on the similarity of its neighborhood with the neighborhood of the pixel being denoised. A patch with a defined size is used to measure that similarity.

The highlighted part doesn't make sense to me and I cannot translate it. The former doc, on https://darktable.gitlab.io/doc/en/, is clearer on the subject. Help needed

elstoc commented 2 years ago

I think I just copied that verbatim from the old user manual. I assume it means something like "take a patch centred on the target pixel and compare it with a similar-sized patched centred on a nearby pixel. Weight the averaging based on the similarity of those nearby patches to the target patch". Indeed the old doc (which you link in the issue) has exactly the same English text for denoise (NL means). See https://darktable.gitlab.io/doc/en/modules.html#denoise_non_local_means

phweyland commented 2 years ago

Thanks. Trying to understand. Denoising is based on a blurring process (averaging). To preserve the structure blurring should not be applied on the structure. To identify the structure there is a comparison, pixel by pixel, between there respective centered patches. How the comparison is made ? Luma, color, gradient, ... ? Once this is done, the more the 2 patches are similar the more they are averaged. That's a guess... If true, the patch is not only used to measure the similitude but also the burring. ...

I think it's useless to have such a piece of explanation because it doesn't allow to connect the dots. Either it should be removed (parameters are enough) or completed to explain correctly the principle.

Thoughts ?

elstoc commented 2 years ago

@rawfiner knows about denoising. Perhaps he can provide some clarification as to how it works?

I don't particularly mind removing the text if it's not adding anything.

rawfiner commented 2 years ago

To denoise one pixel of the image, non-local means performs a weighted average of pixels of the image that are spatially not very far from the pixel. To define the weight of one pixel in the average, we compare its close neighbourhood (a patch), to the close neighbourhood of the pixel we want to denoise. The more alike the 2 patches are, the bigger is the weight. This is done by measuring the mean squared difference between the 2 patches. I think for astrophoto denoise the difference is based only on the L channel, in denoise profiled it considers all 3 channel.

If you are familiar with bilateral filter, non-local means works the same way, but instead of having a weight that depends on the difference between the 2 pixels value, we consider the average difference on a patch

phweyland commented 2 years ago

Thanks @rawfiner !

rawfiner commented 2 years ago

Don't hesitate if it remains unclear, I can try to explain differently :-)