|
|
|
@ -26,7 +26,7 @@ static void help() |
|
|
|
|
<< 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.type() == CV_8UC1 ); |
|
|
|
@ -42,41 +42,9 @@ static void colorizeDisparity( const Mat& gray, Mat& rgb, double maxDisp=-1.f, f |
|
|
|
|
if( maxDisp < 1 ) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
for( int y = 0; y < gray.rows; y++ ) |
|
|
|
|
{ |
|
|
|
|
for( int x = 0; x < gray.cols; x++ ) |
|
|
|
|
{ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Mat tmp; |
|
|
|
|
convertScaleAbs(gray, tmp, 255.f / maxDisp); |
|
|
|
|
applyColorMap(tmp, rgb, COLORMAP_JET); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static float getMaxDisparity( VideoCapture& capture ) |
|
|
|
|