summaryrefslogtreecommitdiffstats
path: root/Third_Party
diff options
context:
space:
mode:
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)