minrows for in sorted np sum img row row for row in range img shape 50

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
minrows = [r[1] for r in sorted([(np.sum(img[row,:]),row) for row in range(img.shape[0])])[:50]]
cols = []
for col in range(100,img.shape[1]):
avg = np.sum(img[minrows,col]) / img.shape[0]
cols.append(avg)
freq = np.fft.fft(cols)
freq[100:] = 0
print abs(np.fft.ifft(freq))
diff = abs(cols - np.fft.ifft(freq))
print diff
maxDiff = max(diff)
for i in range(len(diff)):
if diff[i] > maxDiff *0.20:
img[:,i+100] = np.sum(img.flatten()) / len(img.flatten())