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);
}
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);
}
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);
}
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;
}
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));
}
}
Aggregations