本文整理汇总了Java中net.imglib2.img.ImgFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java ImgFactory.create方法的具体用法?Java ImgFactory.create怎么用?Java ImgFactory.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.img.ImgFactory
的用法示例。
在下文中一共展示了ImgFactory.create方法的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: gaussianSmooth
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
/**
* Gaussian Smooth of the input image using intermediate float format.
* @param <T>
* @param img
* @param sigma
* @return
*/
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> gaussianSmooth(
RandomAccessibleInterval<T> img, double[] sigma) {
Interval interval = Views.iterable(img);
ImgFactory<T> outputFactory = new ArrayImgFactory<T>();
final long[] dim = new long[ img.numDimensions() ];
img.dimensions(dim);
RandomAccessibleInterval<T> output = outputFactory.create( dim,
img.randomAccess().get().createVariable() );
final long[] pos = new long[ img.numDimensions() ];
Arrays.fill(pos, 0);
Localizable origin = new Point(pos);
ImgFactory<FloatType> tempFactory = new ArrayImgFactory<FloatType>();
RandomAccessible<T> input = Views.extendMirrorSingle(img);
Gauss.inFloat(sigma, input, interval, output, origin, tempFactory);
return output;
}
示例5: 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;
}
示例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: 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 );
}
示例8: 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 );
}
示例9: upsample
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
public static <T extends RealType<T> & NativeType<T>> Img<T> upsample(Img<T> input, long[] out_size, Interpolator interpType){
int nDim = input.numDimensions();
if(nDim != out_size.length){
return input;
}
long[] in_size = new long[nDim];
input.dimensions(in_size);
float[] upfactor = new float[nDim];
for(int i=0; i<nDim; i++){
upfactor[i] = (float)out_size[i]/in_size[i];
}
RealRandomAccess< T > interpolant;
switch(interpType){
case Linear:
NLinearInterpolatorFactory<T> NLinterp_factory = new NLinearInterpolatorFactory<T>();
interpolant = Views.interpolate( Views.extendBorder( input ), NLinterp_factory ).realRandomAccess();
break;
case Lanczos:
LanczosInterpolatorFactory<T> LanczosInterp_factory = new LanczosInterpolatorFactory<T>();
interpolant = Views.interpolate( Views.extendBorder( input ), LanczosInterp_factory ).realRandomAccess();
break;
default: // NearestNeighbor:
NearestNeighborInterpolatorFactory<T> NNInterp_factory = new NearestNeighborInterpolatorFactory<T>();
interpolant = Views.interpolate( Views.extendBorder( input ), NNInterp_factory ).realRandomAccess();
break;
}
final ImgFactory< T > imgFactory = new ArrayImgFactory< T >();
final Img< T > output = imgFactory.create( out_size , input.firstElement().createVariable() );
Cursor< T > out_cursor = output.localizingCursor();
float[] tmp = new float[2];
while(out_cursor.hasNext()){
out_cursor.fwd();
for ( int d = 0; d < nDim; ++d )
tmp[ d ] = out_cursor.getFloatPosition(d) /upfactor[d];
interpolant.setPosition(tmp);
out_cursor.get().setReal( Math.round( interpolant.get().getRealFloat() ) );
}
return output;
}
示例10: copyToImageStack
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
public static < T extends NumericType<T> > RandomAccessibleInterval<T> copyToImageStack(
final RandomAccessible< T > raible,
final Interval itvl,
final ImgFactory<T> factory,
final int nThreads )
{
// create the image plus image
final T t = raible.randomAccess().get().copy();
Img< T > target = factory.create( itvl, t );
return copyToImageStack( raible, itvl, target, nThreads );
}
示例11: producePerlinNoiseImage
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
/**
* Generates a Perlin noise image. It is based on Ken Perlin's
* reference implementation (ImprovedNoise class) and a small
* bit of Kas Thomas' sample code (http://asserttrue.blogspot.com/).
*/
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> producePerlinNoiseImage(T type, int width,
int height, double z, double scale) {
// create the new image
ImgFactory<T> imgFactory = new ArrayImgFactory<T>();
RandomAccessibleInterval<T> noiseImage = imgFactory.create( new int[] {width, height}, type);
Cursor<T> noiseCursor = Views.iterable(noiseImage).localizingCursor();
double xOffset = Math.random() * (width*width);
double yOffset = Math.random() * (height*height);
while (noiseCursor.hasNext()) {
noiseCursor.fwd();
double x = (noiseCursor.getDoublePosition(0) + xOffset) * scale;
double y = (noiseCursor.getDoublePosition(1) + yOffset) * scale;
float t = (float)ImprovedNoise.noise( x, y, z);
// ImprovedNoise.noise returns a float in the range [-1..1],
// whereas we want a float in the range [0..1], so:
t = (1 + t) * 0.5f;
noiseCursor.get().setReal(t);
}
//return gaussianSmooth(noiseImage, imgFactory, smoothingSigma);
return noiseImage;
}
示例12: main
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
public static void main( String[] args )
{
new ImageJ();
// test blending
ImgFactory< FloatType > f = new ArrayImgFactory< FloatType >();
Img< FloatType > img = f.create( new int[] { 400, 400 }, new FloatType() );
Cursor< FloatType > c = img.localizingCursor();
final int numDimensions = img.numDimensions();
final double[] tmp = new double[ numDimensions ];
// for blending
final long[] dimensions = new long[ numDimensions ];
img.dimensions( dimensions );
final float percentScaling = 0.2f;
final double[] border = new double[ numDimensions ];
while ( c.hasNext() )
{
c.fwd();
for ( int d = 0; d < numDimensions; ++d )
tmp[ d ] = c.getFloatPosition( d );
c.get().set( (float)BlendingPixelFusion.computeWeight( tmp, dimensions, border, percentScaling ) );
}
ImageJFunctions.show( img );
Log.debug( "done" );
}
示例13: createImage
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
private Img<UnsignedByteType> createImage(final byte[] data, final int w,
final int h, final ImgFactory<UnsignedByteType> cf)
{
final long[] dim = { w, h };
final Img<UnsignedByteType> img = cf.create(dim, new UnsignedByteType());
int index = 0;
for (final UnsignedByteType t : img)
t.set(data[index++]);
return img;
}
示例14: main
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
public static void main( final String[] args )
{
final int n = 2;
final long[] dimensions = new long[] { 5, 5 };
final ImgFactory< CoordinateType > f = new ListImgFactory< CoordinateType >();
final CoordinateType type = new CoordinateType( n );
final Img< CoordinateType > img = f.create( dimensions, type );
final Cursor< CoordinateType > c = img.localizingCursor();
while ( c.hasNext() )
c.next().setPosition( c );
// c.reset();
// while ( c.hasNext() )
// System.out.println( c.next() );
// final Point center = new Point( 2l, 2l );
// final LocalNeighborhood2< CoordinateType > neighborhood = new LocalNeighborhood2< CoordinateType >( img, center );
// final Cursor< CoordinateType > nc = neighborhood.cursor();
// while ( nc.hasNext() )
// System.out.println( nc.next() );
final Interval span = Intervals.createMinMax( -1, -1, 1, 1 );
final Cursor< Neighborhood< CoordinateType > > n3 = new RectangleNeighborhoodCursor< CoordinateType >( Views.interval( img, Intervals.expand( img, -1 ) ), span, RectangleNeighborhoodSkipCenter.< CoordinateType >factory() );
while ( n3.hasNext() )
{
for ( final CoordinateType t : n3.next() )
System.out.println( t );
System.out.println( "-----" );
}
}
示例15: example2
import net.imglib2.img.ImgFactory; //导入方法依赖的package包/类
public static void example2()
{
final ImgFactory< UnsignedByteType > imgFactory = new ArrayImgFactory< UnsignedByteType >();
Img< UnsignedByteType > image = imgFactory.create( new int[] { DIM, DIM, DIM }, new UnsignedByteType() );
long[] center = new long[ 3 ];
long[] span = new long[ 3 ];
for ( int i = 0; i < DIM; i++ )
{
center[ 0 ] = ( long ) ( Math.random() * DIM );
center[ 1 ] = ( long ) ( Math.random() * DIM );
center[ 2 ] = ( long ) ( Math.random() * DIM );
span[ 0 ] = ( long ) ( Math.random() / 10 * DIM );
span[ 1 ] = ( long ) ( Math.random() / 10 * DIM );
span[ 2 ] = ( long ) ( Math.random() / 10 * DIM );
EllipsoidNeighborhood< UnsignedByteType > ellipsoid = new EllipsoidNeighborhood< UnsignedByteType >( image, center, span );
System.out.println( "Center: " + Util.printCoordinates( center ) );// DEBUG
System.out.println( "Span: " + Util.printCoordinates( span ) );// DEBUG
int val = ( int ) ( Math.random() * 200 );
for ( UnsignedByteType pixel : ellipsoid )
{
pixel.set( val );
// val++;
}
}
ImageJFunctions.show( image );
}