Reputation: 11
How to compute the energy cost for Seam Carving in one loop iterating through the rows for python? Seam Carving Wiki Like the Dynamic programming in wiki ,I need the min_cost on the last row for possible three cell, and store the cost and path.
And , it is very slow by using two loop , so anyone know how to make it more efficiently?
Upvotes: 1
Views: 172
Reputation: 2013
You can use numba.jit to (possibly) speed up calculations, provided you respect the correct typing. There is no way to avoid 2 loops in a dynamic programming, however you can take a look at improved seam carving (which also yields better results in general)
https://github.com/axu2/improved-seam-carving https://medium.com/@avik.das/improved-seam-carving-with-forward-energy-88ba84dab7e
from numba import jit
@jit
def calc_seam(img):
...
Upvotes: 0