4
votes
1answer
141 views

Optimizing Python / Numpy Code

So I'm implementing a version of the mean shift image processing algorithm for color segmentation in python/numpy. I've written a pure numpy version of the actual mean shifting per pixel (which I ...
1
vote
2answers
317 views

Python: optimize this rolling loop

I have a numpy array of about 2500 data points. This function is called on a rolling basis where 363 data points is passed at a time. def fcn(data): a = [data[i]/np.mean(data[i-2:i+1])-1 for i in ...