function dither_bw(img)
alg = DitherPunk.FloydSteinberg()
img = Gray{N0f8}.(img)
img_bw = DitherPunk.dither(img, alg, [Gray{N0f8}(0), Gray{N0f8}(1)])
return Bool.(img_bw)
end
img = testimage("cameraman");
@btime dither_bw($img) # 109.763 ms (5453396 allocations: 86.75 MiB)
vs MATLAB's dither function
img = imresize(imread("cameraman.tif"), [512, 512]);
f = @() dither(img)
timeit(f) * 1000 % 2.8ms
It indicates that DitherPunk can be faster. The massive allocation count looks like type instability to me.
vs MATLAB's
ditherfunctionIt indicates that DitherPunk can be faster. The massive allocation count looks like type instability to me.