--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/denoise.jl Thu Nov 21 18:44:27 2019 -0500 @@ -0,0 +1,64 @@ +################## +# Denoise testing +################## + +__precompile__() + +using Printf +using Images +import TestImages + +using AlgTools.Util +using AlgTools.LinkedLists +using ImageTools.Denoise +using ImageTools.Visualise + +const default_save_prefix="denoise_result_" + +const default_params = ( + α = 1, + τ₀ = 5, + σ₀ = 0.99/5, + ρ = 0, + accel = true, + noise_level = 0.5, + verbose_iter = 10, + maxiter = 1000, + save_results = false, + save_iterations = false, + image_name = "lighthouse", +) + +####################### +# Main testing routine +####################### + +function test_denoise(; + visualise=true, + save_prefix=default_save_prefix, + kwargs...) + + + # Parameters for this experiment + params = default_params ⬿ kwargs + params = params ⬿ (save_prefix = save_prefix * params.image_name,) + + # Load image and add noise + b = Float64.(Gray.(TestImages.testimage(params.image_name))) + b_noisy = b .+ params.noise_level.*randn(size(b)...) + + # Launch (background) visualiser + st, iterate = initialise_visualisation(visualise) + + # Run algorithm + x, y, st = denoise_pdps(b_noisy; iterate=iterate, params=params) + + if params.save_results + perffile = params.save_prefix * ".txt" + println("Saving " * perffile) + write_log(perffile, st.log, "# params = $(params)\n") + end + + # Exit background visualiser + finish_visualisation(st) +end