src/Denoise.jl

Wed, 15 Dec 2021 10:36:43 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Wed, 15 Dec 2021 10:36:43 +0200
changeset 58
4a2c4ee27858
parent 53
f8a3bc920f6a
permissions
-rw-r--r--

Improve license phrasing

9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1 ########################################################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
2 # Basic TV denoising via primal–dual proximal splitting
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
3 ########################################################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
4
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
5 __precompile__()
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
6
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
7 module Denoise
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
8
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
9 using AlgTools.Util
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
10 import AlgTools.Iterate
53
f8a3bc920f6a Fix some `using` to be relative.
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
11 using ..Gradient
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
12
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
13 ##############
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
14 # Our exports
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
15 ##############
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
16
28
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
17 export denoise_pdps,
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
18 denoise_fista
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
19
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
20 #############
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
21 # Data types
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
22 #############
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
23
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
24 ImageSize = Tuple{Integer,Integer}
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
25 Image = Array{Float64,2}
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
26 Primal = Image
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
27 Dual = Array{Float64,3}
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
28
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
29 #########################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
30 # Iterate initialisation
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
31 #########################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
32
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
33 function init_rest(x::Primal)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
34 imdim=size(x)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
35
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
36 y = zeros(2, imdim...)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
37 Δx = copy(x)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
38 Δy = copy(y)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
39 x̄ = copy(x)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
40
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
41 return x, y, Δx, Δy, x̄
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
42 end
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
43
28
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
44 function init_primal(xinit::Image, b)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
45 return copy(xinit)
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
46 end
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
47
28
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
48 function init_primal(xinit::Nothing, b :: Image)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
49 return zeros(size(b)...)
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
50 end
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
51
28
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
52
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
53 ############
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
54 # Algorithm
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
55 ############
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
56
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
57 function denoise_pdps(b :: Image;
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
58 xinit :: Union{Image,Nothing} = nothing,
46
46053b3af251 typofix
Tuomo Valkonen <tuomov@iki.fi>
parents: 28
diff changeset
59 iterate = Iterate.simple_iterate,
28
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
60 params::NamedTuple)
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
61
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
62 ################################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
63 # Extract and set up parameters
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
64 ################################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
65
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
66 α, ρ = params.α, params.ρ
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
67 τ₀, σ₀ = params.τ₀, params.σ₀
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
68
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
69 R_K = ∇₂_norm₂₂_est
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
70 γ = 1
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
71
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
72 @assert(τ₀*σ₀ < 1)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
73 σ = σ₀/R_K
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
74 τ = τ₀/R_K
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
75
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
76 ######################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
77 # Initialise iterates
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
78 ######################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
79
28
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
80 x, y, Δx, Δy, x̄ = init_rest(init_primal(xinit, b))
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
81
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
82 ####################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
83 # Run the algorithm
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
84 ####################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
85
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
86 v = iterate(params) do verbose :: Function
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
87 ω = params.accel ? 1/√(1+2*γ*τ) : 1
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
88
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
89 ∇₂ᵀ!(Δx, y) # primal step:
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
90 @. x̄ = x # | save old x for over-relax
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
91 @. x = (x-τ*(Δx-b))/(1+τ) # | prox
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
92 @. x̄ = (1+ω)*x - ω*x̄ # over-relax: x̄ = 2x-x_old
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
93 ∇₂!(Δy, x̄) # dual step: y
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
94 @. y = (y + σ*Δy)/(1 + σ*ρ/α) # |
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
95 proj_norm₂₁ball!(y, α) # | prox
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
96
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
97 if params.accel
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
98 τ, σ = τ*ω, σ/ω
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
99 end
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
100
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
101 ################################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
102 # Give function value if needed
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
103 ################################
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
104 v = verbose() do
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
105 ∇₂!(Δy, x)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
106 value = norm₂²(b-x)/2 + params.α*γnorm₂₁(Δy, params.ρ)
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
107 value, x
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
108 end
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
109
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
110 v
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
111 end
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
112
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
113 return x, y, v
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
114 end
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
115
28
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
116 function denoise_fista(b :: Image;
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
117 xinit :: Union{Image,Nothing} = nothing,
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
118 iterate = AlgTools.simple_iterate,
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
119 params::NamedTuple)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
120
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
121 ################################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
122 # Extract and set up parameters
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
123 ################################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
124
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
125 α, ρ = params.α, params.ρ
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
126 τ₀ = params.τ₀
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
127 τ = τ₀/∇₂_norm₂₂_est²
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
128
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
129 ######################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
130 # Initialise iterates
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
131 ######################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
132
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
133 x = init_primal(xinit, b)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
134 imdim = size(x)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
135 Δx = similar(x)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
136 y = zeros(2, imdim...)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
137 ỹ = copy(y)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
138 y⁻ = similar(y)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
139 Δy = similar(y)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
140
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
141 ####################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
142 # Run the algorithm
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
143 ####################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
144
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
145 t = 0
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
146
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
147 v = iterate(params) do verbose :: Function
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
148 ∇₂ᵀ!(Δx, ỹ)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
149 @. Δx .-= b
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
150 ∇₂!(Δy, Δx)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
151 @. y⁻ = y
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
152 @. y = (ỹ - τ*Δy)/(1 + τ*ρ/α)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
153 proj_norm₂₁ball!(y, α)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
154 t⁺ = (1+√(1+4*t^2))/2
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
155 @. ỹ = y+((t-1)/t⁺)*(y-y⁻)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
156 t = t⁺
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
157
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
158 ################################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
159 # Give function value if needed
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
160 ################################
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
161 v = verbose() do
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
162 ∇₂ᵀ!(Δx, y)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
163 @. x = b - Δx
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
164 ∇₂!(Δy, x)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
165 value = norm₂²(b-x)/2 + params.α*γnorm₂₁(Δy, params.ρ)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
166 value, x
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
167 end
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
168
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
169 v
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
170 end
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
171
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
172 ∇₂ᵀ!(Δx, y)
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
173 @. x = b - Δx
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
174
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
175 return x, y, v
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
176 end
d1f40f6654cb denoise_fista
Tuomo Valkonen <tuomov@iki.fi>
parents: 9
diff changeset
177
9
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
178 end # Module
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
179
1cffd3d07fe2 Denoising routine for testing + visualisation tools
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
180

mercurial