1818
1919#include " itkPCAShapeSignedDistanceFunction.h"
2020
21- #include " vnl/vnl_sample.h"
2221#include " itkImageRegionIterator.h"
2322#include " itkEuler2DTransform.h"
2423
2524#include < gtest/gtest.h>
2625
26+ #include < random> // For mt19937.
27+
2728/* *
2829 * This module tests the functionality of the PCAShapeSignedDistanceFunction
2930 * class.
@@ -65,7 +66,8 @@ TEST(PCAShapeSignedDistanceFunction, Test)
6566
6667
6768 // set up the random number generator
68- vnl_sample_reseed ();
69+ std::mt19937 randomNumberEngine{};
70+ std::normal_distribution<double > randomNumberDistribution (0.0 , 1.0 );
6971
7072 // set up the mean image
7173 auto meanImage = ImageType::New ();
@@ -77,7 +79,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
7779
7880 for (meanImageIt.GoToBegin (); !meanImageIt.IsAtEnd (); ++meanImageIt)
7981 {
80- ImageType::PixelType randomPixel = vnl_sample_normal ( 0 , 1 );
82+ ImageType::PixelType randomPixel = randomNumberDistribution (randomNumberEngine );
8183 meanImageIt.Set (randomPixel);
8284 }
8385
@@ -99,7 +101,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
99101
100102 for (pcImageIts[i].GoToBegin (); !pcImageIts[i].IsAtEnd (); ++pcImageIts[i])
101103 {
102- ImageType::PixelType randomPixel = vnl_sample_normal ( 0 , 1 );
104+ ImageType::PixelType randomPixel = randomNumberDistribution (randomNumberEngine );
103105 pcImageIts[i].Set (randomPixel);
104106 }
105107 }
@@ -112,7 +114,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
112114
113115 for (unsigned int i = 0 ; i < NumberOfPCs; ++i)
114116 {
115- pcStandardDeviations[i] = vnl_sample_normal ( 0 , 1 );
117+ pcStandardDeviations[i] = randomNumberDistribution (randomNumberEngine );
116118 }
117119
118120 shape->SetPrincipalComponentStandardDeviations (pcStandardDeviations);
@@ -126,7 +128,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
126128
127129 for (unsigned int i = 0 ; i < numberOfParameters; ++i)
128130 {
129- parameters[i] = vnl_sample_normal ( 0 , 1 );
131+ parameters[i] = randomNumberDistribution (randomNumberEngine );
130132 }
131133
132134 shape->SetParameters (parameters);
0 commit comments