[vtkusers] extracting binary label image from poly data contour
Lars Friedrich Lars
lars-friedrich at gmx.net
Wed Feb 18 11:00:47 EST 2009
thank you, kent!
I will have a look at your project. I already read about brainstracer and maybe it offers the functionality I am looking for.
In the meantime I found out that expanding the white image 3D-slice in negative as well as in positive direction by one slice solves my problem. But this is complicated - I have to extract the middle slice afterwards ... a bit dirty. I am sure the brainstracer-solution works better.
thank you again for your response.
lars
-------- Original-Nachricht --------
> Datum: Wed, 18 Feb 2009 08:53:13 -0600
> Von: kent williams <nkwmailinglists at gmail.com>
> An: VTK users group <vtkusers at vtk.org>
> Betreff: Re: [vtkusers] extracting binary label image from poly data contour
> Lars, I don't know enough about the process you're using, but we do
> essentially the same thing in our program, BRAINSTracer, which is a
> public project on the NITRC website:
>
> http://www.nitrc.org/projects/brainstracer
>
> We don't do anything nearly that involved; instead, I do this:
>
> Create black image
> For each contour
> Find contour bounds
> For each voxel within contour bounds
> If the voxel is inside the contour, set it to white
> End
> End
>
> You can look at my source code, but it is complicated by a bunch of
> other concerns, starting with subsampling the voxel space, and
> coloring the voxel if the majority of its subvoxels are inside the
> polygon.
>
> The only part of the code is testing polygon membership. There's
> probable something to do that in VTK, but I found the function I've
> adapted here by googling before I turned up anything in VTK.
>
> // This is a 2D test -- testPoint points to point
> // data defined as 'double testPoint[2];' -- and though vtkPoints is
> 3D point data,
> // only the first two components of each point are used.
> inline
> bool PointInPoly(int numPts,vtkPoints *pts,double *testPoint)
> {
> int i, j;
> bool c(false);
> for (i = 0, j = numPts-1; i < numPts; j = i++)
> {
> double pI[3];
> pts->GetPoint(i,pI);
> double pJ[3];
> pts->GetPoint(j,pJ);
>
> if ((((pI[1] <= testPoint[1]) && (testPoint[1] < pJ[1])) ||
> ((pJ[1] <= testPoint[1]) && (testPoint[1] < pI[1]))) &&
> (testPoint[0] < (pJ[0] - pI[0]) * (testPoint[1] - pI[1]) /
> (pJ[1] - pI[1]) + pI[0]))
> {
> c = !c;
> }
> }
> return c;
>
> }
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01
More information about the vtkusers
mailing list