DualScaling parametrisation

Thu, 25 Apr 2024 11:14:41 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Thu, 25 Apr 2024 11:14:41 -0500
changeset 35
74b1a9f0c35e
parent 34
aca9c90f151c
child 36
e4a8f662a1ac

DualScaling parametrisation

src/AlgorithmDualScaling.jl file | annotate | diff | comparison | revisions
src/OpticalFlow.jl file | annotate | diff | comparison | revisions
src/PredictPDPS.jl file | annotate | diff | comparison | revisions
--- a/src/AlgorithmDualScaling.jl	Thu Apr 25 11:16:24 2024 -0500
+++ b/src/AlgorithmDualScaling.jl	Thu Apr 25 11:14:41 2024 -0500
@@ -51,15 +51,16 @@
                iterate = AlgTools.simple_iterate,
                params::NamedTuple) where DisplacementT
 
-    ################################                                        
+    ################################
     # Extract and set up parameters
-    ################################                    
+    ################################
 
     α, ρ = params.α, params.ρ
     R_K² = ∇₂_norm₂₂_est²
     γ = 1.0
     Λ = params.Λ
     τ₀, σ₀ = params.τ₀, params.σ₀
+    ds = DualScaling(params.ds_exponent, params.ds_threshold)
 
     τ = τ₀/γ
     @assert(1+γ*τ ≥ Λ)
@@ -91,7 +92,7 @@
             init_data = false
         end
 
-        pdflow!(x, Δx, y, Δy, v_known, DualScaling())
+        pdflow!(x, Δx, y, Δy, v_known, ds)
 
         ############
         # PDPS step
@@ -108,7 +109,7 @@
         ################################
         # Give function value if needed
         ################################
-        v = verbose() do            
+        v = verbose() do
             ∇₂!(Δy, x)
             value = norm₂²(b-x)/2 + params.α*γnorm₂₁(Δy, params.ρ)
             value, x, [NaN, NaN], nothing
--- a/src/OpticalFlow.jl	Thu Apr 25 11:16:24 2024 -0500
+++ b/src/OpticalFlow.jl	Thu Apr 25 11:14:41 2024 -0500
@@ -60,7 +60,12 @@
 #################################
 # Struct for flow
 #################################
-struct DualScaling end
+struct DualScaling
+    exponent :: Integer
+    threshold :: Real
+    DualScaling(e = 10, t = 1e-1) = new(e, t)
+end
+
 struct Greedy end
 struct Rotation end
 
@@ -164,8 +169,8 @@
     flow!(x, u; threads=(threads==:inner))
     C = similar(y)
     cc = abs.(x-oldx)
-    cm = max(1e-12,maximum(cc))
-    c = 1 .* (1 .- cc./ cm) .^(10)
+    cm = max(flow.threshold,maximum(cc))
+    c = 1 .* (1 .- cc./ cm) .^flow.exponent
     C[1,:,:] .= c
     C[2,:,:] .= c
     y .= C.*y 
--- a/src/PredictPDPS.jl	Thu Apr 25 11:16:24 2024 -0500
+++ b/src/PredictPDPS.jl	Thu Apr 25 11:14:41 2024 -0500
@@ -139,6 +139,8 @@
     init = :zero,
     plot_movement = false,
     stable_interval = Set(0),
+    ds_exponent = 10,
+    ds_threshold = 10e-12
 )
 
 const square = imgen_square((200, 300))

mercurial