<div dir="ltr">Thank you, seems to work, at least I see both images in the same position now.<div><br></div><div>Now, if I understand correctly, the NDI tracker points should try to match the mesh points, that's not happening, my NDI points although are closer to the mesh, still are upside down even after running <span style="font-family:arial,sans-serif;font-size:13px">vtkIterativeClosestPointTransf</span><span style="font-family:arial,sans-serif;font-size:13px">orm </span>(see the image attached). So I think even if it runs correctly, it's going to be hard for vtk to find the match between points..</div>
<div><br></div><div>Thanks,</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 20, 2014 at 7:12 PM, Maarten Beek <span dir="ltr"><<a href="mailto:beekmaarten@yahoo.com" target="_blank">beekmaarten@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif">Source is moved to target -> it's your choice<br>
<br>use StartByMatchingCentroidsOn() to align the centers first.<div><div class="h5"><br><div><span><br></span></div><div style="display:block"> <br> <br> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:12pt">
<div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:12pt"> <div dir="ltr"> <font face="Arial"> On Monday, January 20, 2014 1:57:24 PM, Matias Montroull <<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>> wrote:<br>
</font> </div> <div><div><div><div dir="ltr">Ok, so here's my code: See the registration commented section at the bottom.<div><br clear="none"></div><div>Question, Source
should be my NDI points or the mesh points?</div><div><br clear="none"></div><div>Thanks for your time..<br clear="none">
<div><br clear="none"></div><div><div>//Mesh</div><div> vtkDICOMImageReader readerdicom = new vtkDICOMImageReader();</div><div> readerdicom.SetDirectoryName(@"C:\CDDICOM\images");</div><div>
readerdicom.Update();</div>
<div><br clear="none"></div><div>//extract skin</div><div> vtkContourFilter skinextractor = vtkContourFilter.New();</div><div> skinextractor.SetInputConnection(readerdicom.GetOutputPort());</div><div>
skinextractor.SetValue(0, -800);</div>
<div><br clear="none"></div><div>//remove inner points</div><div> vtkPolyDataConnectivityFilter contornos = new vtkPolyDataConnectivityFilter();</div><div> contornos.SetInputConnection(skinextractor.GetOutputPort());</div>
<div> contornos.SetExtractionModeToLargestRegion();</div><div> contornos.SetColorRegions(1);</div><div> vtkCleanPolyData removepoints = new vtkCleanPolyData();</div><div> removepoints.SetInput(contornos.GetOutput());</div>
<div> removepoints.Update();</div><div><br clear="none"></div><div> vtkPolyDataNormals skinnormals = vtkPolyDataNormals.New();<br clear="none"></div><div> skinnormals.SetInputConnection(removepoints.GetOutputPort());</div>
<div> skinnormals.SetFeatureAngle(90.0);</div><div> skinnormals.ComputePointNormalsOn();</div><div><br clear="none"></div><div> vtkPolyDataMapper skinmapper = vtkPolyDataMapper.New();</div>
<div> skinmapper.SetInputConnection(skinnormals.GetOutputPort());</div>
<div> skinmapper.ScalarVisibilityOff();</div><div><br clear="none"></div><div> vtkActor actor_mesh = vtkActor.New();</div><div> actor_mesh.SetMapper(skinmapper);</div><div><br clear="none">
</div><div><br clear="none"></div><div>
//Rregistracion (I load my NDI tracker registered points)</div><div><br clear="none"></div><div> vtkTesting test = vtkTesting.New();</div><div> string root = test.GetDataRoot();</div><div> string filePath = System.IO.Path.Combine(root, @"C:/tracker/reg.poi");</div>
<div><br clear="none"></div><div> FileStream fs = null;</div><div> StreamReader sr = null;</div><div> String sLineBuffer;</div><div> String[] sXYZ;</div><div> char[] chDelimiter = new char[] { ' ', '\t', ';' };</div>
<div> double[] xyz = new double[3];</div><div> vtkPoints points = vtkPoints.New();</div><div> int cnt = 0;</div><div><br clear="none"></div><div><br clear="none"></div><div> // in case file must be open in another application too use "FileShare.ReadWrite"</div>
<div> fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);</div><div> sr = new StreamReader(fs);</div><div> while (!sr.EndOfStream)</div><div> {</div>
<div> sLineBuffer = sr.ReadLine();</div><div> cnt++;</div><div> sXYZ = sLineBuffer.Split(chDelimiter, StringSplitOptions.RemoveEmptyEntries);</div><div> if (sXYZ == null)</div>
<div> {</div><div> System.Windows.MessageBox.Show("data seems to be in wrong format at line " + cnt, "Format Exception");</div><div> return;</div><div>
}</div><div> xyz[0] = double.Parse(sXYZ[0], CultureInfo.InvariantCulture);</div><div> xyz[1] = double.Parse(sXYZ[1], CultureInfo.InvariantCulture);</div><div> xyz[2] = double.Parse(sXYZ[2], CultureInfo.InvariantCulture);</div>
<div> points.InsertNextPoint(xyz[0], xyz[1], xyz[2]);</div><div> }</div><div> vtkPolyData polydata = vtkPolyData.New();</div><div> polydata.SetPoints(points);</div><div><br clear="none">
</div><div> vtkSurfaceReconstructionFilter surf = new vtkSurfaceReconstructionFilter();</div><div> surf.SetInput(polydata);</div><div> vtkContourFilter cf = new vtkContourFilter();</div><div>
cf.SetInputConnection(surf.GetOutputPort());</div><div><br clear="none"></div><div> vtkVertexGlyphFilter glyphFilter = vtkVertexGlyphFilter.New();</div><div> glyphFilter.SetInputConnection(polydata.GetProducerPort());</div>
<div> glyphFilter.Update();</div><div> // Visualize</div><div> vtkPolyDataMapper registracion_mapper = vtkPolyDataMapper.New();</div><div><br clear="none"></div><div> registracion_mapper.SetInputConnection(glyphFilter.GetOutputPort());<br clear="none">
</div><div> vtkActor actorregistracion = vtkActor.New();</div><div> actorregistracion.SetMapper(registracion_mapper);</div><div> actorregistracion.GetProperty().SetPointSize(3);</div><div>
actorregistracion.GetProperty().SetColor(1, 0.5, 0);</div><div> </div><div> double[] a = actorregistracion.GetCenter();</div><div> double[] b = actor_mesh.GetCenter();</div><div>
<br clear="none"></div><div> </div><div> </div><div> //Registration:</div><div> vtkIterativeClosestPointTransform closestpoints = new vtkIterativeClosestPointTransform();</div><div> closestpoints.SetSource(removepoints.GetOutput());</div>
<div> closestpoints.SetTarget(glyphFilter.GetOutput());</div><div> closestpoints.GetLandmarkTransform().SetModeToRigidBody();</div><div> closestpoints.SetMaximumNumberOfIterations(1000);</div>
<div> closestpoints.SetMaximumNumberOfLandmarks(400);</div><div> closestpoints.StartByMatchingCentroidsOff();</div><div> closestpoints.Modified();</div><div> closestpoints.Update();</div>
<div><br clear="none"></div><div> vtkTransformPolyDataFilter transform = new vtkTransformPolyDataFilter();</div><div> transform.SetInput(removepoints.GetOutput());</div><div> transform.SetTransform(closestpoints);</div>
<div> transform.Update();</div><div><br clear="none"></div><div> vtkPolyDataMapper solucion_mapper = vtkPolyDataMapper.New();</div><div> solucion_mapper.SetInputConnection(transform.GetOutputPort());</div>
<div> vtkActor actorsolucion = vtkActor.New();</div><div> actorsolucion.SetMapper(solucion_mapper);</div><div> actorsolucion.GetProperty().SetColor(0, 0, 1);</div><div> actorsolucion.GetProperty().SetPointSize(3);</div>
<div><br clear="none"></div></div></div></div><div><div><br clear="none"><br clear="none"><div>On Mon, Jan 20, 2014 at 3:47 PM, Maarten Beek <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:beekmaarten@yahoo.com" target="_blank">beekmaarten@yahoo.com</a>></span> wrote:<br clear="none">
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif"><div>
<span>Not after the mapper because that doesn't generate a vtkPolyData (inherits from vtkDataSet).</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif">
<span>I would put it at the end of both pipelines (</span><span style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">vtkClosestPointTransform needs two inputs: source and target) before the results of these pipelines are added to their mappers.</span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">Depends on what data you want to register (vtkPolyDataNormals doesn't change the location of the points so you could take the result before this algorithm as well). <br clear="none">
</span></div><div><div><div style="display:block"> <br clear="none"> <br clear="none"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:12pt"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:12pt">
<div dir="ltr"> <font face="Arial"> On Monday, January 20, 2014 10:04:10 AM, Maarten Beek <<a rel="nofollow" shape="rect" href="mailto:beekmaarten@yahoo.com" target="_blank">beekmaarten@yahoo.com</a>> wrote:<br clear="none">
</font> </div> <div><div><div>
<div style="font-size:12pt;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif">Both data have their own coordinate system. One from the apparatus that generated the skin surface, the other one from the NDI tracker. Both data would be in the same coordinate system if some calibration of the equipment is performed.<br clear="none">
<br clear="none">The current data has to be registered to each other (moving one object into the coordinate system of the other). A first step would be to align the centers (see: vtkClosestPointTransform), then some additional iterations would be required to improve the registration.<br clear="none">
<div><span><br clear="none"></span></div><div style="display:block"> <br clear="none"> <br clear="none"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:12pt"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:12pt">
<div><div dir="ltr"> <font face="Arial"> On Saturday, January 18, 2014 7:44:23 PM, Matias Montroull <<a rel="nofollow" shape="rect" href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>> wrote:<br clear="none">
</font> </div>
<div><div><div dir="ltr"><div><div><div>Hi,<br clear="none"><br clear="none"></div>I've managed to add 2 actors to a render, however, I would like to set the same center for both..<br clear="none"><br clear="none">
</div>
Reason being is that I have a skin face surface and a set of points I registered using a NDI tracker. So, I'd like to view both to see how close my points are to the surface to make some tests and then optimization (find the closest points to the surface).<br clear="none">
<br clear="none"></div>My points appear at the right of the image as shown in the screenshoot attached.. Is that because I need to set the center to be the same por something else I'm missing?<br clear="none"><div><div>
<br clear="none"></div><div></div><div>
Thanks!<br clear="none"></div></div></div></div><br clear="none">_______________________________________________<br clear="none">Powered by <a rel="nofollow" shape="rect" href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br clear="none">
<br clear="none">Visit other Kitware open-source projects at <a rel="nofollow" shape="rect" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br clear="none">
<br clear="none">Please keep messages on-topic and check the VTK FAQ at: <a rel="nofollow" shape="rect" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br clear="none"><br clear="none">
Follow this link to subscribe/unsubscribe:<br clear="none"><a rel="nofollow" shape="rect" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br clear="none">
<br clear="none"><br clear="none"></div></div> </div> </div> </div> </div></div></div><br clear="none"><div>_______________________________________________<br clear="none">Powered by <a rel="nofollow" shape="rect" href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br clear="none">
<br clear="none">Visit other Kitware open-source projects at <a rel="nofollow" shape="rect" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br clear="none">
<br clear="none">
Please keep messages on-topic and check the VTK FAQ at: <a rel="nofollow" shape="rect" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br clear="none"><br clear="none">Follow this link to subscribe/unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br clear="none"></div><br clear="none"><br clear="none"></div> </div> </div>
</div> </div></div></div></div></blockquote>
</div><br clear="none"></div></div></div></div><br><br></div> </div> </div> </div> </div></div></div></div></blockquote></div><br></div>