Looping scatteredInterpolant across each frame in 3D matrix
Show older comments
I am trying to perform a 2D interpolation across each frame in the 3rd dimension in a 3D matrix.
I have:
xgrid: 759x551
ygrid: 759x551
zgrid: 759x551x523
I am hoping to interpolate each frame of the zgrid but scatteredInterpolant does not allow indexing nor the use of cell arrays.
My first step is to use meshgrid to create the 2D resolution I desire, I end up with:
xgrid_q: 301x201
ygrid_q: 301x201
My question is, how do I interpolate the zgrid into 301x201x523?
4 Comments
If we've misunderstood your input data, I would advise attaching xgrid, ygrid, xgrid_q, ygrid_q in a .mat file (all four in one single file) so we can see what it really is.
Laura Szczyrba
on 1 Jun 2023
My data is gridded but it is not a regular rectangular grid. I am hoping to interpolate it onto a regular grid. When I try to use griddedInterpolant, I get an error that the grid arrays must have NDGRID structure.
If your data is gridded, it should have NDGRID structure. That's what it means to be gridded.
Please shows us the plot you get when you do this,
scatter(xgrid(:),ygrid(:))
zooming in as necessary so we can see how the xgrid(i),ygrid(i) pairs are spaced apart.
Laura Szczyrba
on 1 Jun 2023
Accepted Answer
More Answers (1)
Since your grids are related by an affine warping, it might be best to use imwarp, assuming you have the appropriate toolbox.Example:
zgrid(:,:,1) = imread('cameraman.tif');
zgrid(:,:,2) = imresize(im2gray(imread('peppers.png')),[256,256]);
montage(zgrid)
tform = affine2d([1 0 0; .5 1 0; 0 0 1]);
Zgrid = imwarp(zgrid,tform);
montage(Zgrid)
Categories
Find more on Downloads in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

