<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Sidharta,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">your function to calculate interpolated Hounsfield values seems correct.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">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.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">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].</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">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.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hope this helps,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Dženan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 6, 2017 at 8:34 AM, sidharta <span dir="ltr"><<a href="mailto:sidharta.gupta93@gmail.com" target="_blank">sidharta.gupta93@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br>
<br>
I am trying to extract density profile along a trajectory in CT. Using some<br>
adjustments to contour-based segmentation and getting a mesh from the binary<br>
mask, I computed certain trajectories tangential to certain faces/vertices<br>
of the mesh.<br>
<br>
Now, I have the coordinates of the target point and a tangent to the target.<br>
So, depending on the spacing, I extract all the points along the tangent<br>
which are 5mm away from the target. I am using following code to generate<br>
densities after I have got the physical coordinates along this line.<br>
<br>
void generateDensities(std::vector<<wbr>Vector3d> points,<br>
InternalImageType::Pointer image){<br>
<br>
InternalImageType::IndexType pixelIndex;<br>
PointType point;<br>
itk::ContinuousIndex<double, Dimension> pixel;<br>
linearInterpolationContinuousI<wbr>ndexType::Pointer interpolate =<br>
linearInterpolationContinuousI<wbr>ndexType::New();<br>
<br>
interpolate->SetInputImage(<wbr>image);<br>
<br>
std::vector<int> HU_values;<br>
std::vector<double> HU_values_interpolate;<br>
std::vector<InternalImageType:<wbr>:IndexType> Pixel_indices;<br>
std::vector<itk::<wbr>ContinuousIndex<double, Dimension>><br>
Pixel_indices_interpolated;<br>
// std::cout << "Generating with interpolation" << std::endl;<br>
for (int i = 0; i < points.size(); i++)<br>
{<br>
Vector3d temp_point = <a href="http://points.at" rel="noreferrer" target="_blank">points.at</a>(i);<br>
point[0] = temp_point[0];<br>
point[1] = temp_point[1];<br>
point[2] = temp_point[2];<br>
// std::cout << "Getting continuous index " << std::endl;<br>
bool isInside = image-><wbr>TransformPhysicalPointToContin<wbr>uousIndex(point,<br>
pixel);<br>
if (isInside)<br>
{<br>
InternalImageType::PixelType pixelValue =<br>
interpolate-><wbr>EvaluateAtContinuousIndex(<wbr>pixel);<br>
HU_values_interpolate.push_<wbr>back(pixelValue);<br>
Pixel_indices_interpolated.<wbr>push_back(pixel);<br>
}<br>
else<br>
std::cout << "Point " << point << " with index " << pixel << "is outside"<br>
<< std::endl;<br>
}<br>
All_HU_values_interpolated.<wbr>push_back(HU_values_<wbr>interpolate);<br>
All_pixel_indices_<wbr>interpolated.push_back(Pixel_<wbr>indices_interpolated);<br>
HU_values_interpolate.clear();<br>
HU_values.clear();<br>
}<br>
<br>
Now, for verification that I am actually getting in fact the correct values,<br>
I would like to extract the oblique slice along this trajectory and I figure<br>
I have to use the Resample filter to "transform" the CT so that rotation<br>
puts the resampled CT coordinate system parallel to the trajectory and the<br>
origin translated to the start of the trajectory. Now, along the trajectory,<br>
with the set of collinear points (along the trajectory), I can get a lot of<br>
planes (oblique slices essentially) which have the trajectory in them. So to<br>
get around this, I figure if I give another point which is non-collinear to<br>
these points, I can specify the exact oblique slice I want. However, this is<br>
something I have to figure out for a lot of trajectories for the same CT and<br>
then correspondingly for others. Can someone tell me how can I achieve this<br>
"automatically" for all trajectories/CTs?<br>
PS. All CTs have the same spacing and origin.<br>
Kindly also mention if you think the function for generating the densities<br>
is correct or not? Eitherways I would like to validate.<br>
<br>
Thank you,<br>
Sidharta<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-users.7.n7.nabble.com/Extract-slice-from-ResampleFilter-tp38074.html" rel="noreferrer" target="_blank">http://itk-users.7.n7.nabble.<wbr>com/Extract-slice-from-<wbr>ResampleFilter-tp38074.html</a><br>
Sent from the ITK - Users mailing list archive at Nabble.com.<br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>