You’re very welcome.
Robert Brown, PhD McConnell Brain Imaging Centre Montreal Neurological Institute Montreal, Canada www.robbtech.com <http://www.robbtech.com/> github.com/robb-brown <http://github.com/robb-brown> > On May 23, 2018, at 4:00 PM, Vital Fernández <lativm...@gmail.com> wrote: > > Wow Robb. Thank you very much. I am going to play with this to make a > complete script then I will post it here :). > > Thanks > > On Wednesday, 23 May 2018 14:48:09 UTC-5, Robb Brown wrote: > 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 <http://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 a topic in the Google > Groups "theano-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/theano-users/lPN_vWkOIK0/unsubscribe > <https://groups.google.com/d/topic/theano-users/lPN_vWkOIK0/unsubscribe>. > To unsubscribe from this group and all its topics, send an email to > theano-users+unsubscr...@googlegroups.com > <mailto:theano-users+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- --- 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 theano-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.