[Scilab-users] Padding and clipping a grid
arctica1963
arctica1963 at gmail.com
Sun Jul 29 13:18:18 CEST 2018
Hello all,
I need to increase the dimensions over which the FFT is calculated to avoid
edge effects, and following the suggestion of Samuel Gougeon back in 2016,
this was recommended:
Scilab: 6.0.1
data = [1 2 3; 4 5 6; 7 8 9]
addedRows = 3; addedCols = 3;
tmp = [data ; data($, :) .*. ones(addedRows, 1)]; // add rows to bottom
tmp = [tmp tmp(:, $) .*. ones(1,addedCols)]; // add columns to right
tmp = [repmat(tmp(1, : ), addedRows, 1) ; tmp]; // add rows to top
paddedMat = [repmat(tmp(:,1) , 1, addedCols) tmp] // add columns to left
Now, it is important to adjust the input spatial limits (e.g. degrees) for
the new grid:
e.g. x1 = -1, x2 = 1, y1 = -1, y2 = 1 original spatial limits
pad = 1 // add 1 unit to all edges
x1a = x1 - pad
x2a = x2 + pad
y1a = y1 - pad
y2a = y2 + pad
xx1a = linspace(x1a,x2a,new_xdim)
yy1a = linspace(y1a,y2a,new_ydim)
[X,Y] = meshgrid(xx1a,yy1a) etc.
What I would like to do is then run the FFT on the expanded grid and then
clip it back to the original dimensions (before padding) and spatial limits
after processing.
Is there a simple solution to this? I was thinking
resize_matrix(data,dimx,dimy), but not sure how to get the original grid
clipped out. So in the example above, go from the padded limits (-2,2,-2,2)
back to (-1,1,-1,1).
Sorry if this is a really simple solution, still learning!
Thanks
Lester
--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
More information about the users
mailing list