use of ij.ImagePlus in project bioformats by openmicroscopy.
the class ImporterTest method colorCustomTester.
/**
* tests BF's options.setColorMode(custom)
*/
private void colorCustomTester(boolean virtual, int pixType, boolean indexed, int channels, int chanPerPlane, boolean falseColor, int numSeries) {
int sizeX = 55, sizeY = 71, sizeZ = 3, sizeT = 4;
String path = constructFakeFilename("colorCustom", pixType, sizeX, sizeY, sizeZ, channels, sizeT, numSeries, indexed, chanPerPlane, falseColor, -1);
LOGGER.debug("colorCustomTester: {}", path);
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setVirtual(virtual);
options.setColorMode(ImporterOptions.COLOR_MODE_CUSTOM);
int maxChannels = (channels <= 7) ? channels : 7;
for (int s = 0; s < numSeries; s++) for (int c = 0; c < maxChannels; c++) options.setCustomColor(s, c, CUSTOM_COLOR_ORDER[c]);
options.setId(path);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
impsCountTest(imps, 1);
ImagePlus imp = imps[0];
int lutLen = 3;
int expectedSizeC = effectiveC(channels, chanPerPlane, lutLen, indexed, falseColor);
xyzctTest(imp, sizeX, sizeY, sizeZ, expectedSizeC, sizeT);
if ((expectedSizeC >= 2) && (expectedSizeC <= 7)) {
assertTrue(imp.isComposite());
CompositeImage ci = (CompositeImage) imp;
assertTrue(ci.hasCustomLuts());
assertEquals(CompositeImage.COLOR, ci.getMode());
colorTests(ci, expectedSizeC, CUSTOM_COLOR_ORDER);
} else // expectedSizeC < 2 or > 7 - we should have gotten back a regular ImagePlus
{
assertFalse(imp.isComposite());
imagePlusLutTest(imp, indexed, falseColor, CUSTOM_COLOR_ORDER[0]);
}
stackInCztOrderTest(imp, sizeZ, expectedSizeC, sizeT, indexed, falseColor);
// TODO : i've done no pixel testing
}
use of ij.ImagePlus in project bioformats by openmicroscopy.
the class ImporterTest method testComboManyOptions.
@Test
public void testComboManyOptions() {
// note - crop and setTStep both don't work with virtualStacks. No need to test virtual here.
int pixType = FormatTools.UINT16, sizeX = 106, sizeY = 33, sizeZ = 3, sizeC = 5, sizeT = 7;
int cropOriginX = 0, cropOriginY = 0, cropSizeX = 55, cropSizeY = 16, start = 1, stepBy = 2;
// orig is ZCT : this is a deadly swap of all dims
ChannelOrder swappedOrder = ChannelOrder.CTZ;
// note - to reuse existing code it is necessary that the crop origin is (0,0)
String path = constructFakeFilename("superCombo", pixType, sizeX, sizeY, sizeZ, sizeC, sizeT, 1, false, -1, false, -1);
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setId(path);
options.setSwapDimensions(true);
options.setInputOrder(0, bfChanOrd(swappedOrder));
options.setCrop(true);
options.setCropRegion(0, new Region(cropOriginX, cropOriginY, cropSizeX, cropSizeY));
options.setTStep(0, stepBy);
options.setTBegin(0, start);
options.setSplitFocalPlanes(true);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
// we split on Z but that dim was swapped with T
impsCountTest(imps, sizeT);
stackCtzSwappedAndCroppedTest(imps, cropSizeX, cropSizeY, sizeZ, sizeC, sizeT, start, stepBy);
}
use of ij.ImagePlus in project bioformats by openmicroscopy.
the class ImporterTest method memorySpecifyRangeTester.
/**
* tests BF's options.set?Begin(), options.set?End(), and options.set?Step()
*/
private void memorySpecifyRangeTester(int z, int c, int t, int zFrom, int zTo, int zBy, int cFrom, int cTo, int cBy, int tFrom, int tTo, int tBy) {
int pixType = FormatTools.UINT8, x = 50, y = 5;
String path = constructFakeFilename("range", pixType, x, y, z, c, t, -1, false, -1, false, -1);
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setId(path);
// z's
if (zFrom != 0)
options.setZBegin(0, zFrom);
if (zTo != z - 1)
options.setZEnd(0, zTo);
if (zBy != 1)
options.setZStep(0, zBy);
// c's
if (cFrom != 0)
options.setCBegin(0, cFrom);
if (cTo != c - 1)
options.setCEnd(0, cTo);
if (cBy != 1)
options.setCStep(0, cBy);
// t's
if (tFrom != 0)
options.setTBegin(0, tFrom);
if (tTo != t - 1)
options.setTEnd(0, tTo);
if (tBy != 1)
options.setTStep(0, tBy);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
// should have the data in one series
impsCountTest(imps, 1);
ImagePlus imp = imps[0];
xyzctTest(imp, x, y, numInSeries(zFrom, zTo, zBy), numInSeries(cFrom, cTo, cBy), numInSeries(tFrom, tTo, tBy));
// should be in correct order
seriesInZctOrderTest(imp, false, false, zFrom, zTo, zBy, cFrom, cTo, cBy, tFrom, tTo, tBy);
}
use of ij.ImagePlus in project bioformats by openmicroscopy.
the class ImporterTest method colorGrayscaleTester.
/**
* tests BF's options.setColorMode(gray)
*/
private void colorGrayscaleTester(boolean virtual, int pixType, boolean indexed, int channels, int chanPerPlane, boolean falseColor, int numSeries) {
int sizeX = 55, sizeY = 71, sizeZ = 3, sizeT = 4;
String path = constructFakeFilename("colorGrayscale", pixType, sizeX, sizeY, sizeZ, channels, sizeT, numSeries, indexed, chanPerPlane, falseColor, -1);
LOGGER.debug("colorGrayscaleTester: {}", path);
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setVirtual(virtual);
options.setColorMode(ImporterOptions.COLOR_MODE_GRAYSCALE);
options.setId(path);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
impsCountTest(imps, 1);
ImagePlus imp = imps[0];
int lutLen = 3;
int expectedSizeC = effectiveC(channels, chanPerPlane, lutLen, indexed, falseColor);
xyzctTest(imp, sizeX, sizeY, sizeZ, expectedSizeC, sizeT);
if ((expectedSizeC >= 2) && (expectedSizeC <= 7)) {
assertTrue(imp.isComposite());
CompositeImage ci = (CompositeImage) imp;
assertFalse(ci.hasCustomLuts());
assertEquals(CompositeImage.GRAYSCALE, ci.getMode());
colorTests(ci, expectedSizeC, DEFAULT_COLOR_ORDER);
} else // expectedSizeC < 2 or > 7 - we should have gotten back a regular ImagePlus
{
assertFalse(imp.isComposite());
imagePlusLutTest(imp, indexed, falseColor, DEFAULT_COLOR_ORDER[0]);
}
stackInCztOrderTest(imp, sizeZ, expectedSizeC, sizeT, indexed, falseColor);
// TODO : i've done no pixel testing
}
use of ij.ImagePlus in project bioformats by openmicroscopy.
the class ImporterTest method memoryVirtualStackTester.
/**
* tests BF's options.setVirtual()
*/
private void memoryVirtualStackTester(boolean desireVirtual) {
int x = 604, y = 531, z = 7, c = 1, t = 1;
String path = constructFakeFilename("vstack", FormatTools.UINT16, x, y, z, c, t, -1, false, -1, false, -1);
// open stack
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setId(path);
// user specified value here
options.setVirtual(desireVirtual);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
// test results
impsCountTest(imps, 1);
ImagePlus imp = imps[0];
xyzctTest(imp, x, y, z, c, t);
assertEquals(desireVirtual, imp.getStack().isVirtual());
}
Aggregations