[vtkusers] avoiding/removing non-manifold parts from the result of vtkMarchingCubes

Bill Lorensen bill.lorensen at gmail.com
Mon Aug 5 07:27:34 EDT 2013


It does not look like 0/255 segmented data. I'll take a look leter today.



On Mon, Aug 5, 2013 at 1:44 AM, Dr. Roman Grothausmann <
grothausmann.roman at mh-hannover.de> wrote:

> On 02/08/13 23:14, Bill Lorensen wrote:
>
>> vtkDiscreteMarchingCubes should be used for segmented data.
>> vtkMarchingCubes for
>> "continuous" data.
>>
>> In your case, a medical dataset, it is unusual to have 8 bit data. Most
>> medical
>> data (e.g. DICOM) is 16 bit.
>>
>
> Well, it is preprocessed med. data. Originally it is 16bit but we have to
> segment it semi-manually with itksnap, so we end up with a binary image
> (either 0 or 255). As we have a certain uncertainty in the borders of the
> segmentation and some segmentation border voxels with e.g. 2 adjacent bg
> voxels, a mean or gauss filter is applied which yields the "continous"
> data. Applying vtkMarchingCubes at level 127 gives a surface much smoother
> than using either itkAntiAliasBinaryImageFilter or vtkWindowedSincFilter
> afterwards.
>
> Still, I wonder what causes the smoothness of vtkMarchingCubes surface. If
> I understand it correctly, vtkDiscreteMarchingCubes (despite its 256
> mc-cases) only creates triangles whose normals can point in only 26
> discrete orientations. vtkMarchingCubes on a binary image (containing only
> values of 0 or 255) seems to generate the same surface using a level of
> 127. Now if I have "continuous" data, vtkMarchingCubes seems to generate
> triangles oriented in far more than 26 discrete directions. Are the
> triangle orientations of the 256 mc-cases adjusted to point in the
> direction of the image-gradient in a second step of vtkMarchingCubes? Are
> the cube-contour intersection positions of the 256 mc-cases adjusted as
> well, i.e. not restricted any more to intersect the cube edges in the
> middle of the edge?
>
>
>
>>
>> On Fri, Aug 2, 2013 at 4:59 PM, Dr. Roman Grothausmann
>> <grothausmann.roman at mh-**hannover.de <grothausmann.roman at mh-hannover.de><mailto:
>> grothausmann.roman at mh-**hannover.de <grothausmann.roman at mh-hannover.de>>>
>>
>> wrote:
>>
>>     On 02/08/13 22:50, Bill Lorensen wrote:
>>
>>
>>         Since your data is unsigned char, and you used an isovalue of
>> 127, I suspect
>>         there must be some degenerate triangles produced. I did produce
>> two
>>         nonmanifold
>>         edges with isovalue 127 (I'm surprised).
>>
>>         Try specifying a non-integral value (e.g. 127.001). I do not see
>>         non-manifold
>>         edges with that value.
>>
>>
>>
>>     I will. Many thanks for the solution.
>>     What should I read to understand that a non-integral value
>> circumvents the
>>     problem (and that an integral value causes it)?
>>     Also I've searched long for an explanation what causes the difference
>>     concerning surface smoothness using vtkMarchingCubes on a binary
>> image or
>>     one that has a gradient (understanding that that allows to calculate
>> normals
>>     pointing in more than 26 directions) simply created with a mean-filer
>> on the
>>     binary image. Is there a kind of additional internal filter that only
>> is
>>     applied if the input has gradients?
>>
>>     Many thanks Bill for looking into this.
>>     Roman
>>
>>         On Fri, Aug 2, 2013 at 4:30 PM, Bill Lorensen <
>> bill.lorensen at gmail.com
>>         <mailto:bill.lorensen at gmail.**com <bill.lorensen at gmail.com>>
>>         <mailto:bill.lorensen at gmail.__**com <mailto:bill.lorensen at gmail.*
>> *com <bill.lorensen at gmail.com>>>> wrote:
>>
>>              Great. I generated a surface. It will take be a few minutes
>> to generate
>>              feature edges.
>>
>>
>>
>>              On Fri, Aug 2, 2013 at 4:25 PM, Dr. Roman Grothausmann
>>         <grothausmann.roman at mh-__**hannover.de<grothausmann.roman at mh-__hannover.de>
>>         <mailto:grothausmann.roman at mh-**hannover.de<grothausmann.roman at mh-hannover.de>
>> >
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>>         <mailto:grothausmann.roman at mh-**hannover.de<grothausmann.roman at mh-hannover.de>>>>
>> wrote:
>>
>>                  On 02/08/13 22:20, Bill Lorensen wrote:
>>
>>                      what level do you use?
>>
>>
>>                  Sorry, forgot to mention that: level 127
>>
>>
>>
>>
>>                      On Fri, Aug 2, 2013 at 4:07 PM, Dr. Roman
>> Grothausmann
>>         <grothausmann.roman at mh-____**hannover.de<grothausmann.roman at mh-____hannover.de>
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>> >
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>>         <mailto:grothausmann.roman at mh-**hannover.de<grothausmann.roman at mh-hannover.de>
>> >>
>>         <mailto:grothausmann.roman at mh-**____hannover.de<grothausmann.roman at mh-____hannover.de>
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>> >
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>>         <mailto:grothausmann.roman at mh-**hannover.de<grothausmann.roman at mh-hannover.de>
>> >>>>
>>
>>                      wrote:
>>
>>                           On 02/08/13 16:06, Bill Lorensen wrote:
>>
>>                               Marching Cubes should not generate
>> non-manifold
>>         surfaces.
>>                      The offending
>>                               triangle
>>                               looks suspicious. What does the rest of your
>>         pipeline look
>>                      like?
>>
>>
>>                           Thanks Bill for looking into this. I get the
>> very same
>>         output
>>                      using paraview
>>                           and its contour filter when ticking "Generate
>>         Triangles" or using
>>                           vmtkmarchingcubes (which seems to use only
>>         vtkMarchingCubes in
>>                           vmtkmarchingcubes.py). To check it trice I used
>> the simple
>>                      program below and
>>                           got the same output again. Only paraview and its
>>         contour filter
>>                      without
>>                           ticking "Generate Triangles" yields a different
>> result.
>>
>>                           _____________________________
>>
>>                           #include <vtkSmartPointer.h>
>>                           #include <vtkMetaImageReader.h>
>>                           //#include <vtkImageConstantPad.h>
>>                           #include <vtkMarchingCubes.h>
>>                           #include <vtkXMLPolyDataWriter.h>//for vtp-files
>>
>>                           #include <vtkCallbackCommand.h>
>>                           #include <vtkCommand.h>
>>
>>
>>                           void ProgressFunction ( vtkObject* caller, long
>>         unsigned int
>>                      eventId, void*
>>                           clientData, void* callData )
>>                                 {
>>
>>                                 vtkAlgorithm *d=
>>         static_cast<vtkAlgorithm*>(___**___caller);
>>
>>
>>
>>                                 fprintf(stderr, "\rFilter progress:
>> %5.1f%%",
>>         100.0 *
>>                      d->GetProgress());
>>                                 std::cerr.flush();
>>
>>                                 }
>>
>>                           int main(int argc, char* argv[]){
>>                                 if( argc != 5 )
>>                                    {
>>                                    std::cerr << "Usage: " << argv[0];
>>                                    std::cerr << " inputImage";
>>                                    std::cerr << " outputMesh";
>>                                    std::cerr << " level normals";
>>                                    std::cerr << std::endl;
>>                                    return EXIT_FAILURE;
>>                                    }
>>
>>                                 if(!(strcasestr(argv[1],".mhd"**______)))
>> {
>>
>>
>>
>>                                    std::cout << "The input should end
>> with .mhd" <<
>>                      std::endl;
>>                                    return -1;
>>                                    }
>>
>>                                 if(!(strcasestr(argv[2],".vtp"**______)))
>> {
>>
>>
>>
>>                                    std::cout << "The input should end
>> with .vtp" <<
>>                      std::endl;
>>                                    return -1;
>>                                    }
>>
>>                                 vtkSmartPointer<______**
>> vtkCallbackCommand>
>>         progressCallback =
>>                           vtkSmartPointer<______**
>> vtkCallbackCommand>::New();
>>
>>           progressCallback->SetCallback(**______ProgressFunction);
>>
>>                                 vtkSmartPointer<______**vtkMetaImageReader>
>> reader =
>>
>>           vtkSmartPointer<______**vtkMetaImageReader>::New();
>>
>>
>>
>>
>>                                 reader->SetFileName(argv[1]);
>>                                 reader->Update();
>>
>>                                 vtkSmartPointer<______**vtkMarchingCubes>
>> mc=
>>                           vtkSmartPointer<______**
>> vtkMarchingCubes>::New();
>>
>>
>>           mc->SetInputConnection(reader-**______>GetOutputPort());
>>
>>
>>
>>                                 mc->SetValue(0, atof(argv[3]));
>>                                 //mc->ComputeNormalsOn();
>>                                 mc->SetComputeNormals(atoi(___**
>> ___argv[4]));
>>
>>
>>
>>                                 //mc->ComputeGradientsOn();
>>                                 //mc->ComputeScalarsOn();
>>                                 std::cout << "Executing discrete marching
>>         cubes..." <<
>>                      std::endl;
>>                                 mc->AddObserver(vtkCommand::__**
>> ____ProgressEvent,
>>
>>
>>                      progressCallback);
>>
>>                                 mc->Update();
>>                                 std::cout << std::endl << "done." <<
>> std::endl;
>>
>>                                 vtkSmartPointer<______**
>> vtkXMLPolyDataWriter>
>>         Pwriter =
>>                           vtkSmartPointer<______**
>> vtkXMLPolyDataWriter>::New();
>>                                 Pwriter->SetFileName(argv[2]);
>>
>>           Pwriter->SetInputConnection(__**____mc->GetOutputPort());
>>
>>
>>
>>
>>                                 Pwriter->Update();
>>
>>                                 return EXIT_SUCCESS;
>>                                 }
>>
>>
>>
>>
>>
>>                               On Fri, Aug 2, 2013 at 8:23 AM, Dr. Roman
>> Grothausmann
>>         <grothausmann.roman at mh-______**hannover.de<grothausmann.roman at mh-______hannover.de>
>>         <mailto:grothausmann.roman at mh-**____hannover.de<grothausmann.roman at mh-____hannover.de>
>> >
>>         <mailto:grothausmann.roman at mh-**____hannover.de<grothausmann.roman at mh-____hannover.de>
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>> >>
>>         <mailto:grothausmann.roman at mh-**____hannover.de<grothausmann.roman at mh-____hannover.de>
>>
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>> >
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>>         <mailto:grothausmann.roman at mh-**hannover.de<grothausmann.roman at mh-hannover.de>
>> >>>
>>         <mailto:grothausmann.roman at mh-**______hannover.de<grothausmann.roman at mh-______hannover.de>
>>         <mailto:grothausmann.roman at mh-**____hannover.de<grothausmann.roman at mh-____hannover.de>
>> >
>>
>>         <mailto:grothausmann.roman at mh-**____hannover.de<grothausmann.roman at mh-____hannover.de>
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>> >>
>>
>>
>>         <mailto:grothausmann.roman at mh-**____hannover.de<grothausmann.roman at mh-____hannover.de>
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>> >
>>         <mailto:grothausmann.roman at mh-**__hannover.de<grothausmann.roman at mh-__hannover.de>
>>         <mailto:grothausmann.roman at mh-**hannover.de<grothausmann.roman at mh-hannover.de>
>> >>>>>
>>
>>                               wrote:
>>
>>                                    Dear mailing list members,
>>
>>
>>                                    Recently, I came across a
>> voxel-dataset that when
>>                      meshed with
>>                                    vtkMarchingCubes results in a mesh
>> that contains
>>                      non-manifold edges
>>                               (magenta
>>                                    line in attached image).
>>                                    How can this be avoided?
>>                                    Using paraview's contour filter and
>> switching off
>>         "Generate Triangles"
>>                                    creates a slightly different surface
>> mesh
>>         that does
>>                      not contain
>>                               non-manifold
>>                                    edges. However vtkMarchingCubes does
>> not seem
>>         to have
>>                      any option
>>                               concerning
>>                                    triangulation.
>>                                    What filter/option do I have to use to
>> get
>>         the same
>>                      result just
>>                               with pure VTK?
>>
>>                                    As a workaround: Is it possible to
>> split the
>>         mesh at
>>                      non-manifold
>>                               edges?
>>                                    vtkIntersectionPolyDataFilter sounds
>>         promising but
>>                      seems to need
>>                               surfaces
>>                                    not just the edges.
>>
>>                                    Any help or hints are very much
>> appreciated
>>                                    Roman
>>
>>
>>
>>                               --
>>                               Unpaid intern in BillsBasement at noware
>> dot com
>>
>>
>>                           --
>>                           Dr. Roman Grothausmann
>>
>>                           Tomographie und Digitale Bildverarbeitung
>>                           Tomography and Digital Image Analysis
>>
>>                           Institut für Funktionelle und Angewandte
>> Anatomie, OE 4120
>>                           Medizinische Hochschule Hannover
>>                           Carl-Neuberg-Str. 1
>>                           D-30625 Hannover
>>
>>                           Tel. +49 511 532-9574<tel:%2B49%20511%20532-9574>
>>         <tel:%2B49%20511%20532-9574>
>>         <tel:%2B49%20511%20532-9574>
>>
>>                           ______________________________**
>> _______________________
>>
>>
>>                           Powered by www.kitware.com <
>> http://www.kitware.com>
>>         <http://www.kitware.com>
>>         <http://www.kitware.com>
>>
>>
>>                           Visit other Kitware open-source projects at
>>         http://www.kitware.com/______**opensource/opensource.html<http://www.kitware.com/______opensource/opensource.html>
>>         <http://www.kitware.com/____**opensource/opensource.html<http://www.kitware.com/____opensource/opensource.html>
>> >
>>
>>         <http://www.kitware.com/____**opensource/opensource.html<http://www.kitware.com/____opensource/opensource.html>
>>         <http://www.kitware.com/__**opensource/opensource.html<http://www.kitware.com/__opensource/opensource.html>
>> >>
>>
>>
>>         <http://www.kitware.com/____**opensource/opensource.html<http://www.kitware.com/____opensource/opensource.html>
>>         <http://www.kitware.com/__**opensource/opensource.html<http://www.kitware.com/__opensource/opensource.html>
>> >
>>         <http://www.kitware.com/__**opensource/opensource.html<http://www.kitware.com/__opensource/opensource.html>
>>         <http://www.kitware.com/**opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>> >>>
>>
>>                           Please keep messages on-topic and check the VTK
>> FAQ at:
>>         http://www.vtk.org/Wiki/VTK___**____FAQ<http://www.vtk.org/Wiki/VTK_______FAQ><
>> http://www.vtk.org/Wiki/VTK__**___FAQ<http://www.vtk.org/Wiki/VTK_____FAQ>
>> >
>>
>>         <http://www.vtk.org/Wiki/VTK__**___FAQ<http://www.vtk.org/Wiki/VTK_____FAQ><
>> http://www.vtk.org/Wiki/VTK__**_FAQ <http://www.vtk.org/Wiki/VTK___FAQ>>>
>>
>>         <http://www.vtk.org/Wiki/VTK__**___FAQ<http://www.vtk.org/Wiki/VTK_____FAQ><
>> http://www.vtk.org/Wiki/VTK__**_FAQ <http://www.vtk.org/Wiki/VTK___FAQ>>
>>         <http://www.vtk.org/Wiki/VTK__**_FAQ<http://www.vtk.org/Wiki/VTK___FAQ><
>> http://www.vtk.org/Wiki/VTK_**FAQ <http://www.vtk.org/Wiki/VTK_FAQ>>>>
>>
>>
>>                           Follow this link to subscribe/unsubscribe:
>>         http://www.vtk.org/mailman/___**___listinfo/vtkusers<http://www.vtk.org/mailman/______listinfo/vtkusers>
>>         <http://www.vtk.org/mailman/__**__listinfo/vtkusers<http://www.vtk.org/mailman/____listinfo/vtkusers>
>> >
>>
>>         <http://www.vtk.org/mailman/__**__listinfo/vtkusers<http://www.vtk.org/mailman/____listinfo/vtkusers>
>>         <http://www.vtk.org/mailman/__**listinfo/vtkusers<http://www.vtk.org/mailman/__listinfo/vtkusers>
>> >>
>>
>>
>>         <http://www.vtk.org/mailman/__**__listinfo/vtkusers<http://www.vtk.org/mailman/____listinfo/vtkusers>
>>         <http://www.vtk.org/mailman/__**listinfo/vtkusers<http://www.vtk.org/mailman/__listinfo/vtkusers>
>> >
>>         <http://www.vtk.org/mailman/__**listinfo/vtkusers<http://www.vtk.org/mailman/__listinfo/vtkusers>
>>         <http://www.vtk.org/mailman/**listinfo/vtkusers<http://www.vtk.org/mailman/listinfo/vtkusers>
>> >>>
>>
>>
>>
>>
>>                      --
>>                      Unpaid intern in BillsBasement at noware dot com
>>
>>
>>                  --
>>                  Dr. Roman Grothausmann
>>
>>                  Tomographie und Digitale Bildverarbeitung
>>                  Tomography and Digital Image Analysis
>>
>>                  Institut für Funktionelle und Angewandte Anatomie, OE
>> 4120
>>                  Medizinische Hochschule Hannover
>>                  Carl-Neuberg-Str. 1
>>                  D-30625 Hannover
>>
>>                  Tel. +49 511 532-9574 <tel:%2B49%20511%20532-9574>
>>         <tel:%2B49%20511%20532-9574>
>>
>>
>>
>>
>>
>>              --
>>              Unpaid intern in BillsBasement at noware dot com
>>
>>
>>
>>
>>         --
>>         Unpaid intern in BillsBasement at noware dot com
>>
>>
>>     --
>>     Dr. Roman Grothausmann
>>
>>     Tomographie und Digitale Bildverarbeitung
>>     Tomography and Digital Image Analysis
>>
>>     Institut für Funktionelle und Angewandte Anatomie, OE 4120
>>     Medizinische Hochschule Hannover
>>     Carl-Neuberg-Str. 1
>>     D-30625 Hannover
>>
>>     Tel. +49 511 532-9574 <tel:%2B49%20511%20532-9574>
>>
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>>
>
> --
> Dr. Roman Grothausmann
>
> Tomographie und Digitale Bildverarbeitung
> Tomography and Digital Image Analysis
>
> Institut für Funktionelle und Angewandte Anatomie, OE 4120
> Medizinische Hochschule Hannover
> Carl-Neuberg-Str. 1
> D-30625 Hannover
>
> Tel. +49 511 532-9574
>



-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130805/191a1d9d/attachment.htm>


More information about the vtkusers mailing list