JuliaImages / ImageSmooth.jl

Image smoothing algorithms
MIT License
7 stars 1 forks source link

add L0Smooth Algorithm #1

Closed JKay0327 closed 3 years ago

JKay0327 commented 3 years ago

I have added L0Smooth algorithm to src and added test for it. But I meet some problems when testing my work. I met a UndefVarError, especially, the function 'L0Smooth' was not defined. I don't know what's wrong with it.

johnnychen94 commented 3 years ago

But I meet some problems when testing my work. I met a UndefVarError, especially, the function 'L0Smooth' was not defined.

It works well here if you activate the package folder as the project:

$ pwd
/Users/jc/Documents/Julia/ImageSmooth.jl

$ julia --project=.
julia> using ImageSmooth

julia> L0Smooth
L0Smooth
codecov[bot] commented 3 years ago

Codecov Report

Merging #1 (ed755a1) into master (9ffcda3) will increase coverage by 77.47%. The diff coverage is 77.47%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master       #1       +/-   ##
===========================================
+ Coverage        0   77.47%   +77.47%     
===========================================
  Files           0        4        +4     
  Lines           0      111      +111     
===========================================
+ Hits            0       86       +86     
- Misses          0       25       +25     
Impacted Files Coverage Δ
src/utils.jl 47.82% <47.82%> (ø)
src/compat.jl 50.00% <50.00%> (ø)
src/SmoothAPI/smooth.jl 100.00% <100.00%> (ø)
src/algorithms/l0_smooth.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9ffcda3...ed755a1. Read the comment docs.

JKay0327 commented 3 years ago

The document used to have 2 @docs block for L0Smooth, but I met a warning which said duplicate docs found for 'L0Smooth' in @docs block. I'd like to know whether I could maintain 2 @docs block for the same function?

JKay0327 commented 3 years ago

In this PR, we have done works as follow:

The current performance of L0Smooth algorithm in Julia is as follow:

julia> img_gray = testimage("cameraman");
julia> img_rgb = testimage("lena_color_512");

julia> fₛ = L0Smooth()
L0Smooth(0.02, 2.0, 100000.0)

julia> @btime smooth(img_gray, fₛ)
  418.836 ms (1712 allocations: 316.75 MiB)
julia> @btime smooth(img_rgb, fₛ)
  1.155 s (1934 allocations: 1.03 GiB)

The performance of Matlab version L0Smooth is as follow:

img_gray = imread('cameraman.tif');
img_rgb = imread('lena_color_512.tif');

>>repeat = 100;
>>t = 0;
>>for i = 1 : repeat
    t0 = cputime;
    S1 = L0Smoothing(img_gray);
    t =  cputime - t0 + t;
end
>>average_time = t / repeat;
>>fprintf('CPU time: %.4f', average_time);
CPU time: 0.8336

>>t = 0;
>>for i = 1 : repeat
    t0 = cputime;
    S1 = L0Smoothing(img_rgb);
    t =  cputime - t0 + t;
end
>>average_time = t / repeat;
>>fprintf('CPU time: %.4f', average_time);
CPU time: 3.0136

Here is a 2~3 times performance improvement for the Julia version.

Some problems are still remained: