本文整理汇总了Java中net.imglib2.img.basictypeaccess.array.IntArray类的典型用法代码示例。如果您正苦于以下问题:Java IntArray类的具体用法?Java IntArray怎么用?Java IntArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntArray类属于net.imglib2.img.basictypeaccess.array包,在下文中一共展示了IntArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createARGBInstance
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
@SuppressWarnings( "unchecked" )
public static BigWarpImageStackImageLoader< ARGBType, IntArray > createARGBInstance( final ImagePlus imp, int[] ids )
{
return new BigWarpImageStackImageLoader< ARGBType, IntArray >( new ARGBType(), imp, ids )
{
@Override
protected IntArray wrapPixels( final Object array )
{
return new IntArray( ( int[] ) array );
}
@Override
protected void linkType( final PlanarImg< ARGBType, IntArray > img )
{
img.setLinkedType( new ARGBType( img ) );
}
};
}
示例2: createImg
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
private static final Img<?> createImg(final BufferedImage bi) {
final long[] dims = new long[]{bi.getWidth(), bi.getHeight()};
switch (bi.getType()) {
case BufferedImage.TYPE_BYTE_GRAY:
case BufferedImage.TYPE_BYTE_INDEXED:
ByteArray ba = new ByteArray(((DataBufferByte)bi.getRaster().getDataBuffer()).getData());
ArrayImg<UnsignedByteType, ByteArray> b = new ArrayImg<UnsignedByteType, ByteArray>(ba, dims, new Fraction());
b.setLinkedType(new UnsignedByteType(b));
return b;
case BufferedImage.TYPE_USHORT_GRAY:
ShortArray sa = new ShortArray(((DataBufferShort)bi.getRaster().getDataBuffer()).getData());
ArrayImg<UnsignedShortType, ShortArray> s = new ArrayImg<UnsignedShortType, ShortArray>(sa, dims, new Fraction());
s.setLinkedType(new UnsignedShortType(s));
return s;
case BufferedImage.TYPE_INT_RGB:
case BufferedImage.TYPE_INT_ARGB:
IntArray ia = new IntArray(((DataBufferInt)bi.getRaster().getDataBuffer()).getData());
ArrayImg<ARGBType, IntArray> i = new ArrayImg<ARGBType, IntArray>(ia, dims, new Fraction());
i.setLinkedType(new ARGBType(i));
return i;
}
throw new UnsupportedOperationException("Cannot wrap images of type " + bi.getType());
}
示例3: createARGBInstance
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
public static ImageStackImageLoader< ARGBType, IntArray > createARGBInstance( final ImagePlus imp )
{
return new ImageStackImageLoader< ARGBType, IntArray >( new ARGBType(), imp )
{
@Override
protected IntArray wrapPixels( final Object array )
{
return new IntArray( ( int[] ) array );
}
@Override
protected void linkType( final PlanarImg< ARGBType, IntArray > img )
{
img.setLinkedType( new ARGBType( img ) );
}
};
}
示例4: createIntArray
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
private static int[] createIntArray(
final RandomAccessibleInterval<IntType> image)
{
final long[] dims = Intervals.dimensionsAsLongArray(image);
final ArrayImg<IntType, IntArray> dest = ArrayImgs.ints(dims);
copy(image, dest);
return dest.update(null).getCurrentStorageArray();
}
示例5: extractIntArray
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
private static int[] extractIntArray(
final RandomAccessibleInterval<IntType> image)
{
if (!(image instanceof ArrayImg)) return null;
@SuppressWarnings("unchecked")
final ArrayImg<IntType, ?> arrayImg = (ArrayImg<IntType, ?>) image;
final Object dataAccess = arrayImg.update(null);
return dataAccess instanceof IntArray ? //
((IntArray) dataAccess).getCurrentStorageArray() : null;
}
示例6: asImage
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
public static final Img<ARGBType> asImage(final JFreeChart chart, int width, int height) {
final ChartPanel panel = new ChartPanel(chart);
final Dimension d = panel.getPreferredSize();
if (-1 == width && -1 == height) {
width = d.width;
height = d.height;
panel.setSize(d);
} else {
panel.setSize(width, height);
}
layoutComponent(panel);
final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g = bi.createGraphics();
if (!panel.isOpaque()){
g.setColor(panel.getBackground() );
g.fillRect(0, 0, width, height);
}
panel.paint(g);
final int[] pixels = new int[width * height];
final PixelGrabber pg = new PixelGrabber(bi, 0, 0, width, height, pixels, 0, width);
try {
pg.grabPixels();
} catch (final InterruptedException e) {}
g.dispose();
final ArrayImg<ARGBType, IntArray> a = new ArrayImg<ARGBType, IntArray>(new IntArray(pixels), new long[]{width, height}, new Fraction());
// create a Type that is linked to the container
final ARGBType linkedType = new ARGBType( a );
// pass it to the DirectAccessContainer
a.setLinkedType( linkedType );
return a;
}
示例7: multiply
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
@OpMethod(ops = { net.imagej.ops.math.ConstantToArrayImageP.MultiplyInt.class,
net.imagej.ops.math.ConstantToArrayImage.MultiplyInt.class,
net.imagej.ops.math.ConstantToArrayImageP.MultiplyUnsignedInt.class,
net.imagej.ops.math.ConstantToArrayImage.MultiplyUnsignedInt.class })
public <I extends GenericIntType<I>> ArrayImg<I, IntArray> multiply(
final ArrayImg<I, IntArray> image, final int value)
{
@SuppressWarnings("unchecked")
final ArrayImg<I, IntArray> result = (ArrayImg<I, IntArray>) ops().run(
Ops.Math.Multiply.NAME, image, value);
return result;
}
示例8: add
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
@OpMethod(ops = { net.imagej.ops.math.ConstantToPlanarImage.AddInt.class,
net.imagej.ops.math.ConstantToPlanarImage.AddUnsignedInt.class })
public <I extends GenericIntType<I>> PlanarImg<I, IntArray> add(
final PlanarImg<I, IntArray> image, final int value)
{
@SuppressWarnings("unchecked")
final PlanarImg<I, IntArray> result = (PlanarImg<I, IntArray>) ops().run(
Ops.Math.Add.NAME, image, value);
return result;
}
示例9: divide
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
@OpMethod(ops = { net.imagej.ops.math.ConstantToArrayImageP.DivideInt.class,
net.imagej.ops.math.ConstantToArrayImage.DivideInt.class,
net.imagej.ops.math.ConstantToArrayImageP.DivideUnsignedInt.class,
net.imagej.ops.math.ConstantToArrayImage.DivideUnsignedInt.class })
public <I extends GenericIntType<I>> ArrayImg<I, IntArray> divide(
final ArrayImg<I, IntArray> image, final int value)
{
@SuppressWarnings("unchecked")
final ArrayImg<I, IntArray> result = (ArrayImg<I, IntArray>) ops().run(
Ops.Math.Divide.NAME, image, value);
return result;
}
示例10: subtract
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
@OpMethod(ops = { net.imagej.ops.math.ConstantToArrayImageP.SubtractInt.class,
net.imagej.ops.math.ConstantToArrayImage.SubtractInt.class,
net.imagej.ops.math.ConstantToArrayImageP.SubtractUnsignedInt.class,
net.imagej.ops.math.ConstantToArrayImage.SubtractUnsignedInt.class })
public <I extends GenericIntType<I>> ArrayImg<I, IntArray> subtract(
final ArrayImg<I, IntArray> image, final int value)
{
@SuppressWarnings("unchecked")
final ArrayImg<I, IntArray> result = (ArrayImg<I, IntArray>) ops().run(
Ops.Math.Subtract.NAME, image, value);
return result;
}
示例11: createIntInstance
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
@Override
public SCIFIOCellImg<T, IntArray> createIntInstance(
final long[] dimensions, final Fraction entitiesPerPixel)
{
return createInstance(new IntArrayLoader(reader(), subregion), dimensions,
entitiesPerPixel);
}
示例12: main
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
public static void main( final String[] args )
{
new ImageJ();
final double[] coefficients = new double[]{
0, 2, 4, 8,
1, 1, 1, 1,
1, 10, 5, 1,
1, 1, 1, 1,
0, 10, 20, 30,
40, 50, 60, 70,
80, 90, 100, 110,
120, 130, 140, 150
};
final LinearIntensityMap< DoubleType > transform = new LinearIntensityMap< DoubleType >( ArrayImgs.doubles( coefficients, 4, 4, 2 ) );
//final ImagePlus imp = new ImagePlus( "http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png" );
final ImagePlus imp1 = new ImagePlus( "http://fly.mpi-cbg.de/~saalfeld/Pictures/norway.jpg");
final ArrayImg< FloatType, FloatArray > image1 = ArrayImgs.floats( ( float[] )imp1.getProcessor().convertToFloatProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
final ArrayImg< UnsignedByteType, ByteArray > image2 = ArrayImgs.unsignedBytes( ( byte[] )imp1.getProcessor().convertToByteProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
final ArrayImg< UnsignedShortType, ShortArray > image3 = ArrayImgs.unsignedShorts( ( short[] )imp1.getProcessor().convertToShortProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
final ArrayImg< ARGBType, IntArray > image4 = ArrayImgs.argbs( ( int[] )imp1.getProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
ImageJFunctions.show( ArrayImgs.doubles( coefficients, 4, 4, 2 ) );
transform.run( image1 );
transform.run( image2 );
transform.run( image3 );
transform.run( image4 );
ImageJFunctions.show( image1 );
ImageJFunctions.show( image2 );
ImageJFunctions.show( image3 );
ImageJFunctions.show( image4 );
}
示例13: main
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
public static void main( String[] args )
{
final long[] dim = new long[] { 2, 3 };
long[] m = new long[ dim.length ];
long[] M = new long[ dim.length ];
ArrayImg< IntType, IntArray > img = ArrayImgs.ints( dim );
int i = 0;
for ( IntType c : img )
c.set( i++ );
Factory< IntType > factory = ( min1, max1, t1 ) -> {
final long[] dimensions1 = new long[ min1.length ];
for ( int d = 0; d < min1.length; ++d )
dimensions1[ d ] = max1[ d ] - min1[ d ] + 1;
ArrayImg< IntType, IntArray > imgFac = ArrayImgs.ints( dimensions1 );
return Views.translate( imgFac, min1 );
};
Function< long[], long[] > l = ( long[] array ) -> {
long[] result = array.clone();
for ( int k = 0; k < result.length; ++k )
result[ k ] = -result[ k ];
return result;
};
GrowingStoreRandomAccessible< IntType > rra = new GrowingStoreRandomAccessible<>( img, factory );
new ImageJ();
RandomAccess< IntType > ra = rra.randomAccess();
// Bdv bdv = BdvFunctions.show(rra, "1");
IntType f;
ImageJFunctions.show( Views.offsetInterval( rra, rra.getIntervalOfSizeOfStore() ), "1" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( -2, 0 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "2" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( dim[ 1 ], 1 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "3" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( M );
ra.setPosition( 32, 0 );
ra.setPosition( 17, 1 ); // 11 now, was 17 before
long[] pos = new long[ ra.numDimensions() ];
ra.localize( pos );
System.out.println( Arrays.toString( pos ) );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "4" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
// {
// RandomAccess<FloatType> accessToBeCollected = rra.randomAccess();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
// }
// System.gc();
// System.gc();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
}
示例14: main
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
public static void main( String[] args )
{
final long[] dim = new long[] { 2, 3 };
long[] m = new long[ dim.length ];
long[] M = new long[ dim.length ];
ArrayImg< IntType, IntArray > img = ArrayImgs.ints( dim );
int i = 0;
for ( IntType c : img )
c.set( i++ );
// Factory<IntType> factory = (min1, max1, t1) -> {
// final long[] dimensions1 = new long[ min1.length ];
// for (int d = 0; d < min1.length; ++d )
// dimensions1[d] = max1[d] - min1[d] + 1;
// ArrayImg<IntType, IntArray> imgFac = ArrayImgs.ints(dimensions1);
// return Views.translate(imgFac, min1);
// };
SimpleArrayImgFactory< IntType > factory = new SimpleArrayImgFactory< IntType >( new IntType( 0 ) );
Function< long[], long[] > l = ( long[] array ) -> {
long[] result = array.clone();
for ( int k = 0; k < result.length; ++k )
result[ k ] = -result[ k ];
return result;
};
GrowingStoreRandomAccessibleSingletonAccess< IntType > rra = new GrowingStoreRandomAccessibleSingletonAccess<>( img, factory );
new ImageJ();
RandomAccess< IntType > ra = rra.randomAccess();
// Bdv bdv = BdvFunctions.show(rra, "1");
IntType f;
ImageJFunctions.show( Views.offsetInterval( rra, rra.getIntervalOfSizeOfStore() ), "1" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( -2, 0 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "2" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( dim[ 1 ], 1 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "3" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( M );
ra.setPosition( 32, 0 );
ra.setPosition( 17, 1 ); // 11 now, was 17 before
long[] pos = new long[ ra.numDimensions() ];
ra.localize( pos );
System.out.println( Arrays.toString( pos ) );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "4" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
// {
// RandomAccess<FloatType> accessToBeCollected = rra.randomAccess();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
// }
// System.gc();
// System.gc();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
}
示例15: UnsignedIntImage
import net.imglib2.img.basictypeaccess.array.IntArray; //导入依赖的package包/类
public UnsignedIntImage(final long[] dim, final int[] pixels) {
super(new IntArray(pixels), dim, new Fraction());
setLinkedType(new UnsignedIntType(this));
}