[numpy] optimiser un filtre pour 2 arrays
bonjour,
je voudrai optimiser ce code qui met 140 ms à s'executer sur ma bécane.
surfarray.array_alpha() et surfarray.pixels_alpha() retour des arrays.
Code:
1 2 3 4 5 6 7 8
| def blend_alpha(surface1,surface2):
output = surface2.copy().convert_alpha()
a = surfarray.array_alpha(surface1)
b = surfarray.array_alpha(surface2)
for x in range(output.get_width()):
for y in range(output.get_height()):
if a[x][y]<b[x][y]: surfarray.pixels_alpha(output)[x][y] = a[x][y]
return output |
voilà, il faut donc filtrer 2 arrays genre [[5,2,4],[9,7,3],[0,4,8]...] et [[6,7,1],[0,2,7],[9,6,3]...]
et il faut retourner un array avec les valeurs min: [[5,2,1],[0,2,3],[0,4,3]...]
merci pour votre aide.