diff --git a/Project.toml b/Project.toml index 579856a..92d52db 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ImageSmooth" uuid = "a14a6c0f-317a-4379-b4a0-4ba4e1e9b5ed" authors = ["Johnny Chen ", "JKay <2439951158@qq.com>"] -version = "0.1.1" +version = "0.1.2" [deps] FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" diff --git a/src/algorithms/l0_smooth.jl b/src/algorithms/l0_smooth.jl index 96965c5..4cb3202 100644 --- a/src/algorithms/l0_smooth.jl +++ b/src/algorithms/l0_smooth.jl @@ -128,6 +128,9 @@ function (f::L0Smooth)(out::GenericGrayImage, tยน = trues(N, M) โ„ฑ๐‘† = similar(โ„ฑ๐ผ) + # precompute the FFT plan so that we get fast FFT inside the iteration + F = plan_fft!(โ„ฑ๐ผ, (1, 2)) + IF = plan_ifft!(โ„ฑ๐ผ, (1, 2)) while ๐›ฝ < ๐›ฝmax # Computing (โ„Ž, ๐‘ฃ) via solving equation (9) in [1] # We get the solution (12) in [1] through following process @@ -152,14 +155,13 @@ function (f::L0Smooth)(out::GenericGrayImage, # ๐›ฅโ‚แต€() and ๐›ฅโ‚‚แต€() indicate the transposition of forward difference along horizontal axis and vertical axis fdiff!(๐›ฅโ‚แต€โ„Ž, ๐›ฅโ‚๐‘†, dims = 2, rev=true, boundary=:periodic) fdiff!(๐›ฅโ‚‚แต€๐‘ฃ, ๐›ฅโ‚‚๐‘†, dims = 1, rev=true, boundary=:periodic) - @. ๐›ฅโ‚แต€โ„Ž = -๐›ฅโ‚แต€โ„Ž - @. ๐›ฅโ‚‚แต€๐‘ฃ = -๐›ฅโ‚‚แต€๐‘ฃ # Computing S via equation (8) in [1] - @. Normin = complex(๐›ฅโ‚แต€โ„Ž + ๐›ฅโ‚‚แต€๐‘ฃ) - fft!(Normin, (1, 2)) + @. Normin = complex(-๐›ฅโ‚แต€โ„Ž - ๐›ฅโ‚‚แต€๐‘ฃ) + F * Normin # fft!(Normin, (1, 2)) + @. โ„ฑ๐‘† = (โ„ฑ๐ผ + ๐›ฝ * Normin) / (1 + ๐›ฝ * Denormin) - ifft!(โ„ฑ๐‘†, (1, 2)) + IF * โ„ฑ๐‘† # ifft!(โ„ฑ๐‘†, (1, 2)) @. ๐‘† = real(โ„ฑ๐‘†) ๐›ฝ = ๐›ฝ * ๐œ