I have a 3D array of image such as
[
[
[225, 0, 0],
[225, 225, 0],
...
],
[
[225, 0, 0],
[225, 225, 0],
...
],
...
]
The size of this array is 500x500x3 which is 750.000 elements. These are simple nested loops to iterate over the array
for row in arr:
for col in row:
for elem in col:
elem = (2 * elem / MAX_COLOR_VAL) - 1
But it takes a lot of time (> 5 min) to iterate.
I'm new in numpy so may be I'm iterating arrays wrong way? How can I optimize these loops?