If I'm reading your question correctly, you have some voxel size in millimetres and this is not necessarily isotropic (i.e. the voxels are not regular cubes).
So if each voxel has dimensions dx * dy * dz
and you have two voxels at positions (x1, y1, z1)
and (x2, y2, z2)
, the you want to find the Euclidean (straight line) distance between these two points in millimetres.
So, first convert each point to get a spatial position (call these s1
and s2
)
s1(x,y,z) = (x1 * dx, y1 * dy, z1 * dz)
, and
s2(x,y,z) = (x2 * dx, y2 * dy, z2 * dz)
Then the distance, d
, between these points in millimetres is then length of the vector, v
, from s1
to s2
v(x,y,z) = (s2.x - s1.x, s2.y - s1.y, s2.z - s1.z)
Distance d = sqrt(v.x^2 + v.y^2 + v.z^2)
millimetres.