From 5419353a69689b457e9d0fd2d98c450bf83a3579 Mon Sep 17 00:00:00 2001 From: Lijun Zhu Date: Mon, 11 Jan 2021 15:42:28 -0800 Subject: [PATCH] PyCuAmpcor: fix the correlation surface variance estimation --- contrib/PyCuAmpcor/src/cuEstimateStats.cu | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/PyCuAmpcor/src/cuEstimateStats.cu b/contrib/PyCuAmpcor/src/cuEstimateStats.cu index 7d31673..18412bf 100644 --- a/contrib/PyCuAmpcor/src/cuEstimateStats.cu +++ b/contrib/PyCuAmpcor/src/cuEstimateStats.cu @@ -46,7 +46,7 @@ void cuEstimateSnr(cuArrays *corrSum, cuArrays *corrValidCount, cuAr } // cuda kernel for cuEstimateVariance -__global__ void cudaKernel_estimateVar(const float* corrBatchRaw, const int NX, const int NY, const int2* maxloc, +__global__ void cudaKernel_estimateVar(const float* corrBatchRaw, const int NX, const int NY, const int2* maxloc, const float* maxval, const int templateSize, float3* covValue, const int size) { @@ -78,11 +78,12 @@ __global__ void cudaKernel_estimateVar(const float* corrBatchRaw, const int NX, int idx21 = offset + (px + 1) * NY + py ; int idx22 = offset + (px + 1) * NY + py + 1; - float dxx = - ( corrBatchRaw[idx21] + corrBatchRaw[idx01] - 2*corrBatchRaw[idx11] ) * 1.0; - float dyy = - ( corrBatchRaw[idx12] + corrBatchRaw[idx10] - 2*corrBatchRaw[idx11] ) * 1.0; + // second-order derivatives + float dxx = - ( corrBatchRaw[idx21] + corrBatchRaw[idx01] - 2.0*corrBatchRaw[idx11] ); + float dyy = - ( corrBatchRaw[idx12] + corrBatchRaw[idx10] - 2.0*corrBatchRaw[idx11] ) ; float dxy = ( corrBatchRaw[idx22] + corrBatchRaw[idx00] - corrBatchRaw[idx20] - corrBatchRaw[idx02] ) *0.25; - float n2 = fmaxf(1 - peak, 0.0); + float n2 = fmaxf(1.0 - peak, 0.0); dxx = dxx * templateSize; dyy = dyy * templateSize; @@ -95,10 +96,9 @@ __global__ void cudaKernel_estimateVar(const float* corrBatchRaw, const int NX, float u = dxy * dxy - dxx * dyy; float u2 = u*u; + // if the Gaussian curvature is too small if (fabsf(u) < 1e-2) { - - covValue[idxImage] = make_float3(99.0, 99.0, 99.0); - + covValue[idxImage] = make_float3(99.0, 99.0, 0.0); } else { float cov_xx = (- n2 * u * dyy + n4 * ( dyy*dyy + dxy*dxy) ) / u2;