Commit 1533d044 authored by Aaron Denney's avatar Aaron Denney

cdata_weight always positive; fewer multiplications.

parent d848704b
...@@ -103,7 +103,7 @@ namespace cv { namespace cuda { namespace device ...@@ -103,7 +103,7 @@ namespace cv { namespace cuda { namespace device
{ {
static __device__ __forceinline__ float compute(const uchar* left, const uchar* right) static __device__ __forceinline__ float compute(const uchar* left, const uchar* right)
{ {
return fmin(cdata_weight * ::abs((int)*left - *right), cdata_weight * cmax_data_term); return cdata_weight * fmin( ::abs((int)*left - *right), cmax_data_term);
} }
}; };
template <> struct DataCostPerPixel<3> template <> struct DataCostPerPixel<3>
...@@ -114,7 +114,7 @@ namespace cv { namespace cuda { namespace device ...@@ -114,7 +114,7 @@ namespace cv { namespace cuda { namespace device
float tg = 0.587f * ::abs((int)left[1] - right[1]); float tg = 0.587f * ::abs((int)left[1] - right[1]);
float tr = 0.299f * ::abs((int)left[2] - right[2]); float tr = 0.299f * ::abs((int)left[2] - right[2]);
return fmin(cdata_weight * (tr + tg + tb), cdata_weight * cmax_data_term); return cdata_weight * fmin(tr + tg + tb, cmax_data_term);
} }
}; };
template <> struct DataCostPerPixel<4> template <> struct DataCostPerPixel<4>
...@@ -128,7 +128,7 @@ namespace cv { namespace cuda { namespace device ...@@ -128,7 +128,7 @@ namespace cv { namespace cuda { namespace device
float tg = 0.587f * ::abs((int)l.y - r.y); float tg = 0.587f * ::abs((int)l.y - r.y);
float tr = 0.299f * ::abs((int)l.z - r.z); float tr = 0.299f * ::abs((int)l.z - r.z);
return fmin(cdata_weight * (tr + tg + tb), cdata_weight * cmax_data_term); return cdata_weight * fmin(tr + tg + tb, cmax_data_term);
} }
}; };
......
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