for s in range (0, hist.shape[1]): for i in range (0, hist.shape[0], 2): #if green if hist[i,s] > hist[i+1,s]: histimg[i,s,1] = (hist[i,s] - hist[i+1,s]) #red else: histimg[i,s,2] = hist[i+1,s] - hist[i,s]