Skip to content
Snippets Groups Projects
Commit 2f452500 authored by Jonathan Guinet's avatar Jonathan Guinet
Browse files

ENH: rand() have been replaced by MersenneTwister GetUniformVariate() method.

parent 4a1dea17
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
#include "itkMersenneTwisterRandomVariateGenerator.h"
#include "otbVectorImage.h"
#include "otbImage.h"
#include "itkEuclideanDistance.h"
......@@ -39,6 +40,7 @@
#include "otbWrapperTypes.h"
namespace otb
{
......@@ -346,7 +348,7 @@ private:
SampleType sample;
//first sample
itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randGen=itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance();
if (maskFlag)
{
while (!it.IsAtEnd() && !m_MaskIt .IsAtEnd() && (m_MaskIt.Get() <= 0))
......@@ -409,9 +411,7 @@ private:
{
for (unsigned int compIndex = 0; compIndex < sampleSize; ++compIndex)
{
initialMeans[compIndex + classIndex * sampleSize] = min[compIndex] + (max[compIndex] - min[compIndex]) * rand()
/ (RAND_MAX + 1.0);
initialMeans[compIndex + classIndex * sampleSize] = min[compIndex] + (max[compIndex] - min[compIndex]) * randGen->GetUniformVariate(0.0, 1.0);
}
}
otbAppLogINFO(<<totalSamples <<" samples will be used as estimator input."<<std::endl);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment