-
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
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
7d4e6e5
to
3179194
Compare
@TurboGit @da-phil @weltyj friends i think i have sorted it out in an acceptable (for us all) way.
So ready for reviewing pascal. |
3179194
to
53eab9a
Compare
perfect and done |
@jenshannoschwalm I'm not sure what happened but capture.c looks like it didn't change at all after your last update to your github branch... |
You are looking at the wrong code, it's in demosaic |
Capture sharpening has been implemented to work inside the demosaic module so it's raw only. Credits to: Ingo Weyrich ([email protected]), 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, the module requires a version bump. 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) - low chromatic aberration, you might want to add the "raw chromatic aberration" module - low sensor noise as that will be amplified by CS All controls for capture sharpening are within a collapsible UI section. You will find: 1. 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, a value of 10 is mostly enough. 2. radius defines the basic convolution gaussian sigma. This should not be set by "creative means" but according to the blurring radius of the optical system and sensor, too large values will lead to artifacts like halos or ringing pretty fast especially with large 'sharpen' settings. 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 defaults or developing old edits. 3. edge sensitivity As sensor noise will be amplified by CS we take some care about this by a local variance and luminance analysis and restrict CS to locations with higher variance. The default is good for low to medium ISO images. Very noisy images will require larger values than default, with low sensor noise you can decrease this to improve capture sharpening also in dark parts of the image. Note the mask button at the right visualizing the sharpened locations. 4. corner boost Increase the convolution radius in image corners outside the sharp centre. 5. sharp centre (only available with corner boost) Define the central part of the image using the main radius for correction. Note the mask button at the right visualizing the overall radius.
For masks and alike we often need a CLIP() equivalent, instead of using clamp(x, 0.0f, 1.0f) in such cases we have an inline function clipf()
53eab9a
to
c24fd9a
Compare
Just a fix for sharpening at image borders |
Thank you so much, this looks perfect now 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This UI is far better to me and integrate well with current dt UI. Well done, no more comment on my side, works great. Thanks @jenshannoschwalm for this great piece of work.
Indeed @jenshannoschwalm , thanks for all the hard work and seeing it through. Time to pull the cork on the champagne! |
Thanks, there is soon coming more work for you :-) |
Sounds like fun :-) |
Happy to see a long awaited feature in the works @jenshannoschwalm!
I interpret this as settings will scale internally with the resolution of the image? As an example, will the radius be “internally” higher for a 61MP image than a 24MP image? If not, users will have to calculate to dial in and calculate to get the same amount of capture sharpening on images from different MP sensors. |
It's in absolute pixels. |
Yes, different sensors, different lens, different settings :-) |
In my testing of this, I have been missing an option to turn it off and on easily. Obviously the Demosaic module can't be turned off, so you just have to slide the Sharpen iterations to zero and then back up again. It's a bit cumbersome. I imagine this was done to reduce clutter, but would it make sense to have an "eye" icon like we have for masks so we can quickly turn the effect off and on again? |
Feel free to implement this :-) |
but would it make sense to have an "eye" icon like we have for masks so we can quickly turn the effect off and on again @europlatus A checkbox "[ ] enable capture sharpening" would be more appropriate than an eye icon. |
Yes, a checkbox might be used/added but i'd prefer to keep the UI as small as possible. If someone wants to propose an idea, feel free to open a PR so we can test/discuss. |
I thought of that too, but the sharpening slider currently functions as an On/Off button as well, so a checkbox potentially adds unnecessary clicks (one click for the dropdown, one for the checkbox, and one for the slider). Another idea would be for the dropdown arrow to auto enable/disable capture sharpening, so you could click that to turn the effect on and off. But this would mean having the module always expanded if you want capture sharpening on. I'll open a feature request to continue this discussion... |
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 ([email protected]), 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.
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.
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.
Note the visualizing button at the right.
Increase the convolution radius in image corners outside the sharp centre.
Define the "sharp" centre part of the image
Note the visualizing button at the right.