本文整理汇总了Java中net.imglib2.img.ImgFactory类的典型用法代码示例。如果您正苦于以下问题:Java ImgFactory类的具体用法?Java ImgFactory怎么用?Java ImgFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImgFactory类属于net.imglib2.img包,在下文中一共展示了ImgFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HWatershedLabeling
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public HWatershedLabeling(Img<T> input, float threshold, Connectivity connectivity)
{
int nDims = input.numDimensions();
long[] dims = new long[nDims];
input.dimensions(dims);
ImgFactory<IntType> imgFactoryIntType=null;
try {
imgFactoryIntType = input.factory().imgFactory( new IntType() );
} catch (IncompatibleTypeException e) {
e.printStackTrace();
}
if ( imgFactoryIntType != null )
{
this.labelMapMaxTree = imgFactoryIntType.create(dims, new IntType(0));
Cursor<IntType> c_label = labelMapMaxTree.cursor();
Cursor<T> c_input = input.cursor();
while( c_input.hasNext() )
{
c_label.next().setInteger( (int) c_input.next().getRealFloat() );
}
}
this.threshold = threshold;
this.connectivity = connectivity;
}
示例2: Align
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public Align(final RandomAccessibleInterval< T > template, final ImgFactory< FloatType > factory, WarpFunction model)
{
this.template = template;
n = template.numDimensions();
warpFunction = model;
numParameters = warpFunction.numParameters();
currentTransform = new AffineTransform( n );
final long[] dim = new long[n + 1];
for ( int d = 0; d < n; ++d )
dim[d] = template.dimension( d );
dim[n] = n;
final Img< FloatType > gradients = factory.create( dim, new FloatType() );
gradients( Views.extendBorder( template ), gradients );
dim[n] = numParameters;
descent = factory.create( dim, new FloatType() );
computeSteepestDescents( gradients, warpFunction, descent );
Hinv = computeInverseHessian( descent );
error = factory.create( template, new FloatType() );
}
示例3: calculatePCM
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public static <T extends RealType<T>, S extends RealType<S>, R extends RealType<R>, C extends ComplexType<C>> RandomAccessibleInterval<R> calculatePCM(
RandomAccessibleInterval<T> img1, RandomAccessibleInterval<S> img2, int[] extension,
ImgFactory<R> factory, R type, ImgFactory<C> fftFactory, C fftType, ExecutorService service){
// TODO: Extension absolute per dimension in pixels, i.e. int[] extension
// TODO: not bigger than the image dimension because the second mirroring is identical to the image
Dimensions extSize = PhaseCorrelation2Util.getExtendedSize(img1, img2, extension);
long[] paddedDimensions = new long[extSize.numDimensions()];
long[] fftSize = new long[extSize.numDimensions()];
FFTMethods.dimensionsRealToComplexFast(extSize, paddedDimensions, fftSize);
RandomAccessibleInterval<C> fft1 = fftFactory.create(fftSize, fftType);
RandomAccessibleInterval<C> fft2 = fftFactory.create(fftSize, fftType);
FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img1, extension),
FFTMethods.paddingIntervalCentered(img1, new FinalInterval(paddedDimensions))), fft1, service);
FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img2, extension),
FFTMethods.paddingIntervalCentered(img2, new FinalInterval(paddedDimensions))), fft2, service);
RandomAccessibleInterval<R> pcm = calculatePCMInPlace(fft1, fft2, factory, type, service);
return pcm;
}
示例4: main
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
final static public void main( final String[] args )
{
new ImageJ();
Img< FloatType > img = null;
try
{
ImgFactory< FloatType > imgFactory = new CellImgFactory<FloatType>( new int[] {64, 64} );
final ImgOpener io = new ImgOpener();
img = io.openImg( "/home/tobias/workspace/data/73_float.tif", imgFactory, new FloatType() );
}
catch ( Exception e )
{
e.printStackTrace();
return;
}
ImageJFunctions.show( img );
}
示例5: main
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
final static public void main( final String[] args )
{
new ImageJ();
Img< FloatType > img = null;
try
{
final ImgFactory< FloatType > imgFactory = new ArrayImgFactory< FloatType >();
final ImgOpener io = new ImgOpener();
img = io.openImg( "/home/tobias/workspace/data/73_float.tif", imgFactory, new FloatType() );
}
catch ( final Exception e )
{
e.printStackTrace();
return;
}
final RandomAccessibleInterval< FloatType > view = Views.hyperSlice( img, 2, 10 );
ImageJFunctions.show( view );
}
示例6: main
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public static void main( String[] args )
{
ImgFactory< IntType > imgFactory = new ArrayImgFactory< IntType >();
Img< IntType > input = imgFactory.create( dimensions, new IntType() );
// fill input image with test data
int[] pos = new int[ 2 ];
Cursor< IntType > c = input.localizingCursor();
while ( c.hasNext() )
{
c.fwd();
c.localize( pos );
c.get().set( testData[ pos[ 1 ] ][ pos[ 0 ] ] );
}
System.out.println("== dark to bright ==");
PixelListComponentTree< IntType > tree = PixelListComponentTree.buildComponentTree( input, new IntType(), true );
print( tree );
System.out.println("== bright to dark ==");
tree = PixelListComponentTree.buildComponentTree( input, new IntType(), false );
print( tree );
}
示例7: main
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public static <T extends RealType<T> & NativeType< T >> void main(final String[] args) throws ImgIOException, IncompatibleTypeException {
// File file = new File( "E:/Users/JeanYves/Desktop/Data/Y.tif");
final File file = new File( "/home/tobias/Desktop/Y.tif");
final int niter = 1000;
// Open file in imglib2
final ImgFactory< ? > imgFactory = new ArrayImgFactory< T >();
final Img< T > image = (Img< T >) new ImgOpener().openImg( file.getAbsolutePath(), imgFactory );
// Display it via ImgLib using ImageJ
new ImageJ();
ImageJFunctions.show( image );
benchmark( IterationMethod.TRANSLATE_VIEW, "With translated views:", niter, image );
benchmark( IterationMethod.TRANSLATE_VIEW_CURSOR, "With translated views (Cursors only):", niter, image );
benchmark( IterationMethod.TRANSLATE_VIEW_SPLIT, "With translated views (split into center and borders):", niter, image );
benchmark( IterationMethod.RANDOM_ACCESS, "With random access:", niter, image );
benchmark( IterationMethod.RANDOM_ACCESS_SPLIT, "With random access (split into center and borders):", niter, image );
benchmark( IterationMethod.RANDOM_ACCESS_NO_EXTEND, "With random access, no out of bounds access:", niter, image );
}
示例8: main
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
final static public void main( final String[] args ) throws ImgIOException
{
new ImageJ();
final ImgFactory< FloatType > imgFactory = new ArrayImgFactory< FloatType >();
// load image
final Img< FloatType > img = new ImgOpener().openImg( "/home/tobias/workspace/HisYFP/blob.tif", imgFactory, new FloatType() );
// detect edgels
final ArrayList< Edgel > edgels = SubpixelEdgelDetection.getEdgels( img, imgFactory, 2 );
final ImagePlus imp = ImageJFunctions.show( img );
imp.setOverlay( paintEdgels( edgels, 0.05 ) );
for (int i = 0; i<7; ++i) IJ.run("In");
}
示例9: example1
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public static void example1()
{
final ImgFactory< UnsignedShortType > imgFactory = new ArrayImgFactory< UnsignedShortType >();
Img< UnsignedShortType > image = imgFactory.create( new int[] { DIM, DIM, DIM }, new UnsignedShortType() );
long[] center = new long[] { 50, 50, 50 }; // the middle
long[] span = new long[] { 0, 10, 10 };
// Write into the image
EllipsoidNeighborhood< UnsignedShortType > ellipsoid = new EllipsoidNeighborhood< UnsignedShortType >( image, center, span );
int val = 250;
for ( UnsignedShortType pixel : ellipsoid )
{
pixel.set( val );
// val++;
}
ImageJFunctions.show( image );
}
示例10: example3
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public static void example3()
{
final ImgFactory< UnsignedByteType > imgFactory = new ArrayImgFactory< UnsignedByteType >();
Img< UnsignedByteType > image = imgFactory.create( new int[] { DIM, DIM, DIM }, new UnsignedByteType() );
long[][] centers = new long[][] { { 50, 50, 50 }, { 20, 20, 50 }, { 20, 70, 50 }, { 70, 70, 50 }, { 70, 20, 50 }
};
long[][] spans = new long[][] { { 20, 10, 15 }, { 20, 15, 1 }, { 1, 20, 15 }, { 20, 1, 15 }, { 20, 1, 1 } };
for ( int i = 0; i < spans.length; i++ )
{
EllipsoidNeighborhood< UnsignedByteType > ellipsoid = new EllipsoidNeighborhood< UnsignedByteType >( image, centers[i], spans[i] );
// Write into the image
int val = 200;
for ( UnsignedByteType pixel : ellipsoid )
{
pixel.set( val );
// val++;
}
}
ImageJFunctions.show( image );
}
示例11: createGaussianEllipseImg
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
public static <T extends NativeType<T> & RealType<T>> Img<T> createGaussianEllipseImg(ImgFactory<T> factory, int[] size, double[] ctr, double[] sigmas, double min, double max, T t){
Img<T> out = factory.create(size, t);
Cursor<T> c = out.localizingCursor();
double[] pos = new double[3];
while(c.hasNext())
{
c.fwd();
c.localize(pos);
double res = 0;
for(int d=0; d<size.length; d++)
{
res += (pos[d] - ctr[d]) * (pos[d] - ctr[d]) / sigmas[d];
}
res = 1/(1 + res);
if( res > min && res < max) c.get().setReal(res);
}
return out;
}
示例12: selectImgFactory
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
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);
}
}
示例13: LegacyStackImgLoader
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
/**
* For a local initialization without the XML
*
* @param path
* @param fileNamePattern
* @param imgFactory
* @param layoutTP - 0 == one, 1 == one per file, 2 == all in one file
* @param layoutChannels - 0 == one, 1 == one per file, 2 == all in one file
* @param layoutIllum - 0 == one, 1 == one per file, 2 == all in one file
* @param layoutAngles - 0 == one, 1 == one per file, 2 == all in one file
*/
public LegacyStackImgLoader(
final File path, final String fileNamePattern, final ImgFactory< ? extends NativeType< ? > > imgFactory,
final int layoutTP, final int layoutChannels, final int layoutIllum, final int layoutAngles,
final AbstractSequenceDescription< ?, ?, ? > sequenceDescription )
{
super();
this.path = path;
this.fileNamePattern = fileNamePattern;
this.layoutTP = layoutTP;
this.layoutChannels = layoutChannels;
this.layoutIllum = layoutIllum;
this.layoutAngles = layoutAngles;
this.sequenceDescription = sequenceDescription;
this.init( imgFactory );
}
示例14: getCUDAThread1
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
final protected static Thread getCUDAThread1(
final AtomicInteger ai, final ImgFactory< FloatType > blockFactory, final Block[] blocks, final int[] blockSize,
final Img< FloatType > image, final Img< FloatType > result, final int deviceId, final Img< FloatType > kernel1 )
{
final Thread cudaThread1 = new Thread( new Runnable()
{
public void run()
{
final Img< FloatType > block = blockFactory.create( Util.int2long( blockSize ), new FloatType() );
int i;
while ( ( i = ai.getAndIncrement() ) < blocks.length )
convolve1BlockCUDA( blocks[ i ], deviceId, image, result, block, kernel1, i );
}
});
return cudaThread1;
}
示例15: getCUDAThread2
import net.imglib2.img.ImgFactory; //导入依赖的package包/类
final protected static Thread getCUDAThread2(
final AtomicInteger ai, final ImgFactory< FloatType > blockFactory, final Block[] blocks, final int[] blockSize,
final Img< FloatType > image, final Img< FloatType > result, final int deviceId, final Img< FloatType > kernel2 )
{
final Thread cudaThread2 = new Thread( new Runnable()
{
public void run()
{
final Img< FloatType > block = blockFactory.create( Util.int2long( blockSize ), new FloatType() );
int i;
while ( ( i = ai.getAndIncrement() ) < blocks.length )
convolve2BlockCUDA( blocks[ i ], deviceId, image, result, block, kernel2 );
}
});
return cudaThread2;
}