Skip to content

Instantly share code, notes, and snippets.

@loiseaujc
Created February 17, 2021 13:51
Show Gist options
  • Save loiseaujc/e338e2ea15ed11b96e7a4fb5ae6501d4 to your computer and use it in GitHub Desktop.
Save loiseaujc/e338e2ea15ed11b96e7a4fb5ae6501d4 to your computer and use it in GitHub Desktop.
Implementation of basis pursuit denoising with StructuredOptimization.jl
using StructuredOptimization
"""
Simple implementation of basis pursuit denoising using StructuredOptimization.jl
INPUT
-----
m, n : Size of the image in both direction.
idx : Linear indices of the measured pixels.
y : Pixel measurements.
λ : (Optional) Sparsity knob.
OUTPUT
------
x : Estimated image.
"""
function bpdn(m, n, idx, y ; λ=0.1)
# --> Initialize variable.
x = Variable(eltype(y), m, n)
# --> Solve the compressed sensing problem.
@minimize ls(idct(x)[idx] - 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