38 x̄ = copy(x) |
39 x̄ = copy(x) |
39 |
40 |
40 return x, y, Δx, Δy, x̄ |
41 return x, y, Δx, Δy, x̄ |
41 end |
42 end |
42 |
43 |
43 function init_iterates(xinit::Image, b) |
44 function init_primal(xinit::Image, b) |
44 return init_rest(copy(xinit)) |
45 return copy(xinit) |
45 end |
46 end |
46 |
47 |
47 function init_iterates(xinit::Nothing, b :: Image) |
48 function init_primal(xinit::Nothing, b :: Image) |
48 return init_rest(zeros(size(b)...)) |
49 return zeros(size(b)...) |
49 end |
50 end |
|
51 |
50 |
52 |
51 ############ |
53 ############ |
52 # Algorithm |
54 # Algorithm |
53 ############ |
55 ############ |
54 |
56 |
55 function denoise_pdps(b :: Image; |
57 function denoise_pdps(b :: Image; |
56 xinit :: Union{Image,Nothing} = nothing, |
58 xinit :: Union{Image,Nothing} = nothing, |
57 iterate = AlgTools.simple_iterate, |
59 iterate = AlgTools.simple_iterate, |
58 params::NamedTuple) where DisplacementT |
60 params::NamedTuple) |
59 |
61 |
60 ################################ |
62 ################################ |
61 # Extract and set up parameters |
63 # Extract and set up parameters |
62 ################################ |
64 ################################ |
63 |
65 |
73 |
75 |
74 ###################### |
76 ###################### |
75 # Initialise iterates |
77 # Initialise iterates |
76 ###################### |
78 ###################### |
77 |
79 |
78 x, y, Δx, Δy, x̄ = init_iterates(xinit, b) |
80 x, y, Δx, Δy, x̄ = init_rest(init_primal(xinit, b)) |
79 |
81 |
80 #################### |
82 #################### |
81 # Run the algorithm |
83 # Run the algorithm |
82 #################### |
84 #################### |
83 |
85 |
109 end |
111 end |
110 |
112 |
111 return x, y, v |
113 return x, y, v |
112 end |
114 end |
113 |
115 |
|
116 function denoise_fista(b :: Image; |
|
117 xinit :: Union{Image,Nothing} = nothing, |
|
118 iterate = AlgTools.simple_iterate, |
|
119 params::NamedTuple) |
|
120 |
|
121 ################################ |
|
122 # Extract and set up parameters |
|
123 ################################ |
|
124 |
|
125 α, ρ = params.α, params.ρ |
|
126 τ₀ = params.τ₀ |
|
127 τ = τ₀/∇₂_norm₂₂_est² |
|
128 |
|
129 ###################### |
|
130 # Initialise iterates |
|
131 ###################### |
|
132 |
|
133 x = init_primal(xinit, b) |
|
134 imdim = size(x) |
|
135 Δx = similar(x) |
|
136 y = zeros(2, imdim...) |
|
137 ỹ = copy(y) |
|
138 y⁻ = similar(y) |
|
139 Δy = similar(y) |
|
140 |
|
141 #################### |
|
142 # Run the algorithm |
|
143 #################### |
|
144 |
|
145 t = 0 |
|
146 |
|
147 v = iterate(params) do verbose :: Function |
|
148 ∇₂ᵀ!(Δx, ỹ) |
|
149 @. Δx .-= b |
|
150 ∇₂!(Δy, Δx) |
|
151 @. y⁻ = y |
|
152 @. y = (ỹ - τ*Δy)/(1 + τ*ρ/α) |
|
153 proj_norm₂₁ball!(y, α) |
|
154 t⁺ = (1+√(1+4*t^2))/2 |
|
155 @. ỹ = y+((t-1)/t⁺)*(y-y⁻) |
|
156 t = t⁺ |
|
157 |
|
158 ################################ |
|
159 # Give function value if needed |
|
160 ################################ |
|
161 v = verbose() do |
|
162 ∇₂ᵀ!(Δx, y) |
|
163 @. x = b - Δx |
|
164 ∇₂!(Δy, x) |
|
165 value = norm₂²(b-x)/2 + params.α*γnorm₂₁(Δy, params.ρ) |
|
166 value, x |
|
167 end |
|
168 |
|
169 v |
|
170 end |
|
171 |
|
172 ∇₂ᵀ!(Δx, y) |
|
173 @. x = b - Δx |
|
174 |
|
175 return x, y, v |
|
176 end |
|
177 |
114 end # Module |
178 end # Module |
115 |
179 |
116 |
180 |