1

I have an ndarray which represents a rgb color:

upper = np.array([100,50,255], dtype="uint8")

When I increment it:

upper += 1

It gives me: [101 51 0]

I understand that, but I don't want the wrapping around the 0-255 range boundaries.

Is there a numpy way (not a manual loop) to say: increment each value of the array, unless the value is 255 (in which case do nothing)?

ling
  • 9,545
  • 4
  • 52
  • 49

0 Answers0