Skip to content

Instantly share code, notes, and snippets.

@loiseaujc
Last active February 17, 2021 14:03
Show Gist options
  • Save loiseaujc/acd2d4d8d7a0f03ce6613a3be85824b1 to your computer and use it in GitHub Desktop.
Save loiseaujc/acd2d4d8d7a0f03ce6613a3be85824b1 to your computer and use it in GitHub Desktop.
using StructuredOptimization
"""
Simple implementation of basis pursuit denoising using StructuredOptimization.jl
INPUT
-----
C : The measurement matrix.
Ψ : Basis in which x is assumed to be sparse.
y : Pixel measurements.
λ : (Optional) Sparsity knob.
OUTPUT
------
x : Estimated image.
"""
function bpdn(C, Ψ, y ; λ=0.1)
# --> Initialize variable.
x = Variable(eltype(y), size(Ψ, 2))
# --> Solve the compressed sensing problem.
@minimize ls(C * Ψ * x - y) + λ*norm(x, 1)
return ~x
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment