From 4375393c9927871f844a3c4b37dc4da5efaa1a94 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sun, 6 Oct 2019 18:21:45 +0300
Subject: [PATCH] Colour confidence

---
 applications/reconstruct/src/ilw/ilw.cu | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/applications/reconstruct/src/ilw/ilw.cu b/applications/reconstruct/src/ilw/ilw.cu
index 534b071cd..773301dae 100644
--- a/applications/reconstruct/src/ilw/ilw.cu
+++ b/applications/reconstruct/src/ilw/ilw.cu
@@ -141,6 +141,8 @@ __global__ void correspondence_energy_vector_kernel(
 
 	float bestdepth = 0.0f;
 	float bestweight = 0.0f;
+	float bestcolour = 0.0f;
+	float totalcolour = 0.0f;
 	int count = 0;
 	float contrib = 0.0f;
     
@@ -176,14 +178,16 @@ __global__ void correspondence_energy_vector_kernel(
 
 		++count;
 		contrib += weight;
+		bestcolour = max(cweight, bestcolour);
+		totalcolour += cweight;
 		if (weight > bestweight) {
 			bestweight = weight;
 			bestdepth = depth_adjust;
 		}
     }
 
-	const float avgweight = contrib/(float)count;
-    const float confidence = bestweight - avgweight;
+	const float avgcolour = totalcolour/(float)count;
+    const float confidence = bestcolour - avgcolour;
 
     if (bestweight > 0.0f) {
         float old = conf.tex2D(x,y);
-- 
GitLab