Commit ed63c43c authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #11519 from paroj:openni_color

parents 3104d2f7 95736443
...@@ -26,7 +26,7 @@ static void help() ...@@ -26,7 +26,7 @@ static void help()
<< endl; << endl;
} }
static void colorizeDisparity( const Mat& gray, Mat& rgb, double maxDisp=-1.f, float S=1.f, float V=1.f ) static void colorizeDisparity( const Mat& gray, Mat& rgb, double maxDisp=-1.f)
{ {
CV_Assert( !gray.empty() ); CV_Assert( !gray.empty() );
CV_Assert( gray.type() == CV_8UC1 ); CV_Assert( gray.type() == CV_8UC1 );
...@@ -42,41 +42,9 @@ static void colorizeDisparity( const Mat& gray, Mat& rgb, double maxDisp=-1.f, f ...@@ -42,41 +42,9 @@ static void colorizeDisparity( const Mat& gray, Mat& rgb, double maxDisp=-1.f, f
if( maxDisp < 1 ) if( maxDisp < 1 )
return; return;
for( int y = 0; y < gray.rows; y++ ) Mat tmp;
{ convertScaleAbs(gray, tmp, 255.f / maxDisp);
for( int x = 0; x < gray.cols; x++ ) applyColorMap(tmp, rgb, COLORMAP_JET);
{
uchar d = gray.at<uchar>(y,x);
unsigned int H = ((uchar)maxDisp - d) * 240 / (uchar)maxDisp;
unsigned int hi = (H/60) % 6;
float f = H/60.f - H/60;
float p = V * (1 - S);
float q = V * (1 - f * S);
float t = V * (1 - (1 - f) * S);
Point3f res;
if( hi == 0 ) //R = V, G = t, B = p
res = Point3f( p, t, V );
if( hi == 1 ) // R = q, G = V, B = p
res = Point3f( p, V, q );
if( hi == 2 ) // R = p, G = V, B = t
res = Point3f( t, V, p );
if( hi == 3 ) // R = p, G = q, B = V
res = Point3f( V, q, p );
if( hi == 4 ) // R = t, G = p, B = V
res = Point3f( V, p, t );
if( hi == 5 ) // R = V, G = p, B = q
res = Point3f( q, p, V );
uchar b = (uchar)(std::max(0.f, std::min (res.x, 1.f)) * 255.f);
uchar g = (uchar)(std::max(0.f, std::min (res.y, 1.f)) * 255.f);
uchar r = (uchar)(std::max(0.f, std::min (res.z, 1.f)) * 255.f);
rgb.at<Point3_<uchar> >(y,x) = Point3_<uchar>(b, g, r);
}
}
} }
static float getMaxDisparity( VideoCapture& capture ) static float getMaxDisparity( VideoCapture& capture )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment