mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
Make imagelib MathUtil
This commit is contained in:
+3
-4
@@ -7,6 +7,9 @@ import com.dfsek.terra.addons.image.util.ColorUtil;
|
|||||||
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
|
import static com.dfsek.terra.addons.image.util.MathUtil.lerp;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes a 2D distance transform of a given image and stores the result in a 2D array of distances.
|
* Computes a 2D distance transform of a given image and stores the result in a 2D array of distances.
|
||||||
* Implementation based on the algorithm described in the paper
|
* Implementation based on the algorithm described in the paper
|
||||||
@@ -190,10 +193,6 @@ public class DistanceTransform {
|
|||||||
this.maxDistance = maxDistance;
|
this.maxDistance = maxDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double lerp(double x, double x1, double y1, double x2, double y2) {
|
|
||||||
return (((y1-y2)*(x-x1))/(x1-x2))+y1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CostFunction {
|
public enum CostFunction {
|
||||||
Channel,
|
Channel,
|
||||||
Threshold,
|
Threshold,
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.dfsek.terra.addons.image.util;
|
||||||
|
|
||||||
|
public class MathUtil {
|
||||||
|
private MathUtil() {}
|
||||||
|
|
||||||
|
public static double lerp(double x, double x1, double y1, double x2, double y2) {
|
||||||
|
return (((y1-y2)*(x-x1))/(x1-x2))+y1;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user