summaryrefslogtreecommitdiffstats
path: root/Third_Party
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-02-02 16:20:12 -0800
committeryum <yum.food.vr@gmail.com>2025-02-02 16:20:17 -0800
commit5f819329a161d54076d025d6f61656f262094c07 (patch)
treeacba27050736f2296206fb0dc52f4cd2e9bb29bb /Third_Party
parent03406b0983e123bb3203a96bfd2f017e58e3e90d (diff)
Finish reproducing SSFD tech
Fix gen_sdf so it normalizes all SDFs
Diffstat (limited to 'Third_Party')
-rw-r--r--Third_Party/gen_sdf6
1 files changed, 4 insertions, 2 deletions
diff --git a/Third_Party/gen_sdf b/Third_Party/gen_sdf
index 84677c2..2f0e3a6 100644
--- a/Third_Party/gen_sdf
+++ b/Third_Party/gen_sdf
@@ -16,8 +16,10 @@ def compute_sdf(img, scale_factor):
# Combine the distance fields and scale by factor
sdf = (dist_transform_fg - dist_transform_bg) / scale_factor
- # Clamp values to [0, 255] range
- sdf = np.clip(sdf + 128, 0, 255)
+ # Normalize values to [0, 255] range
+ sdf_min = np.min(sdf)
+ sdf_max = np.max(sdf)
+ sdf = ((sdf - sdf_min) * 255 / (sdf_max - sdf_min))
return sdf.astype(np.uint8)