test/denoise.jl

Thu, 19 Dec 2019 23:29:21 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Thu, 19 Dec 2019 23:29:21 +0200
changeset 24
f6630036e588
parent 11
f1bbdf68f35b
child 25
1fba916f2b77
permissions
-rw-r--r--

Visualisation does aspect ratio correctly.

##################
# 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
    finalise_visualisation(st)
end

mercurial