use of org.apache.commons.rng.sampling.distribution.ContinuousSampler in project GDSC-SMLM by aherbert.
the class BlockMeanFilterTest method checkIsCorrect.
private static void checkIsCorrect(RandomSeed seed, BlockMeanDataFilter filter) {
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final ContinuousSampler ed = SamplerUtils.createExponentialSampler(rg, 57);
for (final int width : primes) {
for (final int height : primes) {
final float[] data = createData(rg, width, height);
filter.filter.setWeights(null, 0, 0);
for (final float boxSize : boxSizes) {
for (final boolean internal : checkInternal) {
meanIsCorrect(data, width, height, boxSize, internal, filter);
if (filter.isInterpolated) {
meanIsCorrect(data, width, height, boxSize - 0.3f, internal, filter);
meanIsCorrect(data, width, height, boxSize - 0.6f, internal, filter);
}
}
}
// Uniform weights
final float[] w = new float[width * height];
Arrays.fill(w, 1);
filter.filter.setWeights(w, width, height);
for (final float boxSize : boxSizes) {
for (final boolean internal : checkInternal) {
weightedMeanIsCorrect(data, w, width, height, boxSize, internal, filter);
if (filter.isInterpolated) {
weightedMeanIsCorrect(data, w, width, height, boxSize - 0.3f, internal, filter);
weightedMeanIsCorrect(data, w, width, height, boxSize - 0.6f, internal, filter);
}
}
}
// Weights simulating the variance of sCMOS pixels
for (int i = 0; i < w.length; i++) {
w[i] = (float) (1.0 / Math.max(0.01, ed.sample()));
}
filter.filter.setWeights(w, width, height);
for (final float boxSize : boxSizes) {
for (final boolean internal : checkInternal) {
weightedMeanIsCorrect(data, w, width, height, boxSize, internal, filter);
if (filter.isInterpolated) {
weightedMeanIsCorrect(data, w, width, height, boxSize - 0.3f, internal, filter);
weightedMeanIsCorrect(data, w, width, height, boxSize - 0.6f, internal, filter);
}
}
}
}
}
}
use of org.apache.commons.rng.sampling.distribution.ContinuousSampler in project GDSC-SMLM by aherbert.
the class BlockSumFilterTest method checkIsCorrect.
private static void checkIsCorrect(RandomSeed seed, BlockSumDataFilter filter) {
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final ContinuousSampler ed = SamplerUtils.createExponentialSampler(rg, 57);
for (final int width : primes) {
for (final int height : primes) {
final float[] data = createData(rg, width, height);
filter.filter.setWeights(null, 0, 0);
for (final float boxSize : boxSizes) {
for (final boolean internal : checkInternal) {
sumIsCorrect(data, width, height, boxSize, internal, filter);
if (filter.isInterpolated) {
sumIsCorrect(data, width, height, boxSize - 0.3f, internal, filter);
sumIsCorrect(data, width, height, boxSize - 0.6f, internal, filter);
}
}
}
// Uniform weights
final float[] w = new float[width * height];
Arrays.fill(w, 1);
filter.filter.setWeights(w, width, height);
for (final float boxSize : boxSizes) {
for (final boolean internal : checkInternal) {
weightedSumIsCorrect(data, w, width, height, boxSize, internal, filter);
if (filter.isInterpolated) {
weightedSumIsCorrect(data, w, width, height, boxSize - 0.3f, internal, filter);
weightedSumIsCorrect(data, w, width, height, boxSize - 0.6f, internal, filter);
}
}
}
// Weights simulating the variance of sCMOS pixels
for (int i = 0; i < w.length; i++) {
w[i] = (float) (1.0 / Math.max(0.01, ed.sample()));
}
filter.filter.setWeights(w, width, height);
for (final float boxSize : boxSizes) {
for (final boolean internal : checkInternal) {
weightedSumIsCorrect(data, w, width, height, boxSize, internal, filter);
if (filter.isInterpolated) {
weightedSumIsCorrect(data, w, width, height, boxSize - 0.3f, internal, filter);
weightedSumIsCorrect(data, w, width, height, boxSize - 0.6f, internal, filter);
}
}
}
}
}
}
Aggregations