In this example, a continuous value of 1.3 is located between index1 and index2 and at a distance of 0.3. Since the pixel values are 10 and 20 at these two indices, you get an output of 13.
However, if we change the image spacing to 0.5, the continuous position of 1.3 would be one would expect a different output of (0.7 x 20 + 0.3 x 30) = 23. But it appears that the interpolate function does not take into account image spacing. This is a problem because if we have different spacings in X, Y and Z (as is the case in microscopy modalities), the interpolation result wont be accurate.
@dzenanz : Yes, I got the convention correct now – thank you!
But even then, going by your calculation for the spacing of 0.5, the pixel value is 0.6 x 30 (pixel 3) + 0.4 x 20 (pixel 2) = 26. The answer we get from the code block is 13 irrespective of what the image spacing is set to.