<div dir="ltr"><div>Hi Greg,</div><div><br></div><div>Rotating the image will work, and you wouldn't have to rotate the entire image, since you're only interested in certain pixels.</div><div><br></div><div>The filter vtkImageReslice will translate and rotate an image via interpolation, and you can set it up so that the output is just one single line (or several lines, to make a thick line). The tricky part is finding the correct rotation and translation for SetResliceAxes(). It could be done as follows:</div><div><br></div><div>First, note that the direction of the ResliceAxes transformation is Output->Input (ditto for ResliceTransform, it does the same thing).</div><div><br></div><div>The translation part of the transformation is easy: if the output of vtkImageReslice is a line of pixels (voxels) starting at (0,0,0), then we want a translation that moves point (0,0,0) to (px,py,pz) where the latter is the starting point of the profile line.<br></div><div><br></div><div>And to keep the rotation simple, the output of vtkImageReslice can be one line of pixels along the x-axis, and then we want a rotation that will rotate a unit x-axis vector to the direction vector of the profile line. It's possible to compute the rotation between vectors by doing a cross product, but fortunately there is a method, vtkMath::Perpendiculars(), that can easily do what we need when one of the vectors happens to be the x-axis vector.</div><div><br></div><div>So let's say the profile line starts at (px,py,pz) and has a unit direction vector of (vx,vy,vz). The needed ResliceAxes transformation will be as follows:</div><div><br></div><div>double resliceAxesValues[16] = {</div><div> vx, ux, wx, px,<br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> vy, uy, wy, py,</span><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> vz, uz, wz, pz,</span><br></span></div><div> 0, 0, 0, 1 };</div><div><br></div><div>We already have (px, py, pz) as the translation part of the 4x4 matrix, and (vx, vy, vz) as the first column of the 3x3 rotation matrix. The aforementioned vtkMath::Perpendiculars() method can be used to compute suitable "u" and "w" values:</div><div><br></div><div>// compute vectors u, w that are perpendicular to an existing vector v:</div><div>double u[3], w[3];</div><div>vtkMath::Perpendiculars(v, u, w, 0.0);</div><div><br></div><div><br></div><div>If you wanted to do just a single line via a rotation of the image, you could do it like this:</div><div><br></div><div>reslice = vtk.vtkImageReslice()</div><div>reslice.SetInputConnection( ... )</div><div>reslice.SetOutputOrigin(0, 0, 0)</div><div>reslice.SetOutputSpacing( ...) # use original image spacing</div><div>reslice.SetOutputExtent(0, N, 0, 0, 0, 0) # this gives one line of output</div><div>reslice.SetInterpolationModeToLinear()</div><div>reslice.SetResliceAxes( ... )</div><div><br></div><div>The output of vtkImageReslice will be the values along the line. Fiddling with Origin and OutputExtent can do several lines at once.</div><div><br></div><div> - David</div><div><br></div><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 3, 2018 at 4:33 PM, gregthom992 <span dir="ltr"><<a href="mailto:gregthom992@gmail.com" target="_blank">gregthom992@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks David,<br>
<br>
I think your idea is certainly interesting and I want to work on it later<br>
after the current idea I just had.<br>
<br>
Right now the idea I had was to first orient (rotate ) image so that it is<br>
aligned with the line. After which I intend to simply get rows from the<br>
rotated image. I am not sure how this will work.<br>
I am still reading how to build this pipeline. Do you have any pointers to<br>
speed this up for me ?<br>
<div class="HOEnZb"><div class="h5"><br>
Thanks<br>
<br>
GT<br></div></div></blockquote></div></div></div>