added zero dual predictor for denoising

Sun, 21 Apr 2024 19:04:00 +0300

author
Neil Dizon <neil.dizon@helsinki.fi>
date
Sun, 21 Apr 2024 19:04:00 +0300
changeset 20
7d3a75b875fa
parent 19
7c4dfeb48dd9
child 21
97737e4e7197

added zero dual predictor for denoising

src/AlgorithmZeroDual.jl file | annotate | diff | comparison | revisions
src/PET/PlotResults.jl file | annotate | diff | comparison | revisions
src/PredictPDPS.jl file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/AlgorithmZeroDual.jl	Sun Apr 21 19:04:00 2024 +0300
@@ -0,0 +1,125 @@
+####################################################################
+# Predictive online PDPS for optical flow with known velocity field
+####################################################################
+
+__precompile__()
+
+module AlgorithmZeroDual
+
+identifier = "pdps_known_zerodual"
+
+using Printf
+
+using AlgTools.Util
+import AlgTools.Iterate
+using ImageTools.Gradient
+
+using ..OpticalFlow: ImageSize,
+                     Image,
+                     pdflow!
+
+#########################
+# Iterate initialisation
+#########################
+
+function init_rest(x::Image)
+    imdim=size(x)
+
+    y = zeros(2, imdim...)
+    Δx = copy(x)
+    Δy = copy(y)
+    x̄ = copy(x)
+
+    return x, y, Δx, Δy, x̄
+end
+
+function init_iterates(xinit::Image)
+    return init_rest(copy(xinit))
+end
+
+function init_iterates(dim::ImageSize)
+    return init_rest(zeros(dim...))
+end
+
+############
+# Algorithm
+############
+
+function solve( :: Type{DisplacementT};
+               dim :: ImageSize,
+               iterate = AlgTools.simple_iterate,
+               params::NamedTuple) where DisplacementT
+
+    ################################                                        
+    # Extract and set up parameters
+    ################################                    
+
+    α, ρ = params.α, params.ρ
+    R_K² = ∇₂_norm₂₂_est²
+    γ = 1.0
+    Λ = params.Λ
+    τ₀, σ₀ = params.τ₀, params.σ₀
+
+    τ = τ₀/γ
+    @assert(1+γ*τ ≥ Λ)
+    σ = σ₀*1/(τ*R_K²)
+
+    println("Step length parameters: τ=$(τ), σ=$(σ)")
+
+    ######################
+    # Initialise iterates
+    ######################
+
+    x, y, Δx, Δy, x̄ = init_iterates(dim)
+    init_data = (params.init == :data)
+
+    ####################
+    # Run the algorithm
+    ####################
+
+    v = iterate(params) do verbose :: Function,
+                           b :: Image,
+                           v_known :: DisplacementT,
+                           🚫unused_b_next :: Image
+
+        ##################
+        # Prediction step
+        ##################
+        if init_data
+            x .= b
+            init_data = false
+        end
+
+        pdflow!(x, Δx, y, Δy, v_known, false)
+        y .= zeros(size(y)...)
+
+        ############
+        # PDPS step
+        ############
+
+        ∇₂ᵀ!(Δx, y)                    # primal step:
+        @. x̄ = x                       # |  save old x for over-relax
+        @. x = (x-τ*(Δx-b))/(1+τ)      # |  prox
+        @. x̄ = 2x - x̄                  # over-relax
+        ∇₂!(Δy, x̄)                     # dual step: y
+        @. y = (y + σ*Δy)/(1 + σ*ρ/α)  # |
+        proj_norm₂₁ball!(y, α)         # |  prox
+
+        ################################
+        # Give function value if needed
+        ################################
+        v = verbose() do            
+            ∇₂!(Δy, x)
+            value = norm₂²(b-x)/2 + params.α*γnorm₂₁(Δy, params.ρ)
+            value, x, [NaN, NaN], nothing
+        end
+
+        v
+    end
+
+    return x, y, v
+end
+
+end # Module
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/PET/PlotResults.jl	Sun Apr 21 19:04:00 2024 +0300
@@ -0,0 +1,561 @@
+__precompile__()
+
+module PlotResults
+
+
+########################
+# Load external modules
+########################
+
+using DelimitedFiles, CSV, DataFrames
+using PlotlyJS
+
+export fv_plot, ssim_plot, psnr_plot
+
+global mystart = 38
+global myend = 75
+
+function fv_plot(name :: String, save_plot::Bool=true)
+    save_path = "./img/$(name)256x256_pdps_known_fv_plot.html"
+    #################################################
+    orig = Vector{GenericTrace{Dict{Symbol, Any}}}()
+    #################################################
+    directory_path = "./img/"
+    files = readdir(directory_path)
+    filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_proximal") && endswith(file, "0.txt"), files)
+
+    # Define an array of line styles and colors
+    # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+    line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+
+    for (index,file) in enumerate(filtered_files)
+        filename = directory_path*file
+        #data = readdlm(filename, '\t', skipstart=1)
+        data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :function_value])
+
+        #line_style = line_styles[i]
+        line_color = line_colors[index]
+
+        trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                line_color=line_color, line_dash="dot", name="proxi")
+        push!(orig, trace)
+    end
+
+    #####################################################
+    identity = Vector{GenericTrace{Dict{Symbol, Any}}}()
+    #####################################################
+    directory_path = "./img/"
+    files = readdir(directory_path)
+    filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_primalonly") && endswith(file, "0.txt"), files)
+
+    # Define an array of line styles and colors
+    # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+    line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+
+    for (index,file) in enumerate(filtered_files)
+        filename = directory_path*file
+        #data = readdlm(filename, '\t', skipstart=1)
+        data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :function_value])
+
+        #line_style = line_styles[i]
+        line_color = line_colors[index]
+
+        trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                line_color=line_color, line_dash="dashdot", name="primo")
+        push!(identity, trace)
+    end
+
+
+     #####################################################
+     adhoc = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_greedy") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+         # Extract the columns you want to plot
+         X = Int64.(data[mystart:myend,:iter])
+         Y = Float64.(data[mystart:myend, :function_value])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="dash", name="greed τ")
+         push!(identity, trace)
+     end
+
+
+     #####################################################
+     rotation = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_rotation") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+         # Extract the columns you want to plot
+         X = Int64.(data[mystart:myend,:iter])
+         Y = Float64.(data[mystart:myend, :function_value])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="longdashdot", name="rotat")
+         push!(identity, trace)
+     end     
+
+
+     #####################################################
+     affine = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_dualscaling") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+         # Extract the columns you want to plot
+         X = Int64.(data[mystart:myend,:iter])
+         Y = Float64.(data[mystart:myend, :function_value])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="solid", name="dusca")
+         push!(identity, trace)
+     end      
+
+    layout = Layout(legend_title_text="Function values")  # Set legend title
+    
+    if save_plot && !isempty(save_path)
+        plotlyjs = plot([orig;identity;adhoc;rotation;affine], layout)
+        open(save_path, "w") do io
+            PlotlyBase.to_html(io, plotlyjs.plot)
+        end
+    elseif save_plot
+        println("Please provide a valid save path.")
+    end
+
+    return  plot([orig;identity;adhoc;rotation;affine],layout)
+end
+
+
+#########################################################
+# FUNCTION FOR SSIM
+#########################################################
+function ssim_plot(name :: String, save_plot::Bool=true)
+    save_path = "./img/$(name)256x256_pdps_known_ssim_plot.html"
+    #################################################
+    orig = Vector{GenericTrace{Dict{Symbol, Any}}}()
+    #################################################
+    directory_path = "./img/"
+    files = readdir(directory_path)
+    filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_proximal") && endswith(file, "0.txt"), files)
+
+    # Define an array of line styles and colors
+    # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+    line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+
+    for (index,file) in enumerate(filtered_files)
+        filename = directory_path*file
+        #data = readdlm(filename, '\t', skipstart=1)
+        data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :ssim])
+
+        #line_style = line_styles[i]
+        line_color = line_colors[index]
+
+        trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                line_color=line_color, line_dash="dot", name="proxi")
+        push!(orig, trace)
+    end
+
+    #####################################################
+    identity = Vector{GenericTrace{Dict{Symbol, Any}}}()
+    #####################################################
+    directory_path = "./img/"
+    files = readdir(directory_path)
+    filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_primalonly") && endswith(file, "0.txt"), files)
+
+    # Define an array of line styles and colors
+    # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+    line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+
+    for (index,file) in enumerate(filtered_files)
+        filename = directory_path*file
+        #data = readdlm(filename, '\t', skipstart=1)
+        data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :ssim])
+
+        #line_style = line_styles[i]
+        line_color = line_colors[index]
+
+        trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                line_color=line_color, line_dash="dashdot", name="primo")
+        push!(identity, trace)
+    end
+
+
+     #####################################################
+     adhoc = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_greedy") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :ssim])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="dash", name="greed")
+         push!(identity, trace)
+     end
+
+
+     #####################################################
+     rotation = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_rotation") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :ssim])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="longdashdot", name="rotat")
+         push!(identity, trace)
+     end     
+
+
+     #####################################################
+     affine = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_dualscaling") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :ssim])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="solid", name="dusca")
+         push!(identity, trace)
+     end 
+
+    #####################################################
+    zerodual = Vector{GenericTrace{Dict{Symbol, Any}}}()
+    #####################################################
+    directory_path = "./img/"
+    files = readdir(directory_path)
+    filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_zerodual") && endswith(file, "0.txt"), files)
+
+    # Define an array of line styles and colors
+    # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+    line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+
+    for (index,file) in enumerate(filtered_files)
+        filename = directory_path*file
+        #data = readdlm(filename, '\t', skipstart=1)
+        data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+
+    # Extract the columns you want to plot
+    X = Int64.(data[mystart:myend,:iter])
+    Y = Float64.(data[mystart:myend, :ssim])
+
+        #line_style = line_styles[i]
+        line_color = line_colors[index]
+
+        trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                line_color=line_color, line_dash="longdash", name="zerod")
+        push!(identity, trace)
+    end  
+
+    layout = Layout(yaxis_type="log", legend_title_text="SSIM")  # Set legend title
+    
+    if save_plot && !isempty(save_path)
+        plotlyjs = plot([orig;identity;adhoc;rotation;affine;zerodual], layout)
+        open(save_path, "w") do io
+            PlotlyBase.to_html(io, plotlyjs.plot)
+        end
+    elseif save_plot
+        println("Please provide a valid save path.")
+    end
+
+    return  plot([orig;identity;adhoc;rotation;affine;zerodual],layout)
+end
+
+
+
+#########################################################
+# FUNCTION FOR PSNR
+#########################################################
+function psnr_plot(name :: String, save_plot::Bool=true)
+    save_path = "./img/$(name)256x256_pdps_known_psnr_plot.html"
+    #################################################
+    orig = Vector{GenericTrace{Dict{Symbol, Any}}}()
+    #################################################
+    directory_path = "./img/"
+    files = readdir(directory_path)
+    filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_proximal") && endswith(file, "0.txt"), files)
+
+    # Define an array of line styles and colors
+    # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+    line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+
+    for (index,file) in enumerate(filtered_files)
+        filename = directory_path*file
+        #data = readdlm(filename, '\t', skipstart=1)
+        data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :psnr])
+
+        #line_style = line_styles[i]
+        line_color = line_colors[index]
+
+        trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                line_color=line_color, line_dash="dot", name="proxi")
+        push!(orig, trace)
+    end
+
+    #####################################################
+    identity = Vector{GenericTrace{Dict{Symbol, Any}}}()
+    #####################################################
+    directory_path = "./img/"
+    files = readdir(directory_path)
+    filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_primalonly") && endswith(file, "0.txt"), files)
+
+    # Define an array of line styles and colors
+    # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+    line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+
+    for (index,file) in enumerate(filtered_files)
+        filename = directory_path*file
+        #data = readdlm(filename, '\t', skipstart=1)
+        data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :psnr])
+
+        #line_style = line_styles[i]
+        line_color = line_colors[index]
+
+        trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                line_color=line_color, line_dash="dashdot", name="primo")
+        push!(identity, trace)
+    end
+
+
+     #####################################################
+     adhoc = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_greedy") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :psnr])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="dash", name="greed")
+         push!(identity, trace)
+     end
+
+
+     #####################################################
+     rotation = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_rotation") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :psnr])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="longdashdot", name="rotat")
+         push!(identity, trace)
+     end     
+
+     #####################################################
+     affine = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_dualscaling") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :psnr])
+
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="solid", name="dusca")
+         push!(identity, trace)
+     end  
+
+     #####################################################
+     zerodual = Vector{GenericTrace{Dict{Symbol, Any}}}()
+     #####################################################
+     directory_path = "./img/"
+     files = readdir(directory_path)
+     filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_zerodual") && endswith(file, "0.txt"), files)
+ 
+     # Define an array of line styles and colors
+     # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"]
+     line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"]
+ 
+     for (index,file) in enumerate(filtered_files)
+         filename = directory_path*file
+         #data = readdlm(filename, '\t', skipstart=1)
+         data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame
+ 
+        # Extract the columns you want to plot
+        X = Int64.(data[mystart:myend,:iter])
+        Y = Float64.(data[mystart:myend, :psnr])
+ 
+         #line_style = line_styles[i]
+         line_color = line_colors[index]
+ 
+         trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}",
+                                 line_color=line_color, line_dash="longdash", name="zerod")
+         push!(identity, trace)
+     end  
+
+
+    layout = Layout(yaxis_type="log", legend_title_text="PSNR")  # Set legend title
+    
+    if save_plot && !isempty(save_path)
+        plotlyjs = plot([orig;identity;adhoc;rotation;affine; zerodual], layout)
+        open(save_path, "w") do io
+            PlotlyBase.to_html(io, plotlyjs.plot)
+        end
+    elseif save_plot
+        println("Please provide a valid save path.")
+    end
+
+    return  plot([orig;identity;adhoc;rotation;affine;zerodual],layout)
+end
+
+
+end # Module
\ No newline at end of file
--- a/src/PredictPDPS.jl	Sun Apr 21 18:55:00 2024 +0300
+++ b/src/PredictPDPS.jl	Sun Apr 21 19:04:00 2024 +0300
@@ -87,7 +87,7 @@
        batchrun_denoising,
        batchrun_predictors,
        demo_denoising1, demo_denoising2, demo_denoising3, 
-       demo_denoising4, demo_denoising5, demo_denoising6,
+       demo_denoising4, demo_denoising5, demo_denoising6, demo_denoising7,
        demo_petS1, demo_petS2, demo_petS3, 
        demo_petS4, demo_petS5, demo_petS6, demo_petS7,
        demo_petB1, demo_petB2, demo_petB3, 
@@ -223,7 +223,9 @@
     Experiment(AlgorithmProximal, DisplacementConstant, lighthouse,
                p_known₀_denoising ⬿ (phantom_ρ = 100,)),
     Experiment(AlgorithmRotation, DisplacementConstant, lighthouse,
-               p_known₀_denoising),   
+               p_known₀_denoising),
+    Experiment(AlgorithmZeroDual, DisplacementConstant, lighthouse,
+               p_known₀_denoising),  
 )
 
 const denoising_experiments_all = Iterators.flatten((
@@ -414,6 +416,7 @@
 demo_denoising4 = () -> demo(denoising_experiments_pdps_known[4]) # Primal Only
 demo_denoising5 = () -> demo(denoising_experiments_pdps_known[5]) # Proximal (old)
 demo_denoising6 = () -> demo(denoising_experiments_pdps_known[6]) # Rotation
+demo_denoising7 = () -> demo(denoising_experiments_pdps_known[7]) # Zero dual
 
 function batchrun_article(kwargs...)
     run_experiments(;experiments=experiments_all,

mercurial