<div dir="ltr"><div>Since your volume has discrete labels generated by the confidence connected filter, I suggest you use vtkDiscreteMarchingCubes instead of vtkContourFilter.<br><br></div>Set the isovalue to your segmentation lable (255).<br>
<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jul 20, 2013 at 12:31 PM, Zohreh Tavakoli <span dir="ltr">&lt;<a href="mailto:tavakoli.0991@yahoo.com" target="_blank">tavakoli.0991@yahoo.com</a>&gt;</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:14pt;font-family:times new roman,new york,times,serif"><div>Hi every one</div><div style="font-family:times new roman,new york,times,serif;font-size:14pt">
<div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div><div><div><div style="font-size:14pt;font-family:times new roman,new york,times,serif"><div><br>I want to make 3D mesh of abdomen during insufflation on
 ITK,VTK.  I tried to make a mesh via marching cubes , but i could not 
got the desire one.<br>could you please help me for modification of codes and changing that to be match on my Image???<br>I have attached the codes and image.</div><div style="font-style:normal;font-size:18.66px;background-color:transparent;font-family:times new roman,new york,times,serif">
The image is something like a half of the moon, Imagin Abdomen from side view.<br>Thanks<br>zoya</div><div style="font-style:normal;font-size:18.66px;background-color:transparent;font-family:times new roman,new york,times,serif">
 </div><div style="font-style:normal;font-size:18.66px;background-color:transparent;font-family:times new roman,new york,times,serif"> </div><div style="font-style:normal;font-size:18.66px;background-color:transparent;font-family:times new roman,new york,times,serif">
codes:<br></div><div style="font-style:normal;font-size:18.66px;background-color:transparent;font-family:times new roman,new york,times,serif">#include &quot;itkCommand.h&quot;<br>#include &quot;itkImage.h&quot;<br>#include &quot;itkVTKImageExport.h&quot;<br>
#include &quot;itkVTKImageImport.h&quot;<br>#include &quot;itkConfidenceConnectedImageFilter.h&quot;<br>#include &quot;itkCastImageFilter.h&quot;<br>#include &quot;itkRGBPixel.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br>
#include &quot;itkImageFileWriter.h&quot;<br>#include &quot;itkOrientImageFilter.h&quot;<br><br><var></var>#include &quot;vtkImageImport.h&quot;<br>#include &quot;vtkImageExport.h&quot;<br>#include &quot;vtkRenderer.h&quot;<br>
#include &quot;vtkRenderWindow.h&quot;<br>#include &quot;vtkRenderWindowInteractor.h&quot;<br>#include &quot;vtkActor.h&quot;<br>#include &quot;vtkPolyData.h&quot;<br>#include
 &quot;vtkPolyDataMapper.h&quot;<br>#include &quot;vtkContourFilter.h&quot;<br>#include &quot;vtkImageData.h&quot;<br>#include &quot;vtkDataSet.h&quot;<br>#include &quot;vtkProperty.h&quot;<br>#include &quot;vtkImagePlaneWidget.h&quot;<br>
#include &quot;vtkCellPicker.h&quot;<br>#include &quot;vtkPolyDataWriter.h&quot;<br>#include &lt;iostream&gt;<br><br><br>/**<br> * This function will connect the given itk::VTKImageExport filter to<br> * the given vtkImageImport filter.<br>
 */<br>template &lt;typename ITK_Exporter, typename VTK_Importer&gt;<br>void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)<br>{<br>  importer-&gt;SetUpdateInformationCallback(exporter-&gt;GetUpdateInformationCallback());<br>
  importer-&gt;SetPipelineModifiedCallback(exporter-&gt;GetPipelineModifiedCallback());<br>  importer-&gt;SetWholeExtentCallback(exporter-&gt;GetWholeExtentCallback());<br>  importer-&gt;SetSpacingCallback(exporter-&gt;GetSpacingCallback());<br>
 
 importer-&gt;SetOriginCallback(exporter-&gt;GetOriginCallback());<br>  importer-&gt;SetScalarTypeCallback(exporter-&gt;GetScalarTypeCallback());<br>  importer-&gt;SetNumberOfComponentsCallback(exporter-&gt;GetNumberOfComponentsCallback());<br>
  importer-&gt;SetPropagateUpdateExtentCallback(exporter-&gt;GetPropagateUpdateExtentCallback());<br>  importer-&gt;SetUpdateDataCallback(exporter-&gt;GetUpdateDataCallback());<br>  importer-&gt;SetDataExtentCallback(exporter-&gt;GetDataExtentCallback());<br>
  importer-&gt;SetBufferPointerCallback(exporter-&gt;GetBufferPointerCallback());<br>  importer-&gt;SetCallbackUserData(exporter-&gt;GetCallbackUserData());<br>}<br><br>/**<br> * This function will connect the given vtkImageExport filter to<br>
 * the given itk::VTKImageImport filter.<br> */<br>template &lt;typename VTK_Exporter, typename ITK_Importer&gt;<br>void ConnectPipelines(VTK_Exporter* exporter,
 ITK_Importer importer)<br>{<br>  importer-&gt;SetUpdateInformationCallback(exporter-&gt;GetUpdateInformationCallback());<br>  importer-&gt;SetPipelineModifiedCallback(exporter-&gt;GetPipelineModifiedCallback());<br>  importer-&gt;SetWholeExtentCallback(exporter-&gt;GetWholeExtentCallback());<br>
  importer-&gt;SetSpacingCallback(exporter-&gt;GetSpacingCallback());<br>  importer-&gt;SetOriginCallback(exporter-&gt;GetOriginCallback());<br>  importer-&gt;SetScalarTypeCallback(exporter-&gt;GetScalarTypeCallback());<br>
  importer-&gt;SetNumberOfComponentsCallback(exporter-&gt;GetNumberOfComponentsCallback());<br>  importer-&gt;SetPropagateUpdateExtentCallback(exporter-&gt;GetPropagateUpdateExtentCallback());<br>  importer-&gt;SetUpdateDataCallback(exporter-&gt;GetUpdateDataCallback());<br>
  importer-&gt;SetDataExtentCallback(exporter-&gt;GetDataExtentCallback());<br> 
 importer-&gt;SetBufferPointerCallback(exporter-&gt;GetBufferPointerCallback());<br>  importer-&gt;SetCallbackUserData(exporter-&gt;GetCallbackUserData());<br>}<br><br><br>/**<br> * This program implements an example connection between ITK and VTK<br>
 * pipelines.  The combined pipeline flows as follows:<br> *<br> * itkImageFileReader ==&gt; itkVTKImageExport ==&gt;<br> *    vtkImageImport ==&gt; vtkImagePlaneWidget<br> *<br> * The resulting vtkImagePlaneWidget is displayed in a vtkRenderWindow.<br>
 * Whenever the VTK pipeline executes, information is propagated<br> * through the ITK pipeline.  If the ITK pipeline is out of date, it<br> * will re-execute and cause the VTK pipeline to update properly as<br> * well.<br>
 */<br>int main(int argc, char * argv [] )<br>{  <br><br>  // Load a color image using ITK and display it with VTK<br><br>  if( argc
 &lt; 2 )<br>    {<br>    std::cerr &lt;&lt; &quot;Missing parameters&quot; &lt;&lt; std::endl;<br>    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0] &lt;&lt; &quot; inputImageFilename &quot;;<br>    std::cerr &lt;&lt; &quot;[seedX seedY seedZ] [output.vtk] [surface=0 wireframe=1]&quot; &lt;&lt; std::endl;<br>
    return 1;<br>    }<br>  <br>  try<br>    {<br>    typedef unsigned char PixelType;<br>    const unsigned int Dimension = 3;<br>    typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;<br>    <br>    typedef itk::ImageFileReader&lt; ImageType &gt; ReaderType;<br>
<br>    ReaderType::Pointer reader  = ReaderType::New();<br>    reader-&gt;SetFileName( argv[1] );<br>    <br>    reader-&gt;Update();<br><br>   
 typedef itk::ConfidenceConnectedImageFilter&lt;ImageType,ImageType&gt; SegmentationFilterType;<br><br>    SegmentationFilterType::Pointer filter = SegmentationFilterType::New();<br><br>    filter-&gt;SetInput( reader-&gt;GetOutput() );<br>
<br>    filter-&gt;SetNumberOfIterations(200);<br>    filter-&gt;SetReplaceValue(255);<br>    filter-&gt;SetMultiplier(5.5);<br><br><br>    // Obtain center index of the image<br>    // <br>    ImageType::Pointer inputImage = reader-&gt;GetOutput();<br>
    ImageType::SizeType  size  = inputImage-&gt;GetBufferedRegion().GetSize();<br>    ImageType::IndexType start = inputImage-&gt;GetBufferedRegion().GetIndex();<br><br><br>    // set a seed by default in the center of the image.<br>
    ImageType::IndexType seed;<br>   
 seed[0] = start[0 + size[0] / 2;<br>    seed[1] = start[1] + size[1] / 2;<br>    seed[2] = start[2] + size[2] / 2;<br><br>    if( argc &gt;  4 )<br>      {<br>      seed[0] = atoi( argv[1] );<br>      seed[1] = atoi( argv[3] );<br>
      seed[2] = atoi( argv[4] );<br>      }<br><br>    filter-&gt;SetSeed( seed );<br>      <br>    <br>    typedef itk::VTKImageExport&lt; ImageType &gt; ExportFilterType;<br>    ExportFilterType::Pointer itkExporter1 = ExportFilterType::New();<br>
    ExportFilterType::Pointer itkExporter2 = ExportFilterType::New();<br><br>    itkExporter1-&gt;SetInput( reader-&gt;GetOutput() );<br>    itkExporter2-&gt;SetInput(
 filter-&gt;GetOutput() );<br><br>    // Create the vtkImageImport and connect it to the<br>    // itk::VTKImageExport instance.<br>    vtkImageImport* vtkImporter1 = vtkImageImport::New();  <br>    ConnectPipelines(itkExporter1, vtkImporter1);<br>
    <br>    vtkImageImport* vtkImporter2 = vtkImageImport::New();  <br>    ConnectPipelines(itkExporter2, vtkImporter2);<br>    <br><br>    vtkImporter1-&gt;Update();<br>     <br>    //------------------------------------------------------------------------<br>
    // VTK pipeline.<br>    //------------------------------------------------------------------------<br><br>    // Create a renderer, render window, and render window interactor to<br>    // display the
 results.<br>    vtkRenderer* renderer = vtkRenderer::New();<br>    vtkRenderWindow* renWin = vtkRenderWindow::New();<br>    vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();<br><br>    renWin-&gt;SetSize(700, 700);<br>
    renWin-&gt;AddRenderer(renderer);<br>    iren-&gt;SetRenderWindow(renWin);<br>    <br><br>    // use cell picker for interacting with the image orthogonal views.<br>    //<br>    vtkCellPicker * picker = vtkCellPicker::New();<br>
    picker-&gt;SetTolerance(0.004);<br><br><br>    //assign default props to the ipw&#39;s texture plane actor<br>    vtkProperty * ipwProp = vtkProperty::New();<br>     <br><br>    // Create 3 orthogonal view using the ImagePlaneWidget<br>
   
 //<br>    vtkImagePlaneWidget * xImagePlaneWidget =  vtkImagePlaneWidget::New();<br>    vtkImagePlaneWidget * yImagePlaneWidget =  vtkImagePlaneWidget::New();<br>    vtkImagePlaneWidget * zImagePlaneWidget =  vtkImagePlaneWidget::New();<br>
<br>    // The 3 image plane widgets are used to probe the dataset.<br>    //<br>    xImagePlaneWidget-&gt;DisplayTextOn();<br>    //xImagePlaneWidget-&gt;SetInput(vtkImporter1-&gt;GetOutput());<br>    xImagePlaneWidget-&gt;SetInputConnection(vtkImporter1-&gt;GetOutputPort()) ;<br>
    xImagePlaneWidget-&gt;SetPlaneOrientationToXAxes();<br>    xImagePlaneWidget-&gt;SetSliceIndex(size[0]/2);<br>    xImagePlaneWidget-&gt;SetPicker(picker);<br>    xImagePlaneWidget-&gt;RestrictPlaneToVolumeOn();<br>   
 xImagePlaneWidget-&gt;SetKeyPressActivationValue(&#39;x&#39;);<br>    xImagePlaneWidget-&gt;GetPlaneProperty()-&gt;SetColor(1, 0, 0);<br>    xImagePlaneWidget-&gt;SetTexturePlaneProperty(ipwProp);<br>    xImagePlaneWidget-&gt;SetResliceInterpolateToNearestNeighbour();<br>
<br>    yImagePlaneWidget-&gt;DisplayTextOn();<br>   // yImagePlaneWidget-&gt;SetInput(vtkImporter1-&gt;GetOutput());<br>    yImagePlaneWidget-&gt;SetInputConnection(vtkImporter1-&gt;GetOutputPort());<br>    yImagePlaneWidget-&gt;SetPlaneOrientationToYAxes();<br>
    yImagePlaneWidget-&gt;SetSliceIndex(size[1]/2);<br>    yImagePlaneWidget-&gt;SetPicker(picker);<br>    yImagePlaneWidget-&gt;RestrictPlaneToVolumeOn();<br>    yImagePlaneWidget-&gt;SetKeyPressActivationValue(&#39;y&#39;);<br>
   
 yImagePlaneWidget-&gt;GetPlaneProperty()-&gt;SetColor(1, 1, 0);<br>    yImagePlaneWidget-&gt;SetTexturePlaneProperty(ipwProp);<br>    yImagePlaneWidget-&gt;SetLookupTable(xImagePlaneWidget-&gt;GetLookupTable());<br><br>
    zImagePlaneWidget-&gt;DisplayTextOn();<br>    //zImagePlaneWidget-&gt;SetInput(vtkImporter1-&gt;GetOutput());<br>    zImagePlaneWidget-&gt;SetInputConnection(vtkImporter1-&gt;GetOutputPort());<br>    zImagePlaneWidget-&gt;SetPlaneOrientationToZAxes();<br>
    zImagePlaneWidget-&gt;SetSliceIndex(size[2]/2);<br>    zImagePlaneWidget-&gt;SetPicker(picker);<br>    zImagePlaneWidget-&gt;SetKeyPressActivationValue(&#39;z&#39;);<br>    zImagePlaneWidget-&gt;GetPlaneProperty()-&gt;SetColor(0, 0, 1);<br>
    zImagePlaneWidget-&gt;SetTexturePlaneProperty(ipwProp);<br>   
 zImagePlaneWidget-&gt;SetLookupTable(xImagePlaneWidget-&gt;GetLookupTable());<br><br>    xImagePlaneWidget-&gt;SetInteractor( iren );<br>    xImagePlaneWidget-&gt;On();<br>     <br>    yImagePlaneWidget-&gt;SetInteractor( iren );<br>
    yImagePlaneWidget-&gt;On();<br>     <br>    zImagePlaneWidget-&gt;SetInteractor( iren );<br>    zImagePlaneWidget-&gt;On();<br><br><br>    // Set the background to something grayish<br>    renderer-&gt;SetBackground(0.4392, 0.5020, 0.5647);<br>
<br><br>    // Draw contours around the segmented regions<br>    vtkContourFilter * contour = vtkContourFilter::New();<br>    contour-&gt;SetInputConnection( vtkImporter2-&gt;GetOutputPort() );<br>    contour-&gt;SetValue(0, 128); // edges of a binary image with
 values 0,255<br><br><br>    vtkPolyDataMapper * polyMapper = vtkPolyDataMapper::New();<br>    vtkActor          * polyActor  = vtkActor::New();<br><br>    polyActor-&gt;SetMapper( polyMapper );<br>    polyMapper-&gt;SetInputConnection( contour-&gt;GetOutputPort() );<br>
    polyMapper-&gt;ScalarVisibilityOff();<br><br>    vtkProperty * property = vtkProperty::New();<br>    property-&gt;SetAmbient(0.1);<br>    property-&gt;SetDiffuse(0.1);<br>    property-&gt;SetSpecular(0.5);<br>    property-&gt;SetColor(1.0,0.0,0.0);<br>
    property-&gt;SetLineWidth(2.0);<br>    property-&gt;SetRepresentationToSurface();<br><br>    polyActor-&gt;SetProperty( property );<br>  <br>    renderer-&gt;AddActor(
 polyActor );<br>    <br>    if( argc &gt; 5 )<br>      {<br>      vtkPolyDataWriter * writer = vtkPolyDataWriter::New();<br>      writer-&gt;SetFileName(argv[5]);<br>      writer-&gt;SetInputConnection( contour-&gt;GetOutputPort() );<br>
      writer-&gt;Write();<br>      }<br> <br>    if( argc &gt; 6 )<br>      {<br>      int representation = atoi( argv[6] );<br>      switch(representation)<br>        {<br>        case 0:<br>          property-&gt;SetRepresentationToSurface();<br>
         
 break;<br>        case 1:<br>          property-&gt;SetRepresentationToWireframe();<br>          break;<br>        }<br>      }<br><br>    // Bring up the render window and begin interaction.<br>    renderer-&gt;ResetCamera();<br>
    renWin-&gt;Render();<br>    iren-&gt;Start();<br><br>    // Release all VTK components<br>    polyActor-&gt;Delete();<br>    picker-&gt;Delete();<br>    ipwProp-&gt;Delete();<br>    vtkImporter1-&gt;Delete();<br>    vtkImporter2-&gt;Delete();<br>
    xImagePlaneWidget-&gt;Delete();<br>    yImagePlaneWidget-&gt;Delete();<br>   
 zImagePlaneWidget-&gt;Delete();<br>    contour-&gt;Delete();<br>    property-&gt;Delete();<br>    polyMapper-&gt;Delete();<br>    renWin-&gt;Delete();<br>    renderer-&gt;Delete();<br>    iren-&gt;Delete();<br><br><br>    }<br>
  catch( itk::ExceptionObject &amp; e )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception catched !! &quot; &lt;&lt; e &lt;&lt; std::endl;<br>    }<br><br><br>  <br>  return 0;<br>}</div></div></div></div><br><br></div> </div>
 </div>  </div></div><br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" 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" target="_blank">http://www.kitware.com/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" target="_blank">http://www.kitware.com/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" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>