python - Is there A 1D interpolation (along one axis) of an image using two images (2D arrays) as inputs? -


this question has answer here:

i have 2 images representing x , y values. images full of 'holes' (the 'holes' same in both images).

i want interpolate (linear interpolation fine though higher level interpolation preferable) along 1 of axis in order 'fill' holes.

say axis of choice 0, is, want interpolate across each column. have found numpy interpolation when x same (e.g. numpy.interpolate.interp1d). in case, however, each x different (i.e. holes or empty cells different in each row).

is there numpy/scipy technique can use? 1d convolution work?(though kernels fixed)

you still can use interp1d:

import numpy np scipy import interpolate = np.array([[1,np.nan,np.nan,2],[0,np.nan,1,2]]) #array([[  1.,  nan,  nan,   2.], #       [  0.,  nan,   1.,   2.]])  row in a:     mask = np.isnan(row)     x, y = np.where(~mask)[0], row[~mask]     f = interpolate.interp1d(x, y, kind='linear',)     row[mask] = f(np.where(mask)[0]) #array([[ 1.        ,  1.33333333,  1.66666667,  2.        ], #       [ 0.        ,  0.5       ,  1.        ,  2.        ]]) 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -