diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-04-06 01:32:35 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-04-06 01:32:35 +0200 |
commit | f5d47edb24d3eba9e4666a37e8d448d1582a6ad2 (patch) | |
tree | 292b9c8169a780046e8807e1aeed366f85e20277 | |
parent | forgot the license (diff) | |
download | blueshift-f5d47edb24d3eba9e4666a37e8d448d1582a6ad2.tar.gz blueshift-f5d47edb24d3eba9e4666a37e8d448d1582a6ad2.tar.bz2 blueshift-f5d47edb24d3eba9e4666a37e8d448d1582a6ad2.tar.xz |
optimisation to cubic interpolation: remove a basis function by doing an value translation
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/interpolation.py | 4 | ||||
-rwxr-xr-x | test/cubic_interpolation | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/interpolation.py b/src/interpolation.py index e81c93c..409bbdc 100644 --- a/src/interpolation.py +++ b/src/interpolation.py @@ -61,7 +61,7 @@ def cubicly_interpolate_ramp(r, g, b, tension = 0): # TODO demo and document ten C = lambda c : c[:] if len(c) >= o_size else ([None] * o_size) R, G, B = C(r), C(g), C(b) # Basis functions - h00 = lambda t : (1 + 2 * t) * (1 - t) ** 2 + #h00 = lambda t : (1 + 2 * t) * (1 - t) ** 2 h10 = lambda t : t * (1 - t) ** 2 h01 = lambda t : t ** 2 * (3 - 2 * t) h11 = lambda t : t ** 2 * (t - 1) @@ -95,7 +95,7 @@ def cubicly_interpolate_ramp(r, g, b, tension = 0): # TODO demo and document ten # Tangents mj, mk = c_ * tangent(small, j, small_), c_ * tangent(small, k, small_) # Interpolation - large[i] = h00(w) * pj + h10(w) * mj + h01(w) * pk + h11(w) * mk + large[i] = pj + h10(w) * mj + h01(w) * (pk - pj) + h11(w) * mk ## Check local monotonicity eliminate_halos(r, g, b, R, G, B) return (R, G, B) diff --git a/test/cubic_interpolation b/test/cubic_interpolation index 6346547..dac0d99 100755 --- a/test/cubic_interpolation +++ b/test/cubic_interpolation @@ -79,7 +79,7 @@ def interpolate(small, tension = 0): large = [None] * len(small) ** 2 small_, large_ = len(small) - 1, len(large) - 1 # Basis functions - h00 = lambda t : (1 + 2 * t) * (1 - t) ** 2 + #h00 = lambda t : (1 + 2 * t) * (1 - t) ** 2 h10 = lambda t : t * (1 - t) ** 2 h01 = lambda t : t ** 2 * (3 - 2 * t) h11 = lambda t : t ** 2 * (t - 1) @@ -108,7 +108,7 @@ def interpolate(small, tension = 0): # Tangents mj, mk = c_ * tangent(small, j, small_), c_ * tangent(small, k, small_) # Interpolation - large[i] = h00(w) * pj + h10(w) * mj + h01(w) * pk + h11(w) * mk + large[i] = pj + h10(w) * mj + h01(w) * (pk - pj) + h11(w) * mk return large # Plot interpolation |