[Insight-users] pointsets

Luis Ibanez luis.ibanez at kitware.com
Sun, 21 Mar 2004 18:24:29 -0500


Hi David,

Since the example was added yesterday,
of course, you will not find it in the
ITK 1.6 release (that dates from February.

You could download it from the CVS-Web portal,
http://www.itk.org/cgi-bin/cvsweb.cgi/Insight/Examples/DataRepresentation/Mesh/?cvsroot=Insight

or simply use the code that was already
attached to the email you got. It is
exactly the same code.


Regards,


    Luis


--------------------------
David Macias Verde wrote:

> Thank you very much, but I cannot find that example. I'm using 
> ITK-1.6.0.  Here you have the contents of /my 
> Insight/Examples/DataRepresentation/Mesh./
> 
> /usr/local/InsightToolkit-1.6.0/Examples/DataRepresentation/Mesh:
>   used 4688 available 924324
>   drwxr-xr-x    2 1000     1000         4096 Feb  9 16:23 .
>   drwxr-xr-x    4 1000     1000         4096 Feb  9 16:23 ..
>   -rw-r--r--    1 1000     1000         8850 Dec 17 12:54 AutomaticMesh.cxx
>   -rw-r--r--    1 root     root       561352 Feb  4 17:39 AutomaticMesh.o
>   -rw-r--r--    1 root     root        31167 Feb  9 16:23 
> cmake.check_depends
>   -rw-r--r--    1 root     root        92064 Feb  9 16:23 cmake.depends
>   -rw-r--r--    1 1000     1000         1459 Dec 17 12:54 CMakeLists.txt
>   -rw-r--r--    1 root     root          482 Feb  9 16:23 DartTestfile.txt
>   -rw-r--r--    1 root     root        39137 Feb  9 16:23 Makefile
>   -rw-r--r--    1 1000     1000         7940 Dec 17 12:54 Mesh1.cxx
>   -rw-r--r--    1 root     root       222820 Feb  4 17:39 Mesh1.o
>   -rw-r--r--    1 1000     1000        11945 Dec 17 12:54 Mesh2.cxx
>   -rw-r--r--    1 root     root       324100 Feb  4 17:39 Mesh2.o
>   -rw-r--r--    1 1000     1000         8025 Dec 17 12:54 Mesh3.cxx
>   -rw-r--r--    1 root     root       347312 Feb  4 17:39 Mesh3.o
>   -rw-r--r--    1 1000     1000         9915 Dec 17 12:54 
> MeshCellsIteration.cxx
>   -rw-r--r--    1 root     root       376856 Feb  4 17:39 
> MeshCellsIteration.o
>   -rw-r--r--    1 1000     1000        15275 Dec 17 12:54 
> MeshCellVisitor2.cxx
>   -rw-r--r--    1 root     root       466308 Feb  4 17:39 MeshCellVisitor2.o
>   -rw-r--r--    1 1000     1000        10488 Dec 17 12:54 
> MeshCellVisitor.cxx
>   -rw-r--r--    1 root     root       417296 Feb  4 17:39 MeshCellVisitor.o
>   -rw-r--r--    1 1000     1000        23026 Dec 17 12:54 MeshKComplex.cxx
>   -rw-r--r--    1 root     root       441552 Feb  4 17:39 MeshKComplex.o
>   -rw-r--r--    1 1000     1000        11393 Dec 17 12:54 MeshTraits.cxx
>   -rw-r--r--    1 root     root       376448 Feb  4 17:39 MeshTraits.o
>   -rw-r--r--    1 1000     1000         8200 Dec 17 12:54 PointSet1.cxx
>   -rw-r--r--    1 root     root       109572 Feb  4 17:39 PointSet1.o
>   -rw-r--r--    1 1000     1000         8458 Dec 17 12:54 PointSet2.cxx
>   -rw-r--r--    1 root     root       111908 Feb  4 17:39 PointSet2.o
>   -rw-r--r--    1 1000     1000         9438 Dec 17 12:54 PointSet3.cxx
>   -rw-r--r--    1 root     root       107868 Feb  4 17:40 PointSet3.o
>   -rw-r--r--    1 1000     1000         7111 Dec 17 12:54 
> PointSetWithCovariantVectors.cxx
>   -rw-r--r--    1 root     root       159800 Feb  4 17:40 
> PointSetWithCovariantVectors.o
>   -rw-r--r--    1 1000     1000         6838 Dec 17 12:54 
> PointSetWithVectors.cxx
>   -rw-r--r--    1 root     root       156932 Feb  4 17:40 
> PointSetWithVectors.o
>   -rw-r--r--    1 1000     1000         5079 Dec 17 12:54 RGBPointSet.cxx
>   -rw-r--r--    1 root     root       159376 Feb  4 17:40 RGBPointSet.o
> 
> Regards,
> 
> David Macias
> 
> On Sat, 2004-03-20 at 19:01, Luis Ibanez wrote:
> 
>>/Hi David,
>>
>>An example on how to convert an itk::Image to
>>an itk::PointSet was added to
>>
>>   Insight/Examples/DataRepresentation/Mesh
>>
>>with the name:
>>
>>        ImageToPointSet.cxx
>>
>>
>>Note that converting an Image to a PoinSet
>>is an extremly inefficient way of using the
>>memory.  You probably want to select only a
>>subset of image pixels to be included in the
>>PointSet.
>>
>>
>>Regards,
>>
>>
>>     Luis
>>
>>
>>Please find the code below:
>>
>>
>>---------------------------
>>David Macias Verde wrote:
>>
>>> Hi:
>>> 
>>> How can I produce a pointset from an image?
>>> 
>>> Thanks in advance,
>>> 
>>------------------------------------------
>>
>>
>>#include "itkImageFileReader.h"
>>#include "itkImageFileWriter.h"
>>
>>
>>#include "itkImage.h"
>>#include "itkPointSet.h"
>>#include "itkImageRegionConstIterator.h"
>>
>>
>>int main( int argc, char ** argv )
>>{
>>   // Verify the number of parameters in the command line
>>   if( argc < 2 )
>>     {
>>     std::cerr << "Usage: " << std::endl;
>>     std::cerr << argv[0] << " inputImageFile  " << std::endl;
>>     return -1;
>>     }
>>
>>
>>   typedef unsigned char      PixelType;
>>   const   unsigned int       Dimension = 2;
>>
>>   typedef itk::Image< PixelType, Dimension >    ImageType;
>>
>>   typedef itk::PointSet< PixelType, Dimension > PointSetType;
>>
>>
>>
>>   typedef itk::ImageFileReader< ImageType >  ReaderType;
>>
>>   ReaderType::Pointer reader = ReaderType::New();
>>
>>   const char * inputFilename  = argv[1];
>>   reader->SetFileName( inputFilename  );
>>
>>   try
>>     {
>>     reader->Update();
>>     }
>>   catch( itk::ExceptionObject & err )
>>     {
>>     std::cout << "ExceptionObject caught !" << std::endl;
>>     std::cout << err << std::endl;
>>     return -1;
>>     }
>>
>>   PointSetType::Pointer  pointSet = PointSetType::New();
>>
>>
>>   typedef itk::ImageRegionConstIterator< ImageType > IteratorType;
>>
>>   const ImageType * image = reader->GetOutput();
>>
>>   IteratorType it( image, image->GetBufferedRegion() );
>>
>>   it.GoToBegin();
>>
>>
>>   typedef PointSetType::PointType     PointType;
>>   PointType point;
>>
>>   unsigned long pointId = 0;
>>
>>   while( !it.IsAtEnd() )
>>     {
>>
>>     // Convert the pixel position into a Point
>>     image->TransformIndexToPhysicalPoint( it.GetIndex() , point );
>>     pointSet->SetPoint( pointId, point );
>>
>>     // Transfer the pixel data to the value associated with the point.
>>     pointSet->SetPointData( pointId, it.Get() );
>>
>>     ++it;
>>     ++pointId;
>>     }
>>
>>   std::cout << "Number Of Points = ";
>>   std::cout << pointSet->GetNumberOfPoints() << std::endl;
>>
>>   return 0;
>>}
>>
>>
>>/
>>
> -- 
> David Macias Verde <_david.maciasverde at gobiernodecanarias.org_ 
> <mailto:david.maciasverde at gobiernodecanarias.org>>
> Servicio de Física Médica - Hospital de Gran Canaria Dr. Negrín
> 
>