How to make color balance of photoshop using opencv I want to make the same thing programmatically like Color balance in Photoshop , like in below image



if we have same bar positions in Photoshop then how we can make them in OpenCV , because the problem which I am not understanding is that we have the image with RGB format yes we can convert in other color format but how I can understand these values (do we need to subtract the Cyan values in OpenCV if Cyan Level is -20 in PS ? Or we need to Add ?) and did the same operation in OpenCV ,
For example if I need to change values in Cyan , Magenta and Blue Do I need to convert image first to add values in Cyan and magenta and then convert it back to BGR and then increase blue ?
And is there any built in function in OpenCv for Shadows , MidTones and Highlight 

I am trying something like this

Mat img = imread("E:\\raw_3.jpg");
vector&lt;Mat&gt; colors;
split(img,colors);
colors[0] += 69;
colors[1] += 40 ;
colors[2] -= 23 ;
merge(colors,img);
imshow("image" , img);
imwrite("E:\\color_balance.jpg",img);
waitKey();


for Cyan - red = -23 Magenta - Green = 40 Yellow - Blue = 69 But i am not getting the accurate result as it should be
OpenCV don't have any apis to separate data into lowlight,midtones and highlights.But you can categorize pixels in image into shadows,mid-tones and highlights by setting some thresholds.As they depend on the luminance first convert your image into YUV. If its of 8 bit depth then the pixels with luminance less than 70 are lowlight, pixels ranging from 70 -180 are midtones and 180-255 are highlight. 

When cyan-red is -20,decreasing the red by -20 is just not enough. Because it will also affect the luminance of the image. So instead of decreasing red by 20 decrease it by 10 and increase green and blue by 5. Decreasing the red is same as increasing blue and green,while it also maintains the luminance. You can do the same for Magenta-Green and Yellow-Blue. Hope this helps you.