interp2 with huge matrix
4 views (last 30 days)
Show older comments
Hello
Problem: I have a matrix (M) with 6000 by 11000 elements of complex or double type. The task is to preform a second order polynomial transformation (shift and warp) with interp2().
[X Y] = meshgrid(1:11000,1:6000); % very fast
% A and B are the coefficients
transY = A(1) + A(2)*Y + A(3)*X + A(4)*X.*Y + A(5)*X.^2 + A(6)*Y.^2; % very fast
transX = B(1) + B(2)*Y + B(3)*X + B(4)*X.*Y + B(5)*X.^2 + B(6)*Y.^2; % very fast
ZI = interp2(X,Y,M,transX,transY); % out of memory
The interp2() is very slow and as you can see there are four very large matrices and ZI would be the 5th, so running out of memory is always the case.
How to solve this problem?
So far I have tried to cut the matrix into tiles, but this does not work because of the NaN values for each tile.
Thanks in advance!
0 Comments
Answers (1)
the cyclist
on 6 Jul 2011
By "cut the matrix into tiles" do you mean doing the interpolation by sections (such as X=1:1000, then X=1001:1100, etc)? I would expect that to work, if handled properly and being careful about edge cases. Maybe you should post the code you used to try to do that part.
2 Comments
Ashish Uthama
on 6 Jul 2011
Michael, consider editing your question to add this code with proper formatting. Aside: blkproc or blockproc might be useful(?).
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!