Search in sources :

Example 11 with ImageExtractor

use of uk.ac.sussex.gdsc.core.utils.ImageExtractor in project GDSC-SMLM by aherbert.

the class PerPixelCameraModelTest method canGetCropData.

private static void canGetCropData(RandomSeed seed, boolean initialise) {
    final PerPixelCameraModelTestData data = (PerPixelCameraModelTestData) dataCache.computeIfAbsent(seed, PerPixelCameraModelTest::createData);
    final PerPixelCameraModel model = createModel(data, initialise);
    final UniformRandomProvider rand = RngUtils.create(seed.getSeed());
    final ImageExtractor ie = ImageExtractor.wrap(data.bias, w, h);
    for (int i = 0; i < 10; i++) {
        final Rectangle bounds = getBounds(rand, ie);
        check(data.bias, bounds, model.getBias(bounds));
        check(data.gain, bounds, model.getGain(bounds));
        check(data.variance, bounds, model.getVariance(bounds));
        check(data.varG2, bounds, model.getNormalisedVariance(bounds));
    }
}
Also used : Rectangle(java.awt.Rectangle) UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) ImageExtractor(uk.ac.sussex.gdsc.core.utils.ImageExtractor)

Example 12 with ImageExtractor

use of uk.ac.sussex.gdsc.core.utils.ImageExtractor in project GDSC-SMLM by aherbert.

the class PerPixelCameraModelTest method canCropAndGetData.

private static void canCropAndGetData(RandomSeed seed, boolean initialise) {
    final PerPixelCameraModelTestData data = (PerPixelCameraModelTestData) dataCache.computeIfAbsent(seed, PerPixelCameraModelTest::createData);
    final PerPixelCameraModel model = createModel(data, initialise);
    final UniformRandomProvider rand = RngUtils.create(seed.getSeed());
    final ImageExtractor ie = ImageExtractor.wrap(data.bias, w, h);
    for (int i = 0; i < 10; i++) {
        final Rectangle bounds = getBounds(rand, ie);
        final CameraModel model2 = model.crop(bounds, false);
        Assertions.assertEquals(model2.getBounds(), bounds);
        check(data.bias, bounds, model2.getBias(bounds));
        check(data.gain, bounds, model2.getGain(bounds));
        check(data.variance, bounds, model2.getVariance(bounds));
        check(data.varG2, bounds, model2.getNormalisedVariance(bounds));
    }
}
Also used : Rectangle(java.awt.Rectangle) UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) ImageExtractor(uk.ac.sussex.gdsc.core.utils.ImageExtractor)

Example 13 with ImageExtractor

use of uk.ac.sussex.gdsc.core.utils.ImageExtractor in project GDSC-SMLM by aherbert.

the class PerPixelCameraModelTest method canConvertDataWithCropBounds.

@SeededTest
void canConvertDataWithCropBounds(RandomSeed seed) {
    final PerPixelCameraModelTestData data = (PerPixelCameraModelTestData) dataCache.computeIfAbsent(seed, PerPixelCameraModelTest::createData);
    final PerPixelCameraModel model = new PerPixelCameraModel(w, h, data.bias, data.gain, data.variance);
    final UniformRandomProvider rand = RngUtils.create(seed.getSeed());
    final ImageExtractor ie = ImageExtractor.wrap(data.bias, w, h);
    for (int j = 0; j < 10; j++) {
        final Rectangle bounds = getBounds(rand, ie);
        checkConversion(data, bounds, model);
    }
}
Also used : Rectangle(java.awt.Rectangle) UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) ImageExtractor(uk.ac.sussex.gdsc.core.utils.ImageExtractor) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Aggregations

Rectangle (java.awt.Rectangle)13 ImageExtractor (uk.ac.sussex.gdsc.core.utils.ImageExtractor)13 UniformRandomProvider (org.apache.commons.rng.UniformRandomProvider)6 Point (java.awt.Point)4 BasePoint (uk.ac.sussex.gdsc.core.match.BasePoint)4 Statistics (uk.ac.sussex.gdsc.core.utils.Statistics)3 SeededTest (uk.ac.sussex.gdsc.test.junit5.SeededTest)3 FloatProcessor (ij.process.FloatProcessor)2 FitConfiguration (uk.ac.sussex.gdsc.smlm.engine.FitConfiguration)2 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)2 PeakResult (uk.ac.sussex.gdsc.smlm.results.PeakResult)2 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)1 ImageStack (ij.ImageStack)1 GenericDialog (ij.gui.GenericDialog)1 Overlay (ij.gui.Overlay)1 Plot (ij.gui.Plot)1 Roi (ij.gui.Roi)1 ShortProcessor (ij.process.ShortProcessor)1 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1