Hi,

I have to process hundreds of movies, each of which has hundreds of frames. I need to perform an affine transform warp, followed by a 3rd order polynomial transform warp. I have the coefficients. I have tried the warps on individual randomly selected frames, and they look correct.

Each movie is a 3D matrix of shape [frames, nPixX, nPixY]. It would be very slow to apply the transform to every frame using for-loop. Do you have suggestions on how a (python) for-loop can be bypassed?

In my naive understanding of mathematics, any warp or combination of such is a linear operation onto the pixels of the original image. Thus, it should be possible to obtain such A and B that

ImgNew = A*ImgOld + B

If this is possible, I could use numpy multiplication and addition to have much faster performance than repeating this for every frame.

My movie is 256*256 pixels. I understand that the naive solution would result in a dense matrix A of size 2^32 ~ 4 Gb. While theoretically feasible, its probably not the optimal solution. However, the warping operation I have in mind is not strongly nonlinear, therefore matrix A would be very sparse. So a solution with sparse matrix transform would likely be optimal…