<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yiv0495932146"><div id="yui_3_16_0_1_1446832752234_15976"><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;" id="yui_3_16_0_1_1446832752234_15975"><div id="yiv0495932146yui_3_16_0_1_1446832752234_13346"><span id="yiv0495932146yui_3_16_0_1_1446832752234_13580">Hi David,</span></div><div id="yiv0495932146yui_3_16_0_1_1446832752234_13347"><span><br clear="none"></span></div><div dir="ltr" id="yiv0495932146yui_3_16_0_1_1446832752234_13353"><span id="yiv0495932146yui_3_16_0_1_1446832752234_13387">Thank you very much for your help, it worked now with </span><span class="yiv0495932146" id="yiv0495932146yui_3_16_0_1_1446832752234_13356" 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 class="edited-link-editor" href="http://www.vtkjournal.org/browse/publication/839" id="yui_3_16_0_1_1446832752234_16289">this one</a><span style="font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;" id="yui_3_16_0_1_1446832752234_16291">) to a Python script?</span></div><div id="yiv0495932146yui_3_16_0_1_1446832752234_13353"><br></div><div dir="ltr" id="yiv0495932146yui_3_16_0_1_1446832752234_13353"><span class="yiv0495932146" style="font-family:'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;"><br clear="none"></span></div><div dir="ltr" id="yiv0495932146yui_3_16_0_1_1446832752234_13353"><font face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif" id="yui_3_16_0_1_1446832752234_16331">Best regads,</font></div><div dir="ltr" id="yiv0495932146yui_3_16_0_1_1446832752234_13353"><font face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">Darya</font></div><div class="yiv0495932146qtdSeparateBR" id="yui_3_16_0_1_1446832752234_16112"><br clear="none"></div><div class="yiv0495932146yqt1804874797" id="yiv0495932146yqt59873"></div></div></div></div><div class=".yiv0495932146yahoo_quoted"> <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 <david.gobbi@gmail.com> wrote:<br clear="none"> </font> </div> <br clear="none"><br clear="none"> <div class="yiv0495932146y_msg_container"><div id="yiv0495932146"><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 class="yiv0495932146gmail_extra"><br clear="none"><div class="yiv0495932146yqt1942561776" id="yiv0495932146yqtfd23074"><div class="yiv0495932146gmail_quote">On Fri, Nov 6, 2015 at 12:40 PM, Darya Yelshyna <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:darya.yelshyna@yahoo.com" target="_blank" href="mailto:darya.yelshyna@yahoo.com">darya.yelshyna@yahoo.com</a>></span> wrote:<br clear="none"><blockquote class="yiv0495932146gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"><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 class="yiv0495932146h5"> <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" ymailto="mailto:darya.yelshyna@yahoo.com" target="_blank" href="mailto:darya.yelshyna@yahoo.com">darya.yelshyna@yahoo.com</a>> wrote:<br clear="none"> </font> </div> <br clear="none"><br clear="none"> <div><div><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"><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" ymailto="mailto:david.gobbi@gmail.com" target="_blank" href="mailto:david.gobbi@gmail.com">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" target="_blank" href="https://github.com/dgobbi/AIRS/tree/master/ImageSegmentation">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" target="_blank" href="http://www.vtk.org/doc/nightly/html/classvtkImageThresholdConnectivity.html">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" ymailto="mailto:vtkusers@vtk.org" target="_blank" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>></span> wrote:<br clear="none"><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;"><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></body></html>