<div dir="ltr">Hi Darya,<div><br></div><div>If you are using VTK 6 or later, you can do this by creating a new module</div><div>for VTK and then adding the desired classes to that module (and then</div><div>re-building VTK, of course!)  To see how a module is structured, take a</div><div>look at these two very simple files in the Imaging/Math module:</div><div><br></div><div>    Imaging/Math/module.cmake</div><div>    Imaging/Math/CMakeLists.txt</div><div><br></div><div>It's possible to go a step further by putting a VTK module in its own git</div><div>repository.  This is the "Remote Module" mechanism that Bill referred</div><div>to, he documents it here: <a href="http://www.vtk.org/Wiki/VTK/Remote_Modules">http://www.vtk.org/Wiki/VTK/Remote_Modules</a></div><div><br></div><div>If a class is put into a VTK module (remote or otherwise), then that class</div><div>is automatically wrapped for python and can be accessed like any other</div><div>wrapped class:</div><div><br></div><div>    import vtk</div><div>    f = vtk.vtkHausdorffDistancePointSetFilter()</div><div><br></div><div>Note that filters written for VTK 5 usually have to be modified before they</div><div>will work with VTK 6: <a href="http://www.vtk.org/Wiki/VTK/VTK_6_Migration_Guide">http://www.vtk.org/Wiki/VTK/VTK_6_Migration_Guide</a></div><div><br></div><div> - David</div><div><br></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 6, 2015 at 4:10 PM, Darya Yelshyna <span dir="ltr"><<a href="mailto:darya.yelshyna@yahoo.com" target="_blank">darya.yelshyna@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div><div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div><span>Hi David,</span></div><div><span><br clear="none"></span></div><div dir="ltr"><span>Thank you very much for your help, it worked now with </span><span style="font-family:'Helvetica Neue','Segoe UI',Helvetica,Arial,'Lucida Grande',sans-serif">ThresholdByUpper! Now I have only one more question. Is it possible to bind C++ implementation of VTK classes outside the VTK distribution (for example </span><a href="http://www.vtkjournal.org/browse/publication/839" target="_blank">this one</a><span style="font-family:'Helvetica Neue','Segoe UI',Helvetica,Arial,'Lucida Grande',sans-serif">) to a Python script?</span></div><div><br></div><div dir="ltr"><span style="font-family:'Helvetica Neue','Segoe UI',Helvetica,Arial,'Lucida Grande',sans-serif"><br clear="none"></span></div><div dir="ltr"><font face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">Best regads,</font></div><div dir="ltr"><font face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">Darya</font></div><div><br clear="none"></div><div></div></div></div></div><div><div class="h5"><div> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"> <div dir="ltr"> <font size="2" face="Arial"> On Friday, November 6, 2015 10:37 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:<br clear="none"> </font> </div>  <br clear="none"><br clear="none"> <div><div><div><div dir="ltr">Hi Darya,<div><br clear="none"></div><div>The math for the indices should be the other way around.</div><div>If you already have the voxel indices, then compute the point</div><div>coordinates like this:</div><div><br clear="none"></div><div>x = origin[0] + xyz[0]*spacing[0]</div><div>etc. for y and z</div><div>seed.InsertNextPoint(x,y,z)</div><div><br clear="none"></div><div>Also, of course, if ThresholdByUpper(1) doesn't work, then also</div><div>try ThresholdByLower(1).  The names of those two methods always</div><div>confuses me, and I always forget which method does what...</div><div><br clear="none"></div><div> - David</div><div><br clear="none"></div><div><br clear="none"></div><div><br clear="none"></div><div><br clear="none"></div><div><br clear="none"><div><br clear="none"></div><div><br clear="none"></div><div><br clear="none"><div><div>On Fri, Nov 6, 2015 at 12:40 PM, Darya Yelshyna <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:darya.yelshyna@yahoo.com" target="_blank">darya.yelshyna@yahoo.com</a>></span> wrote:<br clear="none"><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div dir="ltr"><span>I guess I figured out what are real coordinates, but I still don't get my connected region. This is my code:</span></div><div dir="ltr"><span><br clear="none"></span></div><div dir="ltr">seed = vtk.vtkPoints()</div><div dir="ltr">i = (xyz[0] - origin[0]) / spacing[0]</div><div dir="ltr">j = (xyz[1] - origin[1]) / spacing[1]</div><div dir="ltr">k = (xyz[2] - origin[2]) / spacing[2]</div><div dir="ltr">seed.InsertNextPoint(i, j, k)</div><div dir="ltr"><br clear="none"></div><div dir="ltr">connectFilter = vtk.vtkImageThresholdConnectivity()</div><div dir="ltr">connectFilter.SetInputConnection(dilateFilter.GetOutputPort())</div><div dir="ltr">connectFilter.SetSeedPoints(seed)</div><div dir="ltr">connectFilter.ThresholdByUpper(1)</div><div dir="ltr">connectFilter.ReplaceInOn()</div><div dir="ltr">connectFilter.SetInValue(1)</div><div dir="ltr">connectFilter.ReplaceOutOn()</div><div dir="ltr">connectFilter.SetOutValue(0)</div><div dir="ltr"></div><div dir="ltr">connectFilter.Update()</div><div dir="ltr"><br clear="none"></div><div dir="ltr">My image is a vtkImageData CT head scan with values 0 and 1. The value 1 corresponds to segmented head and some artifacts, which I want to remove (they are disconnected from the head). My xyz point is a voxel that lies within the head region ( I checked, its value is 1 in the dilateFilter output). The output from vtkImageThresholdConnectivity is a image filled with 0. What am I doing wrong?</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Thank you all in advance.</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Best regards,</div><div dir="ltr">Darya</div><div><div>  <br clear="none"><div><br clear="none"><br clear="none"></div><div style="display:block"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"> <div dir="ltr"> <font size="2" face="Arial"> On Friday, November 6, 2015 7:06 PM, Darya Yelshyna <<a rel="nofollow" shape="rect" href="mailto:darya.yelshyna@yahoo.com" target="_blank">darya.yelshyna@yahoo.com</a>> wrote:<br clear="none"> </font> </div>  <br clear="none"><br clear="none"> <div><div><div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div><span>Thank you so much for your reply!</span></div><div dir="ltr"><span>I am using Python wrapping to access VTK and I don't know how to add vtkImageConnectivityFilter. I am trying to use vtkImageThresholdConnectivity and I am a little confused with setting the seed. </span>The seeds should be in real data coordinates, not in voxel index locations. How do I retrieve these coordinates from X, Y and Z indexes?</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Sorry for inconveniece.</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Best regards,</div><div dir="ltr">Darya</div>  <br clear="none"><div><br clear="none"><br clear="none"></div><div><div style="display:block"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"> <div dir="ltr"> <font size="2" face="Arial"> On Friday, November 6, 2015 5:49 PM, David Gobbi <<a rel="nofollow" shape="rect" href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:<br clear="none"> </font> </div>  <br clear="none"><br clear="none"> <div><div><div><div dir="ltr">Hi Darya,<div><br clear="none"></div><div>The vtkConnectivityFilter is meant for use on mesh data.  It suspect</div><div>that when you used it on image data, it caused your computer to run</div><div>out of memory.</div><div><br clear="none"></div><div>I have a connectivity filter that I wrote specifically for images, but it</div><div>is on github.  I haven't contributed it to VTK yet.  But you can try it</div><div>if you are interested:</div><div><br clear="none"></div><div><a rel="nofollow" shape="rect" href="https://github.com/dgobbi/AIRS/tree/master/ImageSegmentation" target="_blank">https://github.com/dgobbi/AIRS/tree/master/ImageSegmentation</a><br clear="none"></div><div><br clear="none"></div><div>You can also try the vtkImageThresholdConnectivity filter that comes</div><div>with VTK:</div><div><a rel="nofollow" shape="rect" href="http://www.vtk.org/doc/nightly/html/classvtkImageThresholdConnectivity.html" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkImageThresholdConnectivity.html</a><br clear="none"></div><div><br clear="none"></div><div> - David</div><div><br clear="none"></div><div><br clear="none"></div></div><div><br clear="none"><div>On Fri, Nov 6, 2015 at 10:36 AM, Darya Yelshyna via vtkusers <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>></span> wrote:<br clear="none"><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div>Hi everyone!</div><div><br clear="none"></div><div dir="ltr">I was trying to apply vtkConnectivityFilter to vtkImageData, but the program crashes at this step.</div><div dir="ltr">"This application has requested the Runtime to terminate it in an unusual way." This is this a part of my code:</div><div dir="ltr"><br clear="none"></div><div dir="ltr">dilateFilter = vtk.vtkImageContinuousDilate3D()</div><div dir="ltr">dilateFilter.SetKernelSize(5, 5, 5)</div><div dir="ltr">dilateFilter.SetInputConnection(logic2.GetOutputPort())</div><div dir="ltr">dilateFilter.Update()</div><div dir="ltr"><br clear="none"></div><div dir="ltr">connectFilter = vtk.vtkConnectivityFilter()</div><div dir="ltr">connectFilter.SetExtractionModeToLargestRegion()</div><div dir="ltr">connectFilter.SetInputConnection(dilateFilter.GetOutputPort())</div><div dir="ltr">connectFilter.Update()</div><div dir="ltr"><br clear="none"></div><div dir="ltr">I don't understand what is happening.. Can anybody help me?</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Thank you in advance.</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Best regards,</div><div dir="ltr">Darya</div></div></div></div></blockquote></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote></div><br clear="none"></div></div></div></div></div></div><br clear="none"><br clear="none"></div>  </div> </div>  </div></div></div></div></div></blockquote></div><br></div></div></div>