体积切片操作通常依赖于插值的概念,最典型的是:Nearest neighbor,Linear,和{a3}。请注意,这些方法适用于更多的维度(例如请参见Bilinear或Trilinear插值)。在
在本例中,您是说您有一个卷,可以从中检索X、Y、Z(或一个混合体,但不考虑这种情况,因为这是一个新的整体问题,只会带来混乱)。在
以切片X=5和X=6为例,你想知道如何得到X=5.5。看看这个例子:def linear_interpolation(p1, p2, x0):
"""
Function that receives as arguments the coordinates of two points (x,y)
and returns the linear interpolation of a y0 in a given x0 position. This is the
equivalent to obtaining y0 = y1 + (y2 - y1)*((x0-x1)/(x2-x1)).
Look into https://en.wikipedia.org/wiki/Linear_interpolation for more
information.
Parameters
p1 : tuple (floats)
Tuple (x,y) of a first point in a line.
p2 : tuple (floats)
Tuple (x,y) of a second point in a line.
x0 : float
X coordinate on which you want to interpolate a y0.