Beep6581 / RawTherapee

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

Improve HSV #5429

Open Ripple-qin opened 4 years ago

Ripple-qin commented 4 years ago

Hello, author, thank you for the open source so easy to use image processing library. When accessing the HSV function, we encountered a problem and wanted to get some suggestions from you.

1:S adjustment degree is too small compared to lightroom. May I ask the parameter of the following algorithm to make the degree of S adjustment become larger?

 if (sCurveEnabled) {                                                            
     //shift saturation                                                          
     float satparam = (sCurve->getVal (double (h)) - 0.5) * 2;                   

     if (satparam > 0.00001f) {                                                  
         s = (1.f - satparam) * s + satparam * (1.f - SQR (1.f - min (s, 1.0f)));

         if (s < 0.f) {                                                          
             s = 0.f;                                                            
         }                                                                       
     } else if (satparam < -0.00001f) {                                          
         s *= 1.f + satparam;                                                    
     }                                                                           

 }                                                                               

2: The degree of V adjustment is too small compared to lightroom. Can the parameter of the following algorithm make the degree of V adjustment become larger?

if (vCurveEnabled) {                                                                                                                 
    if (v < 0) {                                                                                                                     
        v = 0;    // important                                                                                                       
    }                                                                                                                                

    //shift value                                                                                                                    
    float valparam = vCurve->getVal ((double)h) - 0.5f;                                                                              
    valparam *= (1.f - SQR (SQR (1.f - min (s, 1.0f))));                                                                             

    if (valparam > 0.00001f) {                                                                                                       
        v = (1.f - valparam) * v + valparam * (1.f - SQR (1.f - min (v, 1.0f))); // SQR (SQR  to increase action and avoid artifacts 

        if (v < 0) {                                                                                                                 
            v = 0;                                                                                                                   
        }                                                                                                                            
    } else {                                                                                                                         
        if (valparam < -0.00001f) {                                                                                                  
            v *= (1.f + valparam);    //1.99 to increase action                                                                      
        }                                                                                                                            
    }                                                                                                                                

}                                                                                                                                    

3: After adjusting the H of the picture, then adjust S again, basically there is no change. Is it possible to put the adjustment of S and V before H?

In order to solve the problem of insufficient adjustment of S and V, I currently try to enlarge the maximum control point of the curve from 1 to 2.0, so that the user can adjust the larger range, but the problem is that the color transition is not smooth and relatively blunt.

Thanks for your support in advance.

Hombre57 commented 4 years ago

@pinguo-wangqinlong I'll have a look this w.e.

Hombre57 commented 4 years ago

@Beep6581 So the pinned item are common to all users ?

Hombre57 commented 4 years ago

@pinguo-wangqinlong You could try this patch, to more than double the power of the effect.

However could you show us a use case of such high S/V shift (without artifact) ?

diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc
index 23dc4b1..55c0f63 100644
--- a/rtengine/improcfun.cc
+++ b/rtengine/improcfun.cc
@@ -2718,7 +2718,7 @@
                                 float satparam = (sCurve->getVal (double (h)) - 0.5) * 2;

                                 if (satparam > 0.00001f) {
-                                    s = (1.f - satparam) * s + satparam * (1.f - SQR (1.f - min (s, 1.0f)));
+                                    s = (1.f - satparam) * s + satparam * (1.f - rtengine::pow4 (1.f - min (s, 1.0f)));

                                     if (s < 0.f) {
                                         s = 0.f;
@@ -2736,10 +2736,10 @@

                                 //shift value
                                 float valparam = vCurve->getVal ((double)h) - 0.5f;
-                                valparam *= (1.f - SQR (SQR (1.f - min (s, 1.0f))));
+                                valparam *= (1.f - rtengine::pow4 (1.f - min (s, 1.0f)));

                                 if (valparam > 0.00001f) {
-                                    v = (1.f - valparam) * v + valparam * (1.f - SQR (1.f - min (v, 1.0f))); // SQR (SQR  to increase action and avoid artifacts
+                                    v = (1.f - valparam) * v + valparam * (1.f - SQR ( rtengine::pow4 (1.f - min (v, 1.0f)))); // SQR (SQR  to increase action and avoid artifacts

                                     if (v < 0) {
                                         v = 0;
Beep6581 commented 4 years ago

Hey @Hombre57 , yes, pinned issues are visible as such for everyone: https://github.blog/changelog/2018-12-13-pinned-issues/

Ripple-qin commented 4 years ago

I will try it and feedback soon. thanks for your strong support.

Ripple-qin commented 4 years ago

We are developing a photo editing software that has a function to adjust HSL. We found that RawTherapee's HSV effect is the best and close to lightRoom. (We know that HSL and HSV are a little different.), but we refer to the HSL effect of lightRoom, Our effects designer found that the S and V effects of RawTherapee's HSV function are too small, which is whyI asked the reason for this question,

I just experimented with your solution. The degree of S and V is much better than before. Thank you for your help again, I will continue to test and feedback the results.