[ITK-users] Extract slice from ResampleFilter

Dženan Zukić dzenanz at gmail.com
Sat Apr 8 16:51:00 EDT 2017


Hi Sidharta,

your function to calculate interpolated Hounsfield values seems correct.

Your problem of selecting oblique slice to resample can be reduced to
finding a plane which passed through your first and last point, and as an
arbitrary constraint passes through point [0,0,0]. If this point is
collinear with your line then pick point [1,0,0], [0,1,0] or [0,0,1]. One
of them will not be collinear.

In order to resample your oblique slice, you need to figure out a transform
matrix which transforms your first point to coordinates [0,0,0], your last
point to coordinates e.g. [1000,0,0] and transforms the normal of your
plane to be parallel with vector [0,0,1].

Then use resample filter, set your transform matrix and set as target
image's region index [0,0,0] and size [1001,1,1]. Alternatively index
[0,-10,0] and size [1001,21,1] if you want to have a real 2D slice to look
at.

Hope this helps,
Dženan

On Thu, Apr 6, 2017 at 8:34 AM, sidharta <sidharta.gupta93 at gmail.com> wrote:

> Dear all,
>
> I am trying to extract density profile along a trajectory in CT. Using some
> adjustments to contour-based segmentation and getting a mesh from the
> binary
> mask, I computed certain trajectories tangential to certain faces/vertices
> of the mesh.
>
> Now, I have the coordinates of the target point and a tangent to the
> target.
> So, depending on the spacing, I extract all the points along the tangent
> which are 5mm away from the target. I am using following code to generate
> densities after I have got the physical coordinates along this line.
>
> void generateDensities(std::vector<Vector3d> points,
> InternalImageType::Pointer image){
>
>         InternalImageType::IndexType pixelIndex;
>         PointType point;
>         itk::ContinuousIndex<double, Dimension> pixel;
>         linearInterpolationContinuousIndexType::Pointer interpolate =
> linearInterpolationContinuousIndexType::New();
>
>         interpolate->SetInputImage(image);
>
>         std::vector<int> HU_values;
>         std::vector<double> HU_values_interpolate;
>         std::vector<InternalImageType::IndexType> Pixel_indices;
>         std::vector<itk::ContinuousIndex<double, Dimension>>
> Pixel_indices_interpolated;
>         // std::cout << "Generating with interpolation" << std::endl;
>         for (int i = 0; i < points.size(); i++)
>         {
>                 Vector3d temp_point = points.at(i);
>                 point[0] = temp_point[0];
>                 point[1] = temp_point[1];
>                 point[2] = temp_point[2];
>                 // std::cout << "Getting continuous index " << std::endl;
>                 bool isInside = image->TransformPhysicalPointToContin
> uousIndex(point,
> pixel);
>                 if (isInside)
>                 {
>                         InternalImageType::PixelType pixelValue =
> interpolate->EvaluateAtContinuousIndex(pixel);
>                         HU_values_interpolate.push_back(pixelValue);
>                         Pixel_indices_interpolated.push_back(pixel);
>                 }
>                 else
>                         std::cout << "Point " << point << " with index "
> << pixel << "is outside"
> << std::endl;
>         }
>         All_HU_values_interpolated.push_back(HU_values_interpolate);
>         All_pixel_indices_interpolated.push_back(Pixel_
> indices_interpolated);
>         HU_values_interpolate.clear();
>         HU_values.clear();
> }
>
> Now, for verification that I am actually getting in fact the correct
> values,
> I would like to extract the oblique slice along this trajectory and I
> figure
> I have to use the Resample filter to "transform" the CT so that rotation
> puts the resampled CT coordinate system parallel to the trajectory and the
> origin translated to the start of the trajectory. Now, along the
> trajectory,
> with the set of collinear points (along the trajectory), I can get a lot of
> planes (oblique slices essentially) which have the trajectory in them. So
> to
> get around this, I figure if I give another point which is non-collinear to
> these points, I can specify the exact oblique slice I want. However, this
> is
> something I have to figure out for a lot of trajectories for the same CT
> and
> then correspondingly for others. Can someone tell me how can I achieve this
> "automatically" for all trajectories/CTs?
> PS. All CTs have the same spacing and origin.
> Kindly also mention if you think the function for generating the densities
> is correct or not? Eitherways I would like to validate.
>
> Thank you,
> Sidharta
>
>
>
>
> --
> View this message in context: http://itk-users.7.n7.nabble.
> com/Extract-slice-from-ResampleFilter-tp38074.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170408/4abc8f8f/attachment.html>


More information about the Insight-users mailing list