 
                         for(int y = 0; y < len; ++y)
                         {
-                            val += DataCostPerPixel<channels>::compute(lle, lri);
+                            val += pixeldiff<channels>(lle, lri);
 
                             lle += cimg_step;
                             lri += cimg_step;

        /////////////////////// init data cost ////////////////////////
        ///////////////////////////////////////////////////////////////

        template <int channels> struct DataCostPerPixel;
        template <> struct DataCostPerPixel<1>
        {
            static __device__ __forceinline__ float compute(const uchar* left, const uchar* right)
            {
                return cdata_weight * fmin( ::abs((int)*left - *right), cmax_data_term);
            }
        };
        template <> struct DataCostPerPixel<3>
        {
            static __device__ __forceinline__ float compute(const uchar* left, const uchar* right)
            {
                float tb = 0.114f * ::abs((int)left[0] - right[0]);
                float tg = 0.587f * ::abs((int)left[1] - right[1]);
                float tr = 0.299f * ::abs((int)left[2] - right[2]);

                return cdata_weight * fmin(tr + tg + tb, cmax_data_term);
            }
        };
        template <> struct DataCostPerPixel<4>
        {
            static __device__ __forceinline__ float compute(const uchar* left, const uchar* right)
            {
                uchar4 l = *((const uchar4*)left);
                uchar4 r = *((const uchar4*)right);

                float tb = 0.114f * ::abs((int)l.x - r.x);
                float tg = 0.587f * ::abs((int)l.y - r.y);
                float tr = 0.299f * ::abs((int)l.z - r.z);

                return cdata_weight * fmin(tr + tg + tb, cmax_data_term);
            }
        };

        template <typename T>
        __global__ void get_first_k_initial_global(uchar *ctemp, T* data_cost_selected_, T *selected_disp_pyr, int h, int w, int nr_plane, int ndisp)

                                const uchar* left_x = cleft + yi * cimg_step + xi * channels;
                                const uchar* right_x = cright + yi * cimg_step + xr * channels;

                                val += pixeldiff<channels>(left_x, right_x);
                            }
                        }
                    }
