[Insight-users] Problems or bug with itkKdTree search method

Arnaud GELAS gelas at creatis.insa-lyon.fr
Tue May 30 10:26:50 EDT 2006


Skipped content of type multipart/alternative-------------- next part --------------
#include <vnl/vnl_random.h>
#include <itkVector.h>
#include <itkListSample.h>
#include <itkKdTreeGenerator.h>
#include <itkKdTree.h>

int main(int argc,char **argv )
{
   typedef itk::Vector< double, 2 > MeasurementType;
   typedef itk::Statistics::ListSample< MeasurementType > ListOfSamplesType;
   typedef ListOfSamplesType::Pointer ListOfSamplesPointer;

   ListOfSamplesPointer samples = ListOfSamplesType::New( );
   samples->SetMeasurementVectorSize( 2 );
   
   vnl_random random( 1 );

   MeasurementType m;
   unsigned int i = 0;

   for( i = 0; i < 100; i++ )
   {
      m[0] = random.drand32( 100. );   
      m[1] = random.drand32( 100. );
      samples->PushBack( m );
   }

   typedef itk::Statistics::KdTreeGenerator< ListOfSamplesType > KdTreeGeneratorType;
   typedef KdTreeGeneratorType::Pointer KdTreeGeneratorGeneratorPointer;

   KdTreeGeneratorGeneratorPointer kdtreegenerator = KdTreeGeneratorType::New( );
   kdtreegenerator->SetBucketSize( 16 );
   kdtreegenerator->SetSample( samples );
   kdtreegenerator->Update( );

   typedef KdTreeGeneratorType::OutputType KdTreeType;
   typedef KdTreeGeneratorType::OutputPointer KdTreePointer;
   typedef KdTreeType::InstanceIdentifierVectorType InstanceIdentifierVectorType;
   typedef InstanceIdentifierVectorType::const_iterator 
      InstanceIdentifierVectorTypeConstIterator;

   KdTreePointer kdtree = kdtreegenerator->GetOutput( );

   for( i = 0; i < 100; i++ )
   {
      std::cout<<i <<std::endl;
      m = samples->GetMeasurementVector( i );
      InstanceIdentifierVectorType ids;

      kdtree->Search( m, 15., ids );
      std::sort( ids.begin( ), ids.end( ) );

      for( InstanceIdentifierVectorTypeConstIterator it = ids.begin( );
         it != ids.end( );
         it++ )
         {
            std::cout<<*it <<std::ends;
         }

      std::cout<<std::endl;

      for( unsigned j = 0; j < 100; j++ )
      {
         MeasurementType l = samples->GetMeasurementVector( j );
         if( ( m - l ).GetSquaredNorm( ) <= 15. * 15. )
         {
            std::cout<<j <<std::ends;
         }
      }
      std::cout<<std::endl;
      std::cout<<"***" <<std::endl;
   }
   
   return 0;
}
-------------- next part --------------
0
0 2 4 50 93 
0 2 4 50 93 
***
1
1 25 64 78 88 
1 25 64 78 88 
***
2
0 2 35 59 76 93 
0 2 35 59 76 93 
***
3
3 24 26 30 35 39 76 92 
3 24 26 30 35 39 76 92 
***
4
0 4 50 62 
0 4 50 62 
***
5
5 55 75 77 82 86 
5 55 75 77 82 86 
***
6
6 25 40 51 66 87 90 
6 25 40 51 66 87 90 
***
7
7 21 29 46 48 53 
7 21 29 46 48 53 
***
8
8 17 37 89 96 
8 17 37 89 96 
***
9
9 56 63 81 97 
9 56 63 81 97 
***
10
10 11 18 32 59 67 76 
10 11 18 32 59 67 76 
***
11
10 11 18 32 59 67 
10 11 18 32 59 67 
***
12
12 23 65 
12 23 65 
***
13
13 27 
13 27 
***
14
14 54 56 73 79 95 
14 54 56 73 79 95 
***
15
15 16 19 31 36 42 44 72 83 84 
15 16 19 31 36 42 44 72 83 84 
***
16
15 16 19 31 36 42 44 72 83 84 
15 16 19 31 36 42 44 72 83 84 
***
17
8 17 37 89 
8 17 37 89 
***
18
10 11 18 22 24 32 
10 11 18 22 24 32 
***
19
15 16 19 20 31 36 38 42 44 52 72 84 
15 16 19 20 31 36 38 42 44 52 72 84 
***
20
19 20 31 34 36 38 52 58 72 84 
19 20 31 34 36 38 52 58 72 84 
***
21
7 21 29 45 53 
7 21 29 45 53 
***
22
18 22 24 26 92 
18 22 24 26 92 
***
23
12 23 65 91 
12 23 65 91 
***
24
3 18 22 24 26 30 32 76 
3 18 22 24 26 30 32 76 
***
25
1 6 25 40 64 78 87 88 89 
1 6 25 40 64 78 87 88 89 
***
26
3 22 24 26 30 76 92 
3 22 24 26 30 76 92 
***
27
13 27 
13 27 
***
28
28 46 50 69 74 85 93 94 
28 46 50 69 74 85 93 94 99 
***
29
7 21 29 41 46 48 53 
7 21 29 41 46 48 53 
***
30
3 24 26 30 35 39 76 
3 24 26 30 35 39 76 
***
31
15 16 19 20 31 36 38 42 44 72 84 
15 16 19 20 31 36 38 42 44 72 84 
***
32
10 11 18 24 32 67 76 
10 11 18 24 32 67 76 
***
33
33 45 51 57 60 64 68 70 80 81 97 
33 45 51 57 60 64 68 70 80 81 97 
***
34
20 34 49 52 61 
20 34 49 52 61 
***
35
3 30 35 39 
2 3 30 35 39 
***
36
15 16 19 20 31 36 38 42 52 58 72 83 84 
15 16 19 20 31 36 38 42 52 58 72 83 84 
***
37
8 17 37 89 96 
8 17 37 89 96 
***
38
19 20 31 36 38 52 58 72 75 84 
19 20 31 36 38 52 58 72 75 84 
***
39
3 30 35 39 
3 30 35 39 
***
40
6 25 40 87 89 90 
6 25 40 87 89 90 
***
41
29 41 46 48 53 71 98 
29 41 46 48 53 71 98 
***
42
15 16 19 31 36 42 44 83 
15 16 19 31 36 42 44 83 
***
43
43 51 66 90 91 
43 51 66 90 91 
***
44
15 16 19 31 42 44 83 
15 16 19 31 42 44 83 
***
45
21 33 45 60 64 70 81 95 
21 33 45 60 64 70 81 95 
***
46
7 28 29 41 46 48 53 69 74 94 
7 28 29 41 46 48 53 69 74 94 
***
47
47 48 73 
47 48 73 
***
48
7 29 41 46 47 48 53 71 
7 29 41 46 47 48 53 71 
***
49
34 49 52 61 
34 49 52 61 
***
50
0 4 28 50 69 74 
0 4 28 50 69 74 99 
***
51
6 33 43 51 57 66 68 70 80 87 
6 33 43 51 57 66 68 70 80 87 
***
52
19 20 34 36 38 49 52 72 84 
19 20 34 36 38 49 52 72 84 
***
53
7 21 29 41 46 48 53 69 
7 21 29 41 46 48 53 69 
***
54
14 54 56 73 79 95 
14 54 56 73 79 95 
***
55
5 55 58 75 77 82 86 
5 55 58 75 77 82 86 
***
56
9 14 54 56 60 63 79 81 95 97 
9 14 54 56 60 63 79 81 95 97 
***
57
33 51 57 60 63 68 70 80 81 97 
33 51 57 60 63 68 70 80 81 97 
***
58
20 36 38 55 58 72 75 77 82 84 86 98 
20 36 38 55 58 72 75 77 82 84 86 98 
***
59
2 10 11 59 67 85 93 
2 10 11 59 67 85 93 99 
***
60
33 45 56 57 60 63 81 95 97 
33 45 56 57 60 63 81 95 97 
***
61
34 49 61 
34 49 61 
***
62
4 62 
4 62 
***
63
9 56 57 60 63 81 97 
9 56 57 60 63 81 97 
***
64
1 25 33 45 64 70 78 87 88 
1 25 33 45 64 70 78 87 88 
***
65
12 23 65 91 
12 23 65 91 
***
66
6 43 51 66 90 91 
6 43 51 66 90 91 
***
67
10 11 32 59 67 
10 11 32 59 67 96 
***
68
33 51 57 68 70 80 87 
33 51 57 68 70 80 87 
***
69
28 46 50 53 69 74 
28 46 50 53 69 74 
***
70
33 45 51 57 64 68 70 80 87 
33 45 51 57 64 68 70 80 87 
***
71
41 48 71 98 
41 48 71 98 
***
72
15 16 19 20 31 36 38 52 58 72 75 82 84 
15 16 19 20 31 36 38 52 58 72 75 82 84 
***
73
14 47 54 73 
14 47 54 73 
***
74
28 46 50 69 74 
28 46 50 69 74 
***
75
5 38 55 58 72 75 77 82 86 98 
5 38 55 58 72 75 77 82 86 98 
***
76
2 3 10 24 26 30 32 76 
2 3 10 24 26 30 32 76 
***
77
5 55 58 75 77 82 86 
5 55 58 75 77 82 86 
***
78
1 25 64 78 88 94 
1 25 64 78 88 94 
***
79
14 54 56 79 95 
14 54 56 79 95 
***
80
33 51 57 68 70 80 87 
33 51 57 68 70 80 87 
***
81
9 33 45 56 57 60 63 81 95 97 
9 33 45 56 57 60 63 81 95 97 
***
82
5 55 58 72 75 77 82 86 
5 55 58 72 75 77 82 86 98 
***
83
15 16 36 42 44 83 
15 16 36 42 44 83 
***
84
15 16 19 20 31 36 38 52 58 72 84 
15 16 19 20 31 36 38 52 58 72 84 
***
85
28 59 85 93 94 
28 59 85 93 94 99 
***
86
5 55 58 75 77 82 86 
5 55 58 75 77 82 86 
***
87
6 25 40 51 64 68 70 80 87 90 
6 25 40 51 64 68 70 80 87 90 
***
88
1 25 64 78 88 
1 25 64 78 88 
***
89
8 17 25 37 40 89 
8 17 25 37 40 89 
***
90
6 40 43 66 87 90 91 
6 40 43 66 87 90 91 
***
91
23 43 65 66 90 91 
23 43 65 66 90 91 
***
92
3 26 92 
3 22 26 92 
***
93
0 2 28 59 85 93 
0 2 28 59 85 93 99 
***
94
28 46 78 85 94 99 
28 46 78 85 94 99 
***
95
14 45 54 56 60 79 81 95 
14 45 54 56 60 79 81 95 
***
96
8 37 67 96 
8 37 67 96 
***
97
9 33 56 57 60 63 81 97 
9 33 56 57 60 63 81 97 
***
98
41 58 71 75 82 98 
41 58 71 75 82 98 
***
99
28 50 59 85 93 94 
28 50 59 85 93 94 99 
***


More information about the Insight-users mailing list