L.append(np.sign(smoothness(flip) - smoothness(g)))
N = len(L)
R = float(L.count(1))/N
S = float(L.count(-1))/N
return R-S
// }}}
After Change
for g in groups(I, mask):
flip = (g + cmask) ^ abs_mask - cmask
result = np.sign(smoothness(flip) - smoothness(g))
if result not in counts:
counts[result] = 0
counts[result] += 1
N = sum(counts.values())
R = float(counts[1])/N
S = float(counts[-1])/N