[Insight-users] calculate normal

Alexandre GOUAILLARD hanfei at caltech.edu
Fri Feb 22 11:30:33 EST 2008


You might want to use metro, or mesh:
http://vcg.isti.cnr.it/activities/surfacegrevis/simplification/metro.html
http://mesh.berlios.de/

I personally prefer the later.

I wrote a VTK wrapper for it long time ago, but it's the property of my old
lab now. If you really need it to be intergrated in your pipeline (as
opposed to use it as a stand alone application) you can contact the two
following individual to see if they can release the code.
chris at creatis.insa-lyon.fr
Remy.prost at creatis.insa-lyon.fr


BTW if they do, le me know ;-)

Good luck.

Alex.



On 2/22/08 3:30 AM, "rashedk" <rashed.vtk at googlemail.com> wrote:

> 
> Hi, 
> 
> Thanks for your answers. Perhaps, it would be better if I described what I
> am trying to achieve here. I have included a diagram here for illustraitve
> purposes:
> 
> http://www.doc.ic.ac.uk/~rkarim/surfaces.jpg
> 
> I want to fire probes from surface 1 and find out at what distance they hit
> surface 2. I have drawn out one such probe, note that these probes are
> normal to surface 1. Would using the computeNormal function of SimplexMesh
> be appropriate within this context? I have managed to convert surface1 to a
> simplex mesh in order to compute the normals. Any other ITK/VTK class which
> would be useful? 
> 
> Best, 
> Rashed 
> 
> 
> 
> 
> Alex. GOUAILLARD-2 wrote:
>> 
>> Hi rashed,
>> 
>> 
>> Usually the answer is application dependent. If there is a point you're
>> especially interested in, it's **your** job to find it first and then to
>> call ComputeNormal.
>> 
>> If you don't know which point you're dealing with, it usually means you
>> want
>> to process all the points. You can just loop over all the points and call
>> ComputeNormal for all of them.
>> 
>> You might want to see the API of itkPointSet from which SimplexMesh
>> inherits. Once again, the software manual is your friend:
>> Chapter 4.2 "PointSet"
>> SubChapter 4.2.2 "Getting access to Points" is worth reading.
>> 
>> Especially, depending on the traits (to come back to your previous
>> question), the container of the pointSet can be a map, which means that
>> the
>> Ids of the points can be not consecutive (i.e. There can be a point whose
>> ID
>> is 1, then a point whose ID is 3 even though there would be no point whose
>> ID is 2). You might want to use an iterator on the container to avoid
>> non-consecutive IDs problem.
>> 
>> That also answers your old question:
>>>>>>> Is there also a way to iterate through every point
>>>>>>> on
>>>>>>> the mesh?  
>> 
>> My 2 cents comments, you're welcome to skip or ignore.
>> 
>> ItkSimplexMesh is not really made to be used on its own. You 'd better see
>> it as a component of a deformable framework and as such, its methods are
>> tailored to fit the segmentation goal. It means that some of the method
>> are
>> not designed to be used outside a very specific context. There is a
>> handfull
>> of classes related to that specific deformable framework; you can see some
>> of them here:
>> http://www.itk.org/Doxygen/html/group__MeshSegmentation.html
>> 
>> The best entrance point to use them, as leila mentioned, is in the related
>> InsightApplication directory (it's a separate tarball, from a separate cvs
>> repository than ITK. It requires ITK):
>> Your_Path_To_InsightApplication\DeformableSimplexMesh\
>> It will provide vtk-ITK glue for vizualization and a GUI. As it implements
>> all the framework, you might to start your experimentation from there.
>> 
>> Note that vtk provides normal and curvature filters for example:
>> VtkPolyDataNormals, vtkCurvatures
>> 
>> 
>> At that point, I would recommend you take time to read the software Guide
>> enterely at least once. It might save you a lot of time.
>> 
>> Cheers,
>> 
>> Alex.
>> 
>> On 2/21/08 11:50 AM, "rashedk" <rashed.vtk at googlemail.com> wrote:
>> 
>>> 
>>> Hi, 
>>> 
>>> In the documentation of ComputeNormal of SimplexMesh it says:
>>> 
>>> CovariantVectorType itk::SimplexMesh< TPixelType, VDimension, TMeshTraits
>>>> ::ComputeNormal   (   unsigned long     idx    )     const
>>> 
>>> compute the normal vector in the specified mesh point
>>> 
>>> I need to pass in the index of the mesh point as a parameter. Which
>>> function
>>> returns the index of a mesh point on a simplex mesh??
>>> 
>>> Thanks, 
>>> Rashed
>>> 
>>> 
>>> 
>>> Alex. GOUAILLARD-2 wrote:
>>>> 
>>>> Hi rashed,
>>>> 
>>>> The meshtraits is a list of type definition to finely tune your
>>>> structure
>>>> depending on your usage. You can read more in the itk software guide:
>>>> Chapter 4.3.4 "Customizing the Mesh", page 70.
>>>> 
>>>> A meshtrait is provided by default, so you can basically ignore that for
>>>> your first experiments and use the itk:SimplexMesh as if it was
>>>> templated
>>>> only over the PixelType and the Dimension. (Note, the Dimension also has
>>>> a
>>>> default value, so theoretically, you only need to define a PixelType)
>>>> 
>>>> 
>>>> //----------------- original code
>>>> 
>>>> // NOTE see the default values for Vdimension and TMeshTraits
>>>> template < typename TPixelType,
>>>>            unsigned int VDimension = 3,
>>>>            typename TMeshTraits = DefaultStaticMeshTraits< TPixelType,
>>>>                                                            VDimension,
>>>>                                                            VDimension,
>>>>                                                            TPixelType,
>>>>                                                            TPixelType,
>>>>                                                            TPixelType >
>>>>> 
>>>> class SimplexMesh : public Mesh<TPixelType, VDimension, TMeshTraits>
>>>> 
>>>> 
>>>> //-----------------
>>>> 
>>>> 
>>>> Possible usages:
>>>> 
>>>> // simplest
>>>> Typedef itk::SimplexMesh< float >      MyFirstSimplexMeshType;
>>>> 
>>>> // same thing with second template parameter explicitly set
>>>> Typedef itk::SimplexMesh< float, 3 >   MySecondSimplexMeshType;
>>>> 
>>>> // full options - stay away from that unless you **really** know what
>>>> you
>>>> do
>>>> Typedef float PointAndCellDataType;
>>>> typedef float                Coord;
>>>> const unsigned int  SDimension = 3; // space dimension
>>>> Const unsigned int  TDimension = 2; // max topological dim. Surface => 2
>>>> 
>>>> typedef itk:: DefaultStaticMeshTraits<
>>>>       PointAndCellDataType,
>>>>       SDimension,
>>>>       TDimension,
>>>>       Coord,
>>>>       Coord,
>>>>       PointAndCellDataType           >    MeshTraitsType;
>>>>  
>>>> typedef SimplexMesh< PointAndCellDataType, SDimension, MeshTraitsType >
>>>>                                           MeshType;
>>>> 
>>>> 
>>>> On 2/20/08 10:18 AM, "rashedk" <rashed.vtk at googlemail.com> wrote:
>>>> 
>>>>> 
>>>>> Thanks! 
>>>>> 
>>>>> What is TMeshTraits in itk::SimplexMesh< TPixelType, VDimension,
>>>>> TMeshTraits
>>>>>> ??
>>>>> 
>>>>> What should I pass for TMeshTraits?
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> Leila Baghdadi-2 wrote:
>>>>>> 
>>>>>> check InsightApplication/DeformableModel...
>>>>>> 
>>>>>> I think that code needs work but I am sure I have the part where it
>>>>>> converts the mesh to pass to vtk.
>>>>>> 
>>>>>> HTH
>>>>>> 
>>>>>> Leila
>>>>>> 
>>>>>> On Wed, 2008-20-02 at 09:21 -0800, rashedk wrote:
>>>>>>> 
>>>>>>> Thanks, but now I am stuck trying to display a simplex mesh in VTK.
>>>>>>> How
>>>>>>> do I
>>>>>>> visualize this mesh? Is there also a way to iterate through every
>>>>>>> point
>>>>>>> on
>>>>>>> the mesh?  
>>>>>>> 
>>>>>>> Rashed. 
>>>>>>> 
>>>>>>> 
>>>>>>> Leila Baghdadi-2 wrote:
>>>>>>>> 
>>>>>>>> Yep that's right and another note,
>>>>>>>> 
>>>>>>>> you "must" create a triangle mesh in order to create a simplex mesh!
>>>>>>>> 
>>>>>>>> If you are unsure about how it is done, check the paper
>>>>>>>> simplex mesh
>>>>>>>> by herve delingette of INRIA france
>>>>>>>> 
>>>>>>>> good luck
>>>>>>>> 
>>>>>>>> Leila
>>>>>>>> 
>>>>>>>> On Wed, 2008-20-02 at 12:47 +0100, Iván Macía wrote:
>>>>>>>>> Hi Rashed,
>>>>>>>>> 
>>>>>>>>> You can do what you mention with VTK or directly in ITK use
>>>>>>>>> itk::BinaryMask3DMeshSource, which is the equivalent of Marching
>>>>>>>>> Cubes
>>>>>>> in
>>>>>>>>> ITK. As the name implies, you need a binary mask (segmentation) as
>>>>>>> input.
>>>>>>>>> 
>>>>>>>>> HTH
>>>>>>>>> 
>>>>>>>>> Ivan
>>>>>>>>> 
>>>>>>>>> -----Mensaje original-----
>>>>>>>>> De: insight-users-bounces+imacia=vicomtech.org at itk.org
>>>>>>>>> [mailto:insight-users-bounces+imacia=vicomtech.org at itk.org] En
>>>>>>>>> nombre
>>>>>>> de
>>>>>>>>> rashedk
>>>>>>>>> Enviado el: miércoles, 20 de febrero de 2008 12:06
>>>>>>>>> Para: insight-users at itk.org
>>>>>>>>> Asunto: Re: [Insight-users] calculate normal
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Hi, 
>>>>>>>>> 
>>>>>>>>> How do I convert my 3D image data to a simplex mesh in order to
>>>>>>> compute
>>>>>>>>> the
>>>>>>>>> normals? Checking the class documentation for itk::SimplexMesh
>>>>>>>>> reveals
>>>>>>>>> that
>>>>>>>>> one has to generate a triangle mesh and then use the
>>>>>>>>> itkTriangleMeshToSimplexMeshFilter. But then how do I convert my 3D
>>>>>>> image
>>>>>>>>> data to a triangle mesh?? Do I use vtkContour to produce polyData
>>>>>>>>> and
>>>>>>>>> then
>>>>>>>>> convert it to itkMesh using appropriate filters?
>>>>>>>>> 
>>>>>>>>> Any help will be appreciated,
>>>>>>>>> 
>>>>>>>>> Thanks
>>>>>>>>> Rashed 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Luis Ibanez wrote:
>>>>>>>>>> 
>>>>>>>>>> Hi Tony,
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Well.... if you only have a point, then there is no normal to
>>>>>>> compute.
>>>>>>>>>> 
>>>>>>>>>> You probably are thinking of a point from a surface, where a point
>>>>>>>>>> belongs to several faces and have other points as neighbors.
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> In that case you may want to look at the itk::SimplexMesh
>>>>>>>>>> http://www.itk.org/Insight/Doxygen/html/classitk_1_1SimplexMesh.html
>>>>>>>>>> 
>>>>>>>>>> and its "ComputeNormal" method:
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>> http://www.itk.org/Insight/Doxygen/html/classitk_1_1SimplexMesh.html#itk
>>>>>>> _1
>>>>>>> _1
>>>>>>>>> SimplexMesha5
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>     Regards,
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>        Luis
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> -------------------
>>>>>>>>>> tony hakki wrote:
>>>>>>>>>>> Is it possible to calculate normal of a point in ITK? If yes,
>>>>>>>>>>> Could
>>>>>>>>> you 
>>>>>>>>>>> tell which class should be used?
>>>>>>>>>>> thank you
>>>>>>>>>>>  
>>>>>>>>>>> 
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Insight-users mailing list
>>>>>>>>>> Insight-users at itk.org
>>>>>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> _______________________________________________
>>>>>>>> Insight-users mailing list
>>>>>>>> Insight-users at itk.org
>>>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> _______________________________________________
>>>>>> Insight-users mailing list
>>>>>> Insight-users at itk.org
>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>>>> _______________________________________________
>>>> Insight-users mailing list
>>>> Insight-users at itk.org
>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>> 
>>>> 
>> 
>> 
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>> 
>> 




More information about the Insight-users mailing list