It's fairly easy to write an interpolation routine in Theano. Here are nearest neighbour (3d) and trilinear for example. For your 2D case you can just knock off a variable. "image" is a tensor containing the image data, points is a list of coordinates giving the points you'd like the interpolated value of. I expect these will work, although be warned, I haven't tested them since Theano 0.7 or 0.8.
Nearest neighbour: x = T.clip(points[2],0,T.shape(image)[2]-2) y = T.clip(points[1],0,T.shape(image)[1]-2) z = T.clip(points[0],0,T.shape(image)[0]-2) nearestNeighbour = image[T.cast(T.floor(z),'uint16'),T.cast(T.floor(y),'uint16'),T.cast(T.floor(x),'uint16')] nearestNeighbour.name = self.name + '-nearestNeighbourSampler' Trilinear: x = T.clip(points[2],0,T.shape(image)[2]-2) y = T.clip(points[1],0,T.shape(image)[1]-2) z = T.clip(points[0],0,T.shape(image)[0]-2) x0 = T.cast(T.floor(x),'uint16') y0 = T.cast(T.floor(y),'uint16') z0 = T.cast(T.floor(z),'uint16') x1 = x0+1 y1 = y0+1 z1 = z0+1 xd = (x-x0) yd = (y-y0) zd = (z-z0) c00 = image[z0,y0,x0]*(1-xd) + image[z0,y0,x1]*xd c10 = image[z0,y1,x0]*(1-xd) + image[z0,y1,x1]*xd c01 = image[z1,y0,x0]*(1-xd) + image[z1,y0,x1]*xd c11 = image[z1,y1,x0]*(1-xd) + image[z1,y1,x1]*xd c0 = c00*(1-yd) + c10*yd c1 = c01*(1-yd) + c11*yd trilinear = c0*(1-zd) + c1*zd -- --- You received this message because you are subscribed to the Google Groups "theano-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
