this for c#, apply clahe for rgb images.
private static Image<Bgr, byte> appy_CLAHE( Image<Bgr, byte> imgIn , int clipLimit=2, int tileSize=25)
{
var imglabcol = new Image<Lab, byte>(imgIn.Size);
var imgoutL = new Image<Gray, byte>(imgIn.Size);
var imgoutBGR = new Image<Bgr, byte>(imgIn.Size);
//clahe filter must be applied on luminance channel or grayscale image
CvInvoke.CvtColor(imgIn, imglabcol, ColorConversion.Bgr2Lab, 0);
CvInvoke.CLAHE(imglabcol[0], clipLimit, new Size(tileSize, tileSize), imgoutL);
imglabcol[0] = imgoutL; // write clahe results on Lum channel into image
CvInvoke.CvtColor(imglabcol, imgoutBGR, ColorConversion.Lab2Bgr, 0);
return imgoutBGR;
}