diff --git a/benchmark/Project.toml b/benchmark/Project.toml index f0879af..153b736 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -1,7 +1,7 @@ [deps] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" DitherPunk = "b8f752a5-abd5-43b6-a55b-e75efda20de0" -ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" -ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" +PkgJogger = "10150987-6cc1-4b76-abee-b1c1cbd91c01" TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" diff --git a/benchmark/bench_jogger.jl b/benchmark/bench_jogger.jl new file mode 100644 index 0000000..cd1df12 --- /dev/null +++ b/benchmark/bench_jogger.jl @@ -0,0 +1,52 @@ +using BenchmarkTools +using DitherPunk +using TestImages +using ColorTypes: RGB + +on_CI = haskey(ENV, "GITHUB_ACTIONS") + +img_gray = testimage("fabio_gray_256") +img_color = testimage("fabio_color_256") + +## Define color scheme +white = RGB{Float32}(1, 1, 1) +yellow = RGB{Float32}(1, 1, 0) +green = RGB{Float32}(0, 0.5, 0) +orange = RGB{Float32}(1, 0.5, 0) +red = RGB{Float32}(1, 0, 0) +blue = RGB{Float32}(0, 0, 1) +cs = [white, yellow, green, orange, red, blue] + +# Use one representative algorithm of each type +algs = Dict( + "error diffusion" => FloydSteinberg(), + "ordered dithering" => Bayer(3;), + "closest color" => ClosestColor(), + "threshold dithering" => WhiteNoiseThreshold(), +) + +# Tag what is tested on each algorithm type +suite = BenchmarkGroup() +suite["error diffusion"] = BenchmarkGroup(["binary", "color"]) +suite["ordered dithering"] = BenchmarkGroup(["binary", "color"]) +suite["threshold dithering"] = BenchmarkGroup(["binary"]) +suite["closest color"] = BenchmarkGroup(["binary", "color"]) + +println(suite) + +for (algname, alg) in algs + suite[algname]["binary new"] = @benchmarkable dither($(img_gray), $(alg)) + suite[algname]["binary inplace"] = @benchmarkable dither!($(copy(img_gray)), $(alg)) + + suite[algname]["per-channel new"] = @benchmarkable dither($(img_color), $(alg)) + suite[algname]["per-channel inplace"] = @benchmarkable dither!( + $(copy(img_color)), $(alg) + ) + + if "color" in suite[algname].tags + suite[algname]["color new"] = @benchmarkable dither($(img_color), $(alg), $(cs)) + suite[algname]["color inplace"] = @benchmarkable dither!( + $(copy(img_color)), $(alg), $(cs) + ) + end +end diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 69d56d7..0320e6f 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,52 +1,5 @@ -using BenchmarkTools +using PkgJogger using DitherPunk -using TestImages -using ImageCore - -on_CI = haskey(ENV, "GITHUB_ACTIONS") - -img_gray = testimage("fabio_gray_256") -img_color = testimage("fabio_color_256") - -## Define color scheme -white = RGB{Float32}(1, 1, 1) -yellow = RGB{Float32}(1, 1, 0) -green = RGB{Float32}(0, 0.5, 0) -orange = RGB{Float32}(1, 0.5, 0) -red = RGB{Float32}(1, 0, 0) -blue = RGB{Float32}(0, 0, 1) -cs = [white, yellow, green, orange, red, blue] - -# Use one representative algorithm of each type -algs = Dict( - "error diffusion" => FloydSteinberg(), - "ordered dithering" => Bayer(; level=3), - "closest color" => ClosestColor(), - "threshold dithering" => WhiteNoiseThreshold(), -) - -# Tag what is tested on each algorithm type -SUITE = BenchmarkGroup() -SUITE["error diffusion"] = BenchmarkGroup(["binary", "color"]) -SUITE["ordered dithering"] = BenchmarkGroup(["binary", "color"]) -SUITE["threshold dithering"] = BenchmarkGroup(["binary"]) -SUITE["closest color"] = BenchmarkGroup(["binary", "color"]) - -println(SUITE) - -for (algname, alg) in algs - SUITE[algname]["binary new"] = @benchmarkable dither($(img_gray), $(alg)) - SUITE[algname]["binary inplace"] = @benchmarkable dither!($(copy(img_gray)), $(alg)) - - SUITE[algname]["per-channel new"] = @benchmarkable dither($(img_color), $(alg)) - SUITE[algname]["per-channel inplace"] = @benchmarkable dither!( - $(copy(img_color)), $(alg) - ) - - if "color" in SUITE[algname].tags - SUITE[algname]["color new"] = @benchmarkable dither($(img_color), $(alg), $(cs)) - SUITE[algname]["color inplace"] = @benchmarkable dither!( - $(copy(img_color)), $(alg), $(cs) - ) - end -end +# Use PkgJogger.@jog to create the JogDitherPunk module +@jog DitherPunk +SUITE = JogDitherPunk.suite() diff --git a/test/Project.toml b/test/Project.toml index 01687fc..e969904 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,25 +1,14 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" +ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" -ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e" -ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" -ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" +FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +PkgJogger = "10150987-6cc1-4b76-abee-b1c1cbd91c01" ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" - -[compat] -Aqua = "0.8" -ColorSchemes = "3" -ImageBase = "0.1" -ImageIO = "0.6" -ImageMagick = "1" -IndirectArrays = "0.5, 1.0" -OffsetArrays = "1" -ReferenceTests = "0.10.1" -TestImages = "1" diff --git a/test/test_benchmarks.jl b/test/test_benchmarks.jl new file mode 100644 index 0000000..ca761e9 --- /dev/null +++ b/test/test_benchmarks.jl @@ -0,0 +1,4 @@ +using PkgJogger +using DitherPunk + +PkgJogger.@test_benchmarks DitherPunk diff --git a/test/test_braille.jl b/test/test_braille.jl index 1d89640..1d37ea5 100644 --- a/test/test_braille.jl +++ b/test/test_braille.jl @@ -1,5 +1,5 @@ using DitherPunk -using ImageBase: RGB, Gray +using ColorTypes: RGB, Gray using Test using ReferenceTests diff --git a/test/test_color.jl b/test/test_color.jl index 767001f..8ed781d 100644 --- a/test/test_color.jl +++ b/test/test_color.jl @@ -1,7 +1,8 @@ using DitherPunk using DitherPunk: ColorNotImplementedError using IndirectArrays -using ImageBase +using ColorTypes: RGB, HSV +using FixedPointNumbers: N0f8 using ReferenceTests using TestImages diff --git a/test/test_fixed_color.jl b/test/test_fixed_color.jl index 9e7c2a5..817c344 100644 --- a/test/test_fixed_color.jl +++ b/test/test_fixed_color.jl @@ -1,5 +1,5 @@ using DitherPunk -using ImageBase +using ColorTypes: RGB, HSV using ReferenceTests using TestImages diff --git a/test/test_gradient.jl b/test/test_gradient.jl index 80c6150..f3cd4a8 100644 --- a/test/test_gradient.jl +++ b/test/test_gradient.jl @@ -1,6 +1,6 @@ using DitherPunk using DitherPunk: DEFAULT_METHOD, AbstractDither -using ImageBase: Gray +using ColorTypes: Gray using OffsetArrays using Test diff --git a/test/test_utils.jl b/test/test_utils.jl index 8d6a180..8a36f87 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -1,6 +1,6 @@ using DitherPunk using DitherPunk: srgb2linear, clamp_limits -using ImageBase +using ColorTypes @test srgb2linear(true) == true @test srgb2linear(false) == false