How to perform shuttle interpolation in Matlab?

I have two matrices A and B containing values ​​for a checkerboard / chessboard grid shape

 AxAxAxAx... xBxBxBxB... AxAxAxAx... xBxBxBxB... ........... ........... 

Where x represents values ​​that are not yet known that I want to (linearly) interpolate. What is the easiest way to achieve this?

First of all, it’s possible

 C = zeros(size(A)+size(B)); C(1:2:end,1:2:end) = A; C(2:2:end,2:2:end) = B; 

to get the above matrix. Now I could iterate over all the remaining points and take the average of all direct neighbors, since 1) for loops in matlab are slow and 2) there, of course, there is a way to use interp2 , although this seems to require a meshgrid like mesh. So, can this be done easier / faster?

+4
source share
1 answer

Thanks woodchips answer here I found it inpaint_nans , the solution is really simple:

 C = nan(size(A)+size(B)); C(1:2:end, 1:2:end) = A; C(2:2:end, 2:2:end) = B; C = inpaint_nans(C); 
+7
source

All Articles