/** Converts the given reader into a MinMaxCalculator, wrapping if needed. */ public static MinMaxCalculator makeMinMaxCalculator(IFormatReader r) { if (r instanceof MinMaxCalculator) return (MinMaxCalculator) r; return new MinMaxCalculator(r); }
/** Converts the given reader into a MinMaxCalculator, wrapping if needed. */ public static MinMaxCalculator makeMinMaxCalculator(IFormatReader r) { if (r instanceof MinMaxCalculator) return (MinMaxCalculator) r; return new MinMaxCalculator(r); }
/** * Helper method to properly log any exceptions raised by Bio-Formats and * add a min/max calculator wrapper to the reader stack. * @param filePath Non-null. * @param series series to use * @param store Min/max store to use with the min/max calculator. */ protected BfPixelBuffer createMinMaxBfPixelBuffer(final String filePath, final int series, final IMinMaxStore store) { try { IFormatReader reader = createBfReader(); MinMaxCalculator calculator = new MinMaxCalculator(reader); calculator.setMinMaxStore(store); BfPixelBuffer pixelBuffer = new BfPixelBuffer(filePath, calculator); pixelBuffer.setSeries(series); log.info(String.format("Creating BfPixelBuffer: %s Series: %d", filePath, series)); return pixelBuffer; } catch (Exception e) { String msg = "Error instantiating pixel buffer: " + filePath; log.error(msg, e); throw new ResourceError(msg); } }
@Test public void setId() throws Exception { reader = new ImageReader(); reader = new ChannelFiller(reader); reader = new ChannelSeparator(reader); reader = new MinMaxCalculator(reader); if (memMap && reader.isSingleFile(id)) { TestTools.mapFile(id); } StopWatch stopWatch = new Slf4JStopWatch(); reader.setId(id); stopWatch.stop(String.format("%s.setId.%s", ((ReaderWrapper) reader).unwrap().getClass().getName(), filename)); seriesCount = reader.getSeriesCount(); }
@Test public void testSetId() throws Exception { reader = new MinMaxCalculator(new ChannelSeparator( new ChannelFiller(new ImageReader()))); metadata = new OMEXMLMetadataImpl(); reader.setMetadataStore(metadata); reader.setId(temporaryFile.getAbsolutePath()); }
@Test public void testSetIdWithNoLightSources() throws Exception { readerWithNoLightSources = new MinMaxCalculator(new ChannelSeparator( new ChannelFiller(new ImageReader()))); metadataWithNoLightSources = new OMEXMLMetadataImpl(); readerWithNoLightSources.setMetadataStore(metadataWithNoLightSources); readerWithNoLightSources.setId( temporaryFileWithNoLightSources.getAbsolutePath()); }
@Test public void testSetId() throws Exception { reader = new MinMaxCalculator(new ChannelSeparator( new ChannelFiller(new ImageReader()))); metadata = new OMEXMLMetadataImpl(); reader.setMetadataStore(metadata); reader.setId(temporaryFile.getAbsolutePath()); }
@Test public void testSetId() throws Exception { reader = new MinMaxCalculator(new ChannelSeparator( new ChannelFiller(new ImageReader()))); metadata = new OMEXMLMetadataImpl(); reader.setMetadataStore(metadata); reader.setId(temporaryFile.getAbsolutePath()); }
@BeforeMethod public void setUp() throws Exception { fullPlaneCallIndex = 1; Location.mapId(TEST_FILE, TEST_FILE); reader = new MinMaxCalculatorTestReader(); reader.setId(TEST_FILE); minMaxStore = new TestMinMaxStore(); minMaxCalculator = new MinMaxCalculator(reader); minMaxCalculator.setMinMaxStore(minMaxStore); sizeX = reader.getSizeX(); sizeY = reader.getSizeY(); bpp = FormatTools.getBytesPerPixel(reader.getPixelType()); planeSize = sizeY * sizeY * bpp; }
@DataProvider(name = "wrappers") public Object[][] createWrappers() { Location.mapId(TEST_FILE, TEST_FILE); Object[][] wrappers = new Object[][] { {new ChannelFiller()}, {new ChannelMerger()}, {new ChannelSeparator()}, {new DimensionSwapper()}, {new FileStitcher()}, {new ImageReader()}, {new MinMaxCalculator()}, {new Memoizer()} }; for (int i=0; i<wrappers.length; i++) { IFormatReader reader = (IFormatReader) wrappers[i][0]; try { reader.setId(TEST_FILE); } catch (FormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return wrappers; }
if (minmax || autoscale) reader = minMaxCalc = new MinMaxCalculator(reader); dimSwapper = null; if (swapOrder != null || shuffleOrder != null) {
minMax = null; if (autoscale) { reader = new MinMaxCalculator(reader); minMax = (MinMaxCalculator) reader;
{new ImageReader(), new ImageReader()}, {new ImageReader(), new ImageReader()}, {new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())), new MinMaxCalculator(new ChannelSeparator())}, {new DimensionSwapper(new ChannelMerger()), new DimensionSwapper(new ChannelMerger())}
@DataProvider(name = "equalWrappers") public Object[][] createEqualWrappers() { Location.mapId(TEST_FILE_A, TEST_FILE_A); Location.mapId(TEST_FILE_B, TEST_FILE_B); Object[][] wrappers = new Object[][] { {new ImageReader(), new ImageReader()}, {new ImageReader(), new ImageReader()}, {new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())), new MinMaxCalculator(new ChannelSeparator(new ChannelFiller()))}, {new DimensionSwapper(new ChannelMerger()), new DimensionSwapper(new ChannelMerger())} }; for (int i=1; i<wrappers.length; i++) { IFormatReader readerA = (IFormatReader) wrappers[i][0]; IFormatReader readerB = (IFormatReader) wrappers[i][1]; try { readerA.setId(TEST_FILE_A); readerB.setId(TEST_FILE_B); } catch (FormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return wrappers; }
/** * Checks that the min and max values for each core index do not change * when the resolutions are unflattened. */ @Test public void testMultipleResolutions() throws Exception { minMaxCalculator.setCoreIndex(0); minMaxCalculator.openBytes(0); assertMinMax(-2.0, 101.0); minMaxCalculator.setCoreIndex(1); minMaxCalculator.openBytes(0); assertMinMax(-1.0, 102.0); MinMaxCalculator unflattened = new MinMaxCalculator(new MinMaxCalculatorTestReader()); try { unflattened.setFlattenedResolutions(false); unflattened.setId(TEST_FILE); unflattened.setCoreIndex(0); unflattened.openBytes(0); assertEquals(-2.0, unflattened.getPlaneMinimum(0)[0]); assertEquals(103.0, unflattened.getPlaneMaximum(0)[0]); unflattened.setCoreIndex(1); unflattened.openBytes(0); assertEquals(-1.0, unflattened.getPlaneMinimum(0)[0]); assertEquals(104.0, unflattened.getPlaneMaximum(0)[0]); } finally { unflattened.close(); } }
r = minMaxCalculator = new MinMaxCalculator(r);
r = minMaxCalculator = new MinMaxCalculator(r);