I didn't find any ITK filter to do this, so I just wrote a simple function
myself.
I use an array (zSlicePos array) to store the slice position for each slice
of the original non-uniform data.
Then, for each slice of the target uniformly-spaced image,
I first compare its z-coordinate with the entries of the slice-position
array to find the indexes of the
two closest slices in the original data, one to the left (or top) and one to
the right (or bottom).
Then a simple interpolation can be performed, as in the following pheudo
code:

       // compute the weights for interpolation in z-direction
(slice-direction)
       // zSlicePos stores the physical z-coordinate for each slice of the
original data
       // "leftslice" and "rightslice" are the indexes of the two closest
slices of the original data
       // "z" is the physical coordinate of the slice (of the target
uniform-spacing image) to be interpolated
       leftweight = zSlicePos[leftslice] - z;
       rightweight = zSlicePos[rightslice] - z;

       // perform interpolation for each voxel on the current slice
       for(int yindex = 0; yindex < newYSize; yindex++)
       {
            for(int xindex = 0; xindex < newXSize; xindex++)
            {
                newVal = leftweight* oldImage[xindex][yindex][leftslice] -

rightweight*oldImage[xindex][yindex][rightslice];
                newVal = newVal/(leftweight - rightweight);
                newImage[xindex][yindex][zindex] = newVal;
           }
       }

Of cause, the size and spacing of the target uniform-spacing image have to
be determined before computing the interpolation.
I used the median value of the original set of unevenly slice-spacing values
as the spacing of the final image, but you may prefer to use the minimum
value or any other
criterion. The origin and size of the new image can be set to cover the
physical expansion of the original set of slices.

Hope this helps,

Xiao




On Wed, Apr 1, 2009 at 10:55 AM, sebastian ordas
<[email protected]>wrote:

> thanks Xiao.
>
> so what you suggest is to do an interpolation along the z axis, right?
> but how to take into account the uneven spacing in that interpolation?
> Is there any ITK filter for this aim?
>
> thanks
> sebastian
>
> On Wed, Apr 1, 2009 at 12:49 PM, Xiao Han <[email protected]> wrote:
> > Unevenly spaced slices happen a lot for DICOM images as well.
> > What I did is to first load the data to a 3D volume (ignore the uneven
> > spacing at the file reading step),
> > then re-sample this temporary volume to uniform spacing as the final
> loaded
> > image.
> > The re-sampling is pretty simple since only interpolation along the slice
> > direction is needed.
> >
> > I think this re-sampling step is unavoidable, but it only need be done
> once
> > and all later image manipulation can
> > simply use the re-sampled, uniformly-spaced image.
> >
> > Hope this helps,
> >
> > Xiao
> >
> >
> > On Wed, Apr 1, 2009 at 8:09 AM, sebastian ordas <
> [email protected]>
> > wrote:
> >>
> >> Hi Team,
> >>
> >> I would like to extend the raw reader to allow for importing unevenly
> >> spaced slices (jpeg images) into a single data set?
> >> I could have a separate text file with the interslice separation, but
> >> how to gather the slices into a single volume? mitk::Image does not
> >> allow such arrangement, right?
> >>
> >> Any advice would be greatly appreciated.
> >>
> >> best regards,
> >> sebastian
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> _______________________________________________
> >> mitk-users mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/mitk-users
> >
> >
>
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to