use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.
the class MedianFilterTest method floatBlockMedianNxNInternalAndRollingMedianNxNInternalReturnSameResult.
@SeededTest
public void floatBlockMedianNxNInternalAndRollingMedianNxNInternalReturnSameResult(RandomSeed seed) {
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final MedianFilter filter = new MedianFilter();
for (final int width : primes) {
for (final int height : primes) {
for (final int boxSize : boxSizes) {
floatCompareBlockMedianNxNInternalAndRollingMedianNxNInternal(rg, filter, width, height, boxSize);
}
}
}
}
use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.
the class MedianFilterTest method floatBlockMedian3x3InternalAndRollingMedianNxNInternalReturnSameResult.
@SeededTest
public void floatBlockMedian3x3InternalAndRollingMedianNxNInternalReturnSameResult(RandomSeed seed) {
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final MedianFilter filter = new MedianFilter();
for (final int width : primes) {
for (final int height : primes) {
floatCompareBlockMedian3x3InternalAndRollingMedianNxNInternal(rg, filter, width, height);
}
}
}
use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.
the class WeightedFilterTest method filterDoesNotAlterFilteredImageMean.
@SeededTest
void filterDoesNotAlterFilteredImageMean(RandomSeed seed) {
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
// ExponentialDistribution ed = new ExponentialDistribution(rand, 57,
// ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
final DataFilter filter = createDataFilter();
final float[] offsets = getOffsets(filter);
final int[] boxSizes = getBoxSizes(filter);
final TDoubleArrayList l1 = new TDoubleArrayList();
final SharedStateContinuousSampler gs = SamplerUtils.createGaussianSampler(rg, 2, 0.2);
for (final int width : primes) {
for (final int height : primes) {
final float[] data = createData(width, height, rg);
l1.reset();
filter.setWeights(null, width, height);
for (final int boxSize : boxSizes) {
for (final float offset : offsets) {
for (final boolean internal : checkInternal) {
l1.add(getMean(data, width, height, boxSize - offset, internal, filter));
}
}
}
final double[] e = l1.toArray();
int ei = 0;
// Uniform weights
final float[] w = new float[width * height];
Arrays.fill(w, 0.5f);
filter.setWeights(w, width, height);
for (final int boxSize : boxSizes) {
for (final float offset : offsets) {
for (final boolean internal : checkInternal) {
testMean(data, width, height, boxSize - offset, internal, filter, "w=0.5", e[ei++], 1e-5);
}
}
}
// 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()));
w[i] = (float) (1.0 / Math.max(0.01, gs.sample()));
// w[i] = 0.5f;
}
ei = 0;
filter.setWeights(w, width, height);
for (final int boxSize : boxSizes) {
for (final float offset : offsets) {
for (final boolean internal : checkInternal) {
testMean(data, width, height, boxSize - offset, internal, filter, "w=?", e[ei++], 5e-2);
}
}
}
}
}
}
use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.
the class WeightedFilterTest method evenWeightsDoesNotAlterFiltering.
@SeededTest
void evenWeightsDoesNotAlterFiltering(RandomSeed seed) {
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final DataFilter filter1 = createDataFilter();
final DataFilter filter2 = createDataFilter();
final float[] offsets = getOffsets(filter1);
final int[] boxSizes = getBoxSizes(filter1);
final int[] primes = Arrays.copyOf(WeightedFilterTest.primes, WeightedFilterTest.primes.length - 1);
final FloatFloatBiPredicate equality = TestHelper.floatsAreClose(1e-4, 0);
for (final int width : primes) {
for (final int height : primes) {
final float[] data = createData(width, height, rg);
// Uniform weights
final float[] w = new float[width * height];
Arrays.fill(w, 0.5f);
filter2.setWeights(w, width, height);
for (final int boxSize : boxSizes) {
for (final float offset : offsets) {
for (final boolean internal : checkInternal) {
final float[] e = filter(data, width, height, boxSize - offset, internal, filter1);
final float[] o = filter(data, width, height, boxSize - offset, internal, filter2);
try {
TestAssertions.assertArrayTest(e, o, equality);
} catch (final AssertionError ex) {
final String msg = String.format("%s : [%dx%d] @ %.1f [internal=%b]", filter2.name, width, height, boxSize - offset, internal);
throw new AssertionError(msg, ex);
}
}
}
}
}
}
}
use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.
the class BinomialFitterTest method sameFitZeroTruncatedBinomialWithKnownNUsingLseOrMle.
@SeededTest
void sameFitZeroTruncatedBinomialWithKnownNUsingLseOrMle(RandomSeed seed) {
Assumptions.assumeTrue(TestSettings.allow(nonEssentialTestComplexity));
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final boolean zeroTruncated = true;
for (final int n : N) {
for (final double p : P) {
fitBinomialUsingLseOrMle(rg, n, p, zeroTruncated, n, n);
}
}
}
Aggregations