Sometimes I think numpy ruined a perfectly good language. intersection = ((pixels_0 < 255) & (pixels_1 < 255)).sum()