PyCuAmpcor: fix the correlation surface variance estimation

LT1AB
Lijun Zhu 2021-01-11 15:42:28 -08:00
parent d5e5067acd
commit 5419353a69
1 changed files with 7 additions and 7 deletions

View File

@ -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;