diff --git a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticNoiseGenerator.cpp b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticNoiseGenerator.cpp index 83d61970b6..8887467513 100644 --- a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticNoiseGenerator.cpp +++ b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticNoiseGenerator.cpp @@ -1,40 +1,40 @@ #include "mitkPhotoacousticNoiseGenerator.h" #include #include #include void mitk::PhotoacousticNoiseGenerator::ApplyNoiseModel(ImageType image, double detectorNoise, double speckleNoise) { - if(detectorNoise < 0 || speckleNoise < 1) + if(detectorNoise < 0 || speckleNoise < 0) { - std::string msg = "detectorNoise must be >= 0 and speckleNoise must be >= 1"; + std::string msg = "detectorNoise must be >= 0 and speckleNoise must be >= 0"; MITK_ERROR << msg; mitkThrow() << msg; } if(detectorNoise == 0 && speckleNoise == 1) { return; } std::mt19937 rng; std::random_device randomDevice; if(randomDevice.entropy()>mitk::eps) { rng.seed(randomDevice()); } else { rng.seed(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); } std::normal_distribution<> detector(detectorNoise/2, detectorNoise); std::normal_distribution<> speckle(1, speckleNoise); //TODO: Determine realistic noise model. for(int x = 0, xLength=image->GetXDim(); x < xLength; x++) for(int y = 0, yLength=image->GetYDim(); y < yLength; y++) for(int z = 0, zLength=image->GetZDim(); z < zLength; z++) { image->SetData((image->GetData(x, y, z)+detector(rng))*speckle(rng), x, y, z); } }