0

I'm building a software for a LED Canvas with 24 x 30 pixels. And I want to save the current state in a numpy array, then get a new state as a numpy array and slowly fade from the first state to the second state.

To do so I was thinking i have to compare my two numpy arrays:

currentState = np.zeros((24,30,3), 'int_') # All LEDs off e.g.
newState = np.zeros((24,30,3), 'int_') + 255 # All LEDS full white

Now i need an array with the difference between each item on the matrix like

currentState[x][y] = [0, 0, 0]
newState[x][y] = [255, 255, 255]
# Some compare operation
difference[x][y] = [255, 255, 255]

# or e.g.

currentState[x][y] = [255, 70, 30]
newState[x][y] = [100, 255, 30]
# Some compare operation
difference[x][y] = [-155, 185, 0]

Since execution time is crutial i don't wanna iterate over the matrix arrays. Is there any other way?

Thanks a lot in advance.

The answer is not currentState - newState. Please look carefully on the second example.

xioverflow
  • 113
  • 6

1 Answers1

0

Literally just subtract them:

difference = newState - currentState
Akaisteph7
  • 5,034
  • 2
  • 20
  • 43