Search in sources :

Example 66 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class ImageJImagePeakResultsTest method canInterpolateDownInYAtPixelEdge.

@Test
void canInterpolateDownInYAtPixelEdge() {
    final ImageJImagePeakResults r = new ImageJImagePeakResults(title, bounds, 1);
    r.setDisplayFlags(ImageJImagePeakResults.DISPLAY_WEIGHTED);
    final FloatProcessor fp = new FloatProcessor(bounds.width, bounds.height);
    begin(r);
    addValue(r, 1.5f, 1f, 2);
    fp.putPixelValue(1, 0, 1);
    fp.putPixelValue(1, 1, 1);
    r.end();
    final float[] expecteds = getImage(fp);
    final float[] actuals = getImage(r);
    Assertions.assertArrayEquals(expecteds, actuals);
}
Also used : FloatProcessor(ij.process.FloatProcessor) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest) Test(org.junit.jupiter.api.Test)

Example 67 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class ImageJImagePeakResultsTest method canInterpolateUpInXAtPixelEdge.

@Test
void canInterpolateUpInXAtPixelEdge() {
    final ImageJImagePeakResults r = new ImageJImagePeakResults(title, bounds, 1);
    r.setDisplayFlags(ImageJImagePeakResults.DISPLAY_WEIGHTED);
    final FloatProcessor fp = new FloatProcessor(bounds.width, bounds.height);
    begin(r);
    addValue(r, 2f, 1.5f, 2);
    fp.putPixelValue(1, 1, 1);
    fp.putPixelValue(2, 1, 1);
    r.end();
    final float[] expecteds = getImage(fp);
    final float[] actuals = getImage(r);
    Assertions.assertArrayEquals(expecteds, actuals);
}
Also used : FloatProcessor(ij.process.FloatProcessor) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest) Test(org.junit.jupiter.api.Test)

Example 68 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class ImageJImagePeakResultsTest method noInterpolateUpInYAtImageEdge.

@Test
void noInterpolateUpInYAtImageEdge() {
    final ImageJImagePeakResults r = new ImageJImagePeakResults(title, bounds, 1);
    r.setDisplayFlags(ImageJImagePeakResults.DISPLAY_WEIGHTED);
    final FloatProcessor fp = new FloatProcessor(bounds.width, bounds.height);
    begin(r);
    addValue(r, 1.5f, 2.5f, 2);
    fp.putPixelValue(1, 2, 2);
    r.end();
    final float[] expecteds = getImage(fp);
    final float[] actuals = getImage(r);
    Assertions.assertArrayEquals(expecteds, actuals);
}
Also used : FloatProcessor(ij.process.FloatProcessor) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest) Test(org.junit.jupiter.api.Test)

Example 69 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class FloatDht3DTest method createOctantsStack.

static ImageStack createOctantsStack(int width, int height, int depth) {
    final int w_2 = width / 2;
    final int stepH2 = height / 2;
    final int d_2 = depth / 2;
    final ImageStack stack = new ImageStack(width, height, depth);
    final FloatProcessor fp = new FloatProcessor(width, height);
    final float[] pixels = (float[]) fp.getPixels();
    fill(fp, w_2, 0, w_2, stepH2, 1);
    fill(fp, 0, 0, w_2, stepH2, 2);
    fill(fp, 0, stepH2, w_2, stepH2, 3);
    fill(fp, w_2, stepH2, w_2, stepH2, 4);
    for (int z = 0; z < d_2; z++) {
        stack.setPixels(pixels.clone(), 1 + z);
    }
    fill(fp, w_2, 0, w_2, stepH2, 5);
    fill(fp, 0, 0, w_2, stepH2, 6);
    fill(fp, 0, stepH2, w_2, stepH2, 7);
    fill(fp, w_2, stepH2, w_2, stepH2, 8);
    for (int z = d_2; z < depth; z++) {
        stack.setPixels(pixels.clone(), 1 + z);
    }
    return stack;
}
Also used : ImageStack(ij.ImageStack) FloatProcessor(ij.process.FloatProcessor)

Example 70 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class ImageConverterTest method canGetCropData.

@SeededTest
void canGetCropData(RandomSeed seed) {
    final ImageConverterTestData data = (ImageConverterTestData) dataCache.computeIfAbsent(seed, ImageConverterTest::createData);
    final byte[] bdata = data.bdata;
    final short[] sdata = data.sdata;
    final float[] fdata = data.fdata;
    final UniformRandomProvider rand = RngUtils.create(seed.getSeed());
    final ImageExtractor ie = ImageExtractor.wrap(fdata, w, h);
    for (int i = 0; i < 10; i++) {
        final Rectangle bounds = ie.getBoxRegionBounds(10 + rand.nextInt(w - 20), 10 + rand.nextInt(h - 20), 5 + rand.nextInt(5));
        final FloatProcessor ip = new FloatProcessor(w, h, fdata.clone());
        ip.setRoi(bounds);
        final float[] fe = (float[]) (ip.crop().getPixels());
        Assertions.assertArrayEquals(fe, ImageJImageConverter.getData(bdata, w, h, bounds, null));
        Assertions.assertArrayEquals(fe, ImageJImageConverter.getData(sdata, w, h, bounds, null));
        Assertions.assertArrayEquals(fe, ImageJImageConverter.getData(fdata, w, h, bounds, null));
        // Check the double format
        final double[] de = SimpleArrayUtils.toDouble(fe);
        Assertions.assertArrayEquals(de, ImageJImageConverter.getDoubleData(bdata, w, h, bounds, null));
        Assertions.assertArrayEquals(de, ImageJImageConverter.getDoubleData(sdata, w, h, bounds, null));
        Assertions.assertArrayEquals(de, ImageJImageConverter.getDoubleData(fdata, w, h, bounds, null));
    }
}
Also used : FloatProcessor(ij.process.FloatProcessor) 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

FloatProcessor (ij.process.FloatProcessor)174 ImageProcessor (ij.process.ImageProcessor)30 SeededTest (uk.ac.sussex.gdsc.test.junit5.SeededTest)26 Rectangle (java.awt.Rectangle)23 Test (org.junit.Test)22 ByteProcessor (ij.process.ByteProcessor)21 ShortProcessor (ij.process.ShortProcessor)20 Point (java.awt.Point)20 Test (org.junit.jupiter.api.Test)20 ImagePlus (ij.ImagePlus)19 ImageStack (ij.ImageStack)19 Future (java.util.concurrent.Future)12 ColorProcessor (ij.process.ColorProcessor)11 ArrayList (java.util.ArrayList)9 LinkedList (java.util.LinkedList)8 Fht (uk.ac.sussex.gdsc.core.ij.process.Fht)7 Point (mpicbg.models.Point)6 FHT2 (ij.process.FHT2)5 File (java.io.File)5 UniformRandomProvider (org.apache.commons.rng.UniformRandomProvider)5