JuliaImages / DitherPunk.jl

Dithering algorithms in Julia.
MIT License
60 stars 3 forks source link

downsample the image before clustering #71

Closed johnnychen94 closed 2 years ago

johnnychen94 commented 2 years ago

For any real-world image, clustering the image pixel is a computational intensive big-data problem. For our very purpose to estimate the colormap, a downsampled the version already works well.

using DitherPunk, TestImages, Clustering

img_gray = testimage("cameraman")
img_color = testimage("lighthouse")

@time dither(img_gray, FloydSteinberg(), 8)
# PR: 0.477710 seconds (30.36 M allocations: 559.455 MiB, 9.76% gc time)
# master: 0.693541 seconds (31.94 M allocations: 610.524 MiB, 7.57% gc time)

@time dither(img_color, FloydSteinberg(), 24)
# PR: 2.002484 seconds (120.32 M allocations: 1.937 GiB, 7.40% gc time)
# master: 8.085305 seconds (124.17 M allocations: 2.187 GiB, 2.26% gc time, 0.32% compilation time)

The results are not identical but the visual quality looks quite similar. I think this is a good improvement overall (not a breaking change).

codecov[bot] commented 2 years ago

Codecov Report

Merging #71 (c123651) into master (7969627) will increase coverage by 0.04%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #71      +/-   ##
==========================================
+ Coverage   98.44%   98.49%   +0.04%     
==========================================
  Files          14       14              
  Lines         257      265       +8     
==========================================
+ Hits          253      261       +8     
  Misses          4        4              
Impacted Files Coverage Δ
src/DitherPunk.jl 100.00% <ø> (ø)
src/clustering.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 7969627...c123651. Read the comment docs.