22 if (detectorNoise < 0 || speckleNoise < 0)
29 std::random_device randomDevice;
32 rng.seed(randomDevice());
36 rng.seed(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
38 std::normal_distribution<> detector(detectorNoise / 2, detectorNoise / 2);
39 std::normal_distribution<> speckle(1, speckleNoise);
41 unsigned int negativecounter = 0;
43 double* data = image->GetData();
45 for (
unsigned int x = 0, xLength = image->GetXDim(); x < xLength; x++)
46 for (
unsigned int y = 0, yLength = image->GetYDim(); y < yLength; y++)
47 for (
unsigned int z = 0, zLength = image->GetZDim(); z < zLength; z++)
49 double additiveNoise = detector(rng);
51 double multiplicativeNoise = speckle(rng);
53 double newSignal = (data[image->GetIndex(x, y, z)] + additiveNoise)*multiplicativeNoise;
61 data[image->GetIndex(x, y, z)] = newSignal;
mitk::Image::Pointer image
static void ApplyNoiseModel(mitk::pa::Volume::Pointer image, double detectorNoise, double speckleNoise)
ApplyNoiseModel Applies noise to an image.
MITKCORE_EXPORT const ScalarType eps