# HG changeset patch # User Tuomo Valkonen # Date 1714061681 18000 # Node ID 74b1a9f0c35ea7d4c99eea263399c3a4f6fa471e # Parent aca9c90f151c3bf98dd1aa717af854692697768d DualScaling parametrisation diff -r aca9c90f151c -r 74b1a9f0c35e src/AlgorithmDualScaling.jl --- 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 diff -r aca9c90f151c -r 74b1a9f0c35e src/OpticalFlow.jl --- 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 diff -r aca9c90f151c -r 74b1a9f0c35e src/PredictPDPS.jl --- 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))