python中的图像插值
我试图用插值来消除图像的色差。我的代码生成了以下错误:TypeError:unhabable类型:“numpy.ndarray”。下面是我的代码-任何帮助都将不胜感激。谢谢-阿雷伊 这是一个输入说明python中的图像插值,python,numpy,scipy,Python,Numpy,Scipy,我试图用插值来消除图像的色差。我的代码生成了以下错误:TypeError:unhabable类型:“numpy.ndarray”。下面是我的代码-任何帮助都将不胜感激。谢谢-阿雷伊 这是一个输入说明 #splitting an image into its separe bands source = im.split() Cfixed = source[2] Cwarp = source[1] #take the image minus a ew-wide edge roi = [ew+1,
#splitting an image into its separe bands
source = im.split()
Cfixed = source[2]
Cwarp = source[1]
#take the image minus a ew-wide edge
roi = [ew+1, xdim-ew, ew+1, ydim-ew];
roi_pad = [roi[0]-ew, roi[1]+ew, roi[2]-ew, roi[3]+ew];
for k in range(0,centers_x.size):
cx = centers_x[k]
cy = centers_y[k]
wz = warps[k]
import scipy as sp
from scipy import interpolate
def warpRegion(Cwarp, roi_pad, (cx, cy, wz)):
#Unpack region indices
sx, ex, sy, ey = roi_pad
xramp, yramp = np.mgrid[sx:ex+1, sy:ey+1]
shapeofgrid=xramp.shape
print 'shape of x grid'+str(shapeofgrid)
xrampc = xramp - cx;
yrampc = yramp - cy;
xramp1 = 1/wz*xrampc;
yramp1 = 1/wz*yrampc;
xrampf = xrampc.flatten()
yrampf = yrampc.flatten()
xramp1f = xramp1.flatten()
yramp1f = yramp1.flatten()
reg_w = sp.interpolate.interp2d(yrampf,xrampf,Cwarp, yramp1f, xramp1f,'cubic');
错误消息的一种可能解释是,您试图将NumPy数组用作dict键或set元素。查看错误发生的位置,并研究该行中引用的每个变量的类型。如果需要帮助,请发布一个可运行的示例和异常的完整回溯。我建议使用PIL。(Python图像库) 一种方法是:
生成每个象限/采样区域的顶色列表并散列该列表请添加一些生成示例输入数据的代码(以及可能的numpy/scipy导入语句)source=im.split()Cfixed=source[2]Cwarp=source[1]#获取图像减去ew宽边roi=[ew+1,xdim-ew,ew+1,ydim-ew];我的意思是将其添加到代码中,使其成为一个完整但最小的示例(即没有任何不重要的额外代码)。你需要帮助别人帮助你,所以如果他们能直接运行你的代码,那么你就更有可能修复你的问题。另外,你能添加完整的错误信息吗?例如,包括行号我很抱歉,我正在试图弄清楚如何正确格式化我在这个链接上再次发问我在这个链接上发问了