-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement capture sharpening inside demosaic module #18909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement capture sharpening inside demosaic module #18909
Conversation
ca9fb75
to
33ba3e8
Compare
A lovely enhancement, and reasonably fast even on my aging i7-2670QM! |
Nice effort, I like it 👍 |
I couldn't yet, could you somehow share such raw files? (And possibly the xmp too? It might be related to white balance coeffs. A pre-requisite would be a correct WB) As CS is an iterative process any error would be amplified by more iterations.
I don't understand your "reproducer procedure" here. |
Just did a quick test, for a consistent UI I would propose to make the sliders non sensitive when sharpen is 0 but not to hide them. |
I can do so of course. EDIT latest commit changes this but for my taste it's looking worse. We also have the other optinoal sliders in this module only visible if "relevant" |
33ba3e8
to
dcaeb65
Compare
What I meant was exporting an image without CS and one with CS turned on with at least 15 iterations, then compare the images overlayed in separate layers in gimp, using the layer mode "difference". I'll try to find images which I can share for you to reproduce. |
dcaeb65
to
87aa1b3
Compare
You are aware of the |
Squashed and force-pushed an updated version
|
Nope, never used it, what is it good for? |
It writes pfm files to tmp directory while processing the specified module in the pipe, it's meant for debugging exactly such issues :-)
|
87aa1b3
to
120e3d0
Compare
Latest version includes a variance lut for performance plus some readability maintenance. (Some NaN issues spotted while testing this are in a bugfix PR for 5.2) |
120e3d0
to
be57df1
Compare
Latest version got some subtle perf gain, more important is improved stability for high-noise underexposed images. Right now i think it's good as is and i would appreciate testing. Please bear in mind, i have squashed and force-pushed the update to keep number of commits low. I am still not convinced about the UI.
|
@jenshannoschwalm do you have suggested settings or at least a good starting point? |
Normally with a strength of 10 would be fine. Evaluate at 100% zoom. |
be57df1
to
f3f3c1a
Compare
Latest version - as usual load the whole pr for testing -
|
f3f3c1a
to
01e36bf
Compare
make it working again with current master, convolution stuff has not changed, the "avoid-noisy-areas" threshold has been improved. |
d6ee037
to
e9a78b3
Compare
force-pushed rebased on master and minor code maintenance, nothing algo-wise changed. |
e9a78b3
to
e435e61
Compare
|
e435e61
to
f36840a
Compare
Ready to go from my side. Latest force-push just has some more aggressive compiler options for CPU performance |
f36840a
to
2b78bea
Compare
Release note suggestion: |
2b78bea
to
203a60a
Compare
Minor code change to make params check happy. |
203a60a
to
edcbeaf
Compare
Capture sharpening has been implemented to work inside the demosaic module so it's raw only. Credits to: Ingo Weyrich (heckflosse67@gmx.de), he implemented the original algorithm for rawtherapee, this implementation is based on his work, especially the convolution kernels. CPU and OpenCL code paths are both available. Demosaic module gets more parameters so there is a version bump, one still unused float parameter has been reserved. A "mini manual" Capture sharpening (CS) tries to recover details lost due to in-camera blurring, which can be caused by diffraction, the anti-aliasing filter or other sources of gaussian-type blur. Prerequisites are - good white balance parameters (same requirement as for highlights reconstruction or demosaic) - no chromatic aberration, you might want to add the "raw chromatic aberration" module - sensor noise will be amplified by CS controls: 1. capture sharpen switches CS on if above zero and defines the strength of overall effect. CS works in an iterative process, this defines the number of iterations, mostly a setting of 10 will be enough. 2. radius defines the basic convolution gaussian sigma. This should not be set by "creative means" but to the blurring radius of the optical system and sensor, too large values will lead to artifacts like halos. Calculating a correct radius is provided internally. This will be done either if you a) click on the button besides the slider b) activate capture sharpen the first time after resetting to demosaic defaults or developing old edits. 3. contrast threshold As sensor noise will be amplified by CS we take some care about this by a per pixel variance analysis and restrict CS to locations with higher variance. The default is good for low to medium ISO images. 4. corner boost Increase the radius in image corners. We assume a circle of 1/2 of image size to be "sharp" (only use main radius), locations outside this center circle get an increased convolution radius.
edcbeaf
to
e6fadb9
Compare
This has been discussed many times here and on pixls.us so here we go. As we have D&S giving good results i was somewhat reluctant to work on this and do a pr but as CS works so good on RT and after a lot of testing (and using this on my personal images for a while with 3 auto applied presets for my fixed-lens camera - one for high-iso with CS turned off and two presets for wide open and "normal") i am pretty confident it's worth it and would be a significant improvement.
(It took quite a while to spot a very bad bug in GPU code leading to system instability and crashes so unfortunately not for 5.2)
Please test in depth and let's decide if this is for master. It's a lot of processing - so not a superfast module.
Capture sharpening has been implemented to work inside the demosaic module so it's raw only.
Credits to: Ingo Weyrich (heckflosse67@gmx.de), he implemented the original algorithm for rawtherapee, this implementation is based on his work, especially the convolution kernels.
CPU and OpenCL code paths are both available.
Demosaic module gets more parameters so there is a version bump, one float has been reserved.
The "mini manual" (regularly updated to latest commit)
Capture sharpening (CS) tries to recover details lost due to in-camera blurring, which can be caused by diffraction, the anti-aliasing filter or other sources of gaussian-type blur. Prerequisites are
Controls
switches CS on if above zero and defines the strength of overall effect.
CS works in an iterative process, this defines the number of iterations, mostly a setting of 10 will be enough.
As downscaling after demosaicing reduces the visibility of CS we reduce iterations in such cases for performance.
defines the basic convolution gaussian sigma.
This should not be set by "creative means" but to the blurring radius of the optical system and sensor, too large values will lead to artifacts like halos.
Calculating a correct radius is provided internally. This will be done either if you
a) click on the button besides the slider
b) activate capture sharpen the first time after resetting to demosaic defaults or developing old edits.
As sensor noise will be amplified by CS we take some care about this by a per pixel variance analysis and use a logistic function with this threshold to avoid CS in noisy areas. The default is good for low iso images.
Increase the radius in image corners. We assume a circle of 1/2 of image size to be "sharp" (only use main radius), locations outside this center circle get an increased convolution radius.