rewrote color conversion functions; added sRGB<->CIE Lab/Luv conversion; added RGB<->YUV conversion; improved [s]RGB->Lab conversion speed
This commit is contained in:
@@ -3266,6 +3266,41 @@ partition( const vector<_Tp>& _vec, vector<int>& labels,
|
||||
return nclasses;
|
||||
}
|
||||
|
||||
// computes cubic spline coefficients for a function: (xi=i, yi=f[i]), i=0..n
|
||||
template<typename _Tp> static void splineBuild(const _Tp* f, int n, _Tp* tab)
|
||||
{
|
||||
_Tp cn = 0;
|
||||
int i;
|
||||
tab[0] = tab[1] = (_Tp)0;
|
||||
|
||||
for(i = 1; i < n-1; i++)
|
||||
{
|
||||
_Tp t = 3*(f[i+1] - 2*f[i] + f[i-1]);
|
||||
_Tp l = 1/(4 - tab[(i-1)*4]);
|
||||
tab[i*4] = l; tab[i*4+1] = (t - tab[(i-1)*4+1])*l;
|
||||
}
|
||||
|
||||
for(i = n-1; i >= 0; i--)
|
||||
{
|
||||
_Tp c = tab[i*4+1] - tab[i*4]*cn;
|
||||
_Tp b = f[i+1] - f[i] - (cn + c*2)*(_Tp)0.3333333333333333;
|
||||
_Tp d = (cn - c)*(_Tp)0.3333333333333333;
|
||||
tab[i*4] = f[i]; tab[i*4+1] = b;
|
||||
tab[i*4+2] = c; tab[i*4+3] = d;
|
||||
cn = c;
|
||||
}
|
||||
}
|
||||
|
||||
// interpolates value of a function at x, 0 <= x <= n using a cubic spline.
|
||||
template<typename _Tp> static inline _Tp splineInterpolate(_Tp x, const _Tp* tab, int n)
|
||||
{
|
||||
int ix = cvFloor(x);
|
||||
ix = std::min(std::max(ix, 0), n-1);
|
||||
x -= ix;
|
||||
tab += ix*4;
|
||||
return ((tab[3]*x + tab[2])*x + tab[1])*x + tab[0];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// bridge C++ => C Seq API
|
||||
|
@@ -206,6 +206,21 @@ enum
|
||||
CV_HLS2BGR_FULL = 72,
|
||||
CV_HLS2RGB_FULL = 73,
|
||||
|
||||
CV_LBGR2Lab = 74,
|
||||
CV_LRGB2Lab = 75,
|
||||
CV_LBGR2Luv = 76,
|
||||
CV_LRGB2Luv = 77,
|
||||
|
||||
CV_Lab2LBGR = 78,
|
||||
CV_Lab2LRGB = 79,
|
||||
CV_Luv2LBGR = 80,
|
||||
CV_Luv2LRGB = 81,
|
||||
|
||||
CV_BGR2YUV = 82,
|
||||
CV_RGB2YUV = 83,
|
||||
CV_YUV2BGR = 84,
|
||||
CV_YUV2RGB = 85,
|
||||
|
||||
CV_COLORCVT_MAX =100
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user