3 ms·
Just for the fun of it I tested what speed up I could get with a naive algorithm and pythran. Based on your description it looks like the I should do the follow
by cycomanic 6y ago
Just for the fun of it I tested what speed up I could get with a naive algorithm and pythran. Based on your description it looks like the I should do the following:
def threshold_pixel(img, thr):
out = np.zeros_like(img)
o = np.mean(img, axis=-1)
out[o>thr] = 255
return out
This runs in ~30ms for a (1024,1024,3) array using numpy on my machine. Using pythran (note I had to explicitely write out the loop for out[o>thr] =255, due to a bug, that I found and just reported), I get a speed of 6.ms (with openmp) and 9ms without (I did not tune the openmp, but this should yield a much higher speedup).
P.S.: Just had a look at your project, very cool, I have to try that