 
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 
-__device__ unsigned char computeSigmaOfL(int x, int y, int r)
-{
-    double xxsum = 0.0;
-    double xsum = 0.0;
-    double count = 0.0;
-
-    for(int xp = -r; xp <= r; xp++)
-    {
-        for(int yp = -r; yp <= r; yp++)
-        {
-            float lValf = 255.0f * (tex2D(r4tex, (float)(x + xp) + 0.5f, (float)(y + yp) + 0.5f).x);
-            double lVal = lValf;
-            xsum += lVal;
-            xxsum += lVal * lVal;
-            count += 1.0;
-        }
-    }
-
-    float sigma = xxsum / count - (xsum * xsum) / (count * count);
-
-    return (unsigned char)(fminf(255.0f, sigma));
-}
-
 __device__ unsigned char computeGradientSizeOfL(int x, int y)
 
 {

    }
}

__global__ void downscale_mean_smooth_lab_kernel(
    uchar4* texLab, int texLab_p,
    int width, int height, int scale)
{
    int x = blockIdx.x * blockDim.x + threadIdx.x;
    int y = blockIdx.y * blockDim.y + threadIdx.y;
    if((x < width) && (y < height))
    {
        float4 t = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
        float sum = 0.0f;
        for(int i = 0; i < scale; i++)
        {
            for(int j = 0; j < scale; j++)
            {
                float4 curPix = 255.0f * tex2D(r4tex, (float)(x * scale + j) + 0.5f, (float)(y * scale + i) + 0.5f);
                t = t + curPix;
                sum += 1.0f;
            }
        }

        t.x = t.x / sum;
        t.y = t.y / sum;
        t.z = t.z / sum;
        t.w = t.w / sum;

        uchar4 tu4 = make_uchar4((unsigned char)t.x, (unsigned char)t.y, (unsigned char)t.z, (unsigned char)t.w);

        *get2DBufferAt(texLab, texLab_p, x, y) = tu4;
    }
}

__global__ void ptsStatForRcDepthMap_kernel(float2* out, int out_p,
                                            float3* pts, int pts_p,
                                            int npts, int width, int height,
                                            int maxNPixSize, int wsh, const float gammaC, const float gammaP)
{
    int ptid = blockIdx.x * blockDim.x + threadIdx.x;

    if(ptid < npts)
    {
        float3 p = pts[ptid];
        float depthP = size(sg_s_rC - p);
        float2 pixf;

        getPixelFor3DPointRC(pixf, p);

        int2 pix = make_int2((int)pixf.x, (int)pixf.y);
        float2 depthVarianceGray = make_float2(0.0f, 0.0f);

        if((pix.x > wsh) && (pix.x < width - wsh) && (pix.y > wsh) && (pix.y < height - wsh))
        {
            float varianceGray = 255.0f * tex2D(r4tex, (float)pix.x + 0.5f, (float)pix.y + 0.5f).w;
            float depth = tex2D(depthsTex, pix.x, pix.y);
            depthVarianceGray = make_float2(depth, varianceGray);
        }

        // TODO!
        out[ptid] = depthVarianceGray;
    }
}

__global__ void getSilhoueteMap_kernel(bool* out, int out_p, int step, int width, int height, const uchar4 maskColorLab)
{
    int x = blockIdx.x * blockDim.x + threadIdx.x;

    }
}

} // namespace depthMap
} // namespace aliceVision
