net.imglib2.img.cell.CellImgFactory Java Examples
The following examples show how to use
net.imglib2.img.cell.CellImgFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateImgTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testImageFactory() { final Dimensions dim = new FinalDimensions(10, 10, 10); @SuppressWarnings("unchecked") final Img<DoubleType> arrayImg = (Img<DoubleType>) ops.run( CreateImgFromDimsAndType.class, dim, new DoubleType(), new ArrayImgFactory<DoubleType>()); final Class<?> arrayFactoryClass = arrayImg.factory().getClass(); assertEquals("Image Factory: ", ArrayImgFactory.class, arrayFactoryClass); @SuppressWarnings("unchecked") final Img<DoubleType> cellImg = (Img<DoubleType>) ops.run( CreateImgFromDimsAndType.class, dim, new DoubleType(), new CellImgFactory<DoubleType>()); final Class<?> cellFactoryClass = cellImg.factory().getClass(); assertEquals("Image Factory: ", CellImgFactory.class, cellFactoryClass); }
Example #2
Source File: CreateLabelingTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@SuppressWarnings("unchecked") @Test public void testImageFactory() { final Dimensions dim = new FinalDimensions( 10, 10, 10 ); assertEquals("Labeling Factory: ", ArrayImgFactory.class, ((Img<?>) ((ImgLabeling<String, ?>) ops.run( DefaultCreateImgLabeling.class, dim, null, new ArrayImgFactory<IntType>())).getIndexImg()).factory().getClass()); assertEquals("Labeling Factory: ", CellImgFactory.class, ((Img<?>) ((ImgLabeling<String, ?>) ops.run( DefaultCreateImgLabeling.class, dim, null, new CellImgFactory<IntType>())).getIndexImg()).factory().getClass()); }
Example #3
Source File: SlideBook6.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
protected ImgFactory<? extends NativeType<?>> selectImgFactory(final SlideBook6MetaData meta) { int[] dims = meta.imageSize(0); long maxNumPixels = dims[0]; maxNumPixels *= dims[1]; maxNumPixels *= dims[2]; String s = "Maximum number of pixels in any view: n=" + Long.toString(maxNumPixels) + " px "; if (maxNumPixels < Integer.MAX_VALUE) { IOFunctions.println(s + "< " + Integer.MAX_VALUE + ", using ArrayImg."); return new ArrayImgFactory<FloatType>(); } else { IOFunctions.println(s + ">= " + Integer.MAX_VALUE + ", using CellImg."); return new CellImgFactory<FloatType>(256); } }
Example #4
Source File: LegacyStackImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
protected < T extends NativeType< T > > Img< T > instantiateImg( final long[] dim, final T type ) { Img< T > img; try { img = getImgFactory().imgFactory( type ).create( dim, type ); } catch ( Exception e1 ) { try { img = new CellImgFactory< T >( 256 ).create( dim, type ); } catch ( Exception e2 ) { img = null; } } return img; }
Example #5
Source File: SCIFIOCellImgFactory.java From scifio with BSD 2-Clause "Simplified" License | 6 votes |
private CellGrid createCellGrid(final long[] dimensions, final Fraction entitiesPerPixel) { CellImgFactory.verifyDimensions(dimensions); final int n = dimensions.length; final int[] defaultDims = new int[dimensions.length]; for (int d = 0; d < defaultDims.length; d++) { defaultDims[d] = dimensions[d] < defaultCellDimensions[d] ? // (int) dimensions[d] : defaultCellDimensions[d]; } final int[] cellDimensions = CellImgFactory.getCellDimensions(defaultDims, n, entitiesPerPixel); return new CellGrid(dimensions, cellDimensions); }
Example #6
Source File: AbstractOpTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
public CellImg<ByteType, ?> generateByteTestCellImg(final boolean fill, final long... dims) { final CellImg<ByteType, ?> img = new CellImgFactory<ByteType>().create(dims, new ByteType()); if (fill) { final Cursor<ByteType> c = img.cursor(); while (c.hasNext()) c.next().set((byte) pseudoRandom()); } return img; }
Example #7
Source File: AbstractOpTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
public CellImg<ByteType, ?> generateByteTestCellImg(final boolean fill, final int[] cellDims, final long... dims) { final CellImg<ByteType, ?> img = new CellImgFactory<ByteType>(cellDims) .create(dims, new ByteType()); if (fill) { final Cursor<ByteType> c = img.cursor(); while (c.hasNext()) c.next().set((byte) pseudoRandom()); } return img; }
Example #8
Source File: Resave_TIFF.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
public static Parameters getParameters() { final GenericDialogPlus gd = new GenericDialogPlus( "Resave dataset as TIFF" ); if ( defaultPath == null ) defaultPath = LoadParseQueryXML.defaultXMLfilename; PluginHelper.addSaveAsFileField( gd, "Select new XML", defaultPath, 80 ); gd.addChoice( "ImgLib2_data_container", StackList.imglib2Container, StackList.imglib2Container[ defaultContainer ] ); gd.addCheckbox( "Lossless compression of TIFF files (ZIP)", defaultCompress ); gd.addMessage( "Use ArrayImg if -ALL- input views are smaller than ~2048x2048x500 px (2^31 px), or if the\n" + "program throws an OutOfMemory exception while processing. CellImg is slower, but more\n" + "memory efficient and supports much larger file sizes only limited by the RAM of the machine.", new Font( Font.SANS_SERIF, Font.ITALIC, 11 ) ); gd.showDialog(); if ( gd.wasCanceled() ) return null; final Parameters params = new Parameters(); params.xmlFile = gd.getNextString(); if ( !params.xmlFile.endsWith( ".xml" ) ) params.xmlFile += ".xml"; params.compress = defaultCompress = gd.getNextBoolean(); defaultPath = LoadParseQueryXML.defaultXMLfilename = params.xmlFile; if ( ( defaultContainer = gd.getNextChoiceIndex() ) == 0 ) params.imgFactory = new ArrayImgFactory< FloatType >(); else params.imgFactory = new CellImgFactory< FloatType >(); return params; }
Example #9
Source File: LightSheetZ1.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
protected ImgFactory< ? extends NativeType< ? > > selectImgFactory( final LightSheetZ1MetaData meta ) { long maxNumPixels = 0; for ( int a = 0; a < meta.numAngles(); ++a ) { final int[] dim = meta.imageSizes().get( a ); long n = 1; for ( int d = 0; d < dim.length; ++d ) { n *= (long)dim[ d ]; if ( dim[ d ] <= 0 ) { IOFunctions.println( "Dimensions couldn't be read from metadata, using CellImg(256)." ); return new CellImgFactory< FloatType >( 256 ); } } maxNumPixels = Math.max( n, maxNumPixels ); } int smallerLog2 = (int)Math.ceil( Math.log( maxNumPixels ) / Math.log( 2 ) ); String s = "Maximum number of pixels in any view: n=" + maxNumPixels + " (2^" + (smallerLog2-1) + " < n < 2^" + smallerLog2 + " px), "; if ( smallerLog2 <= 31 ) { IOFunctions.println( s + "using ArrayImg." ); return new ArrayImgFactory< FloatType >(); } else { IOFunctions.println( s + "using CellImg(256)." ); return new CellImgFactory< FloatType >( 256 ); } }
Example #10
Source File: BoundingBoxGUI.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
public < T extends ComplexType< T > & NativeType < T > > ImgFactory< T > getImgFactory( final T type ) { final ImgFactory< T > imgFactory; if ( this.getImgType() == 0 ) imgFactory = new ArrayImgFactory< T >(); else if ( this.getImgType() == 1 ) imgFactory = new ImagePlusImgFactory< T >(); else imgFactory = new CellImgFactory<T>( 256 ); return imgFactory; }
Example #11
Source File: DefaultCreateImgFactory.java From imagej-ops with BSD 2-Clause "Simplified" License | 4 votes |
@Override public ImgFactory<T> calculate() { return (dims == null || Intervals.numElements(dims) <= Integer.MAX_VALUE) ? new ArrayImgFactory<>() : new CellImgFactory<>(); }
Example #12
Source File: XmlIoSlideBook6ImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public SlideBook6ImgLoader fromXml( final Element elem, File basePath, final AbstractSequenceDescription<?, ?, ?> sequenceDescription ) { try { final File path = loadPath( elem, DIRECTORY_TAG, basePath ); final String masterFile = XmlHelpers.getText( elem, MASTER_FILE_TAG ); final String container = XmlHelpers.getText( elem, IMGLIB2CONTAINER_PATTERN_TAG ); final ImgFactory< FloatType > imgFactory; if ( container == null ) { System.out.println( "WARNING: No Img implementation defined in XML, using ArrayImg." ); // if no factory is defined we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); } else { if ( container.toLowerCase().contains( "cellimg" ) ) { imgFactory = new CellImgFactory< FloatType >( 256 ); } else if ( container.toLowerCase().contains( "arrayimg" ) ) { imgFactory = new ArrayImgFactory< FloatType >(); } else if ( container.toLowerCase().contains( "planarimg" ) ) { imgFactory = new PlanarImgFactory< FloatType >(); } else { // if factory is unknown we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); System.out.println( "WARNING: Unknown Img implementation defined in XML:'" + container + "', using ArrayImg." ); } } return new SlideBook6ImgLoader( new File( path, masterFile ), imgFactory, sequenceDescription ); } catch ( final Exception e ) { throw new RuntimeException( e ); } }
Example #13
Source File: XmlIoLightSheetZ1ImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public LightSheetZ1ImgLoader fromXml( final Element elem, File basePath, final AbstractSequenceDescription<?, ?, ?> sequenceDescription ) { try { final File path = loadPath( elem, DIRECTORY_TAG, basePath ); final String masterFile = XmlHelpers.getText( elem, MASTER_FILE_TAG ); final String container = XmlHelpers.getText( elem, IMGLIB2CONTAINER_PATTERN_TAG ); final ImgFactory< FloatType > imgFactory; if ( container == null ) { System.out.println( "WARNING: No Img implementation defined in XML, using ArrayImg." ); // if no factory is defined we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); } else { if ( container.toLowerCase().contains( "cellimg" ) ) { imgFactory = new CellImgFactory< FloatType >( 256 ); } else if ( container.toLowerCase().contains( "arrayimg" ) ) { imgFactory = new ArrayImgFactory< FloatType >(); } else if ( container.toLowerCase().contains( "planarimg" ) ) { imgFactory = new PlanarImgFactory< FloatType >(); } else { // if factory is unknown we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); System.out.println( "WARNING: Unknown Img implementation defined in XML:'" + container + "', using ArrayImg." ); } } return new LightSheetZ1ImgLoader( new File( path, masterFile ), imgFactory, sequenceDescription ); } catch ( final Exception e ) { throw new RuntimeException( e ); } }
Example #14
Source File: XmlIoStackImgLoader.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public T fromXml( final Element elem, final File basePath, final AbstractSequenceDescription< ?, ?, ? > sequenceDescription ) { try { File path = loadPath( elem, DIRECTORY_TAG, basePath ); String fileNamePattern = XmlHelpers.getText( elem, FILE_PATTERN_TAG ); int layoutTP = XmlHelpers.getInt( elem, LAYOUT_TP_TAG ); int layoutChannels = XmlHelpers.getInt( elem, LAYOUT_CHANNEL_TAG ); int layoutIllum = XmlHelpers.getInt( elem, LAYOUT_ILLUMINATION_TAG ); int layoutAngles = XmlHelpers.getInt( elem, LAYOUT_ANGLE_TAG ); final String container = XmlHelpers.getText( elem, IMGLIB2CONTAINER_PATTERN_TAG ); ImgFactory< FloatType > imgFactory; if ( container == null ) { System.out.println( "WARNING: No Img implementation defined, using ArrayImg." ); // if no factory is defined we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); } else { if ( container.toLowerCase().contains( "cellimg" ) ) { imgFactory = new CellImgFactory< FloatType >( 256 ); } else if ( container.toLowerCase().contains( "arrayimg" ) ) { imgFactory = new ArrayImgFactory< FloatType >(); } else if ( container.toLowerCase().contains( "planarimg" ) ) { imgFactory = new PlanarImgFactory< FloatType >(); } else { // if factory is unknown we define an ArrayImgFactory imgFactory = new ArrayImgFactory< FloatType >(); System.out.println( "WARNING: Unknown Img implementation '" + container + "', using ArrayImg." ); } } return createImgLoader( path, fileNamePattern, imgFactory, layoutTP, layoutChannels, layoutIllum, layoutAngles, sequenceDescription ); } catch ( final Exception e ) { throw new RuntimeException( e ); } }
Example #15
Source File: EfficientBayesianBased.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public boolean parseAdditionalParameters( final GenericDialog gd ) { defaultFFTImgType = gd.getNextChoiceIndex(); if ( defaultFFTImgType == 0 ) computeFactory = new ArrayImgFactory< FloatType >(); else if ( defaultFFTImgType == 1 ) computeFactory = new ImagePlusImgFactory< FloatType >(); else computeFactory = new CellImgFactory< FloatType >( 256 ); saveMemory = defaultSaveMemory = gd.getNextBoolean(); defaultIterationType = gd.getNextChoiceIndex(); if ( defaultIterationType == 0 ) iterationType = PSFTYPE.OPTIMIZATION_II; else if ( defaultIterationType == 1 ) iterationType = PSFTYPE.OPTIMIZATION_I; else if ( defaultIterationType == 2 ) iterationType = PSFTYPE.EFFICIENT_BAYESIAN; else //if ( defaultIterationType == 3 ) iterationType = PSFTYPE.INDEPENDENT; defaultWeightType = gd.getNextChoiceIndex(); if ( defaultWeightType == 0 ) weightType = WeightType.PRECOMPUTED_WEIGHTS; else if ( defaultWeightType == 1 ) weightType = WeightType.VIRTUAL_WEIGHTS; else if ( defaultWeightType == 2 ) weightType = WeightType.NO_WEIGHTS; else weightType = WeightType.WEIGHTS_ONLY; osemspeedupIndex = defaultOSEMspeedupIndex = gd.getNextChoiceIndex(); numIterations = defaultNumIterations = (int)Math.round( gd.getNextNumber() ); debugMode = defaultDebugMode = gd.getNextBoolean(); adjustBlending = defaultAdjustBlending = gd.getNextBoolean(); useTikhonovRegularization = defaultUseTikhonovRegularization = gd.getNextBoolean(); lambda = defaultLambda = gd.getNextNumber(); blockSizeIndex = defaultBlockSizeIndex = gd.getNextChoiceIndex(); computationTypeIndex = defaultComputationTypeIndex = gd.getNextChoiceIndex(); extractPSFIndex = defaultExtractPSF = gd.getNextChoiceIndex(); displayPSF = defaultDisplayPSF = gd.getNextChoiceIndex(); return true; }