本文整理汇总了Java中net.imglib2.img.basictypeaccess.array.ByteArray类的典型用法代码示例。如果您正苦于以下问题:Java ByteArray类的具体用法?Java ByteArray怎么用?Java ByteArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArray类属于net.imglib2.img.basictypeaccess.array包,在下文中一共展示了ByteArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: click
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
@Override
public void click( final int x, final int y )
{
if ( filledPixelsOverlay.visible() )
{
synchronized ( viewer )
{
viewer.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
final Point p = new Point( x, y );
final ArrayImg< ByteType, ByteArray > img = wrapBufferedImage( filledPixelsOverlay.img );
final ByteType extension = new ByteType( ( byte ) 1 );
final long t0 = System.currentTimeMillis();
final ArrayRandomAccess< ByteType > ra = img.randomAccess();
ra.setPosition( p );
FloodFill.fill( Views.extendValue( img, extension ), Views.extendValue( img, extension ), p, extension.copy(), extension.copy(), new DiamondShape( 1 ), filter );
final long t1 = System.currentTimeMillis();
System.out.println( "Filling took " + ( t1 - t0 ) + " ms" );
viewer.setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );
viewer.getDisplay().repaint();
}
}
}
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:27,代码来源:DrawProjectAndIntersectController.java
示例2: createUnsignedByteInstance
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
@SuppressWarnings( "unchecked" )
public static BigWarpImageStackImageLoader< UnsignedByteType, ByteArray > createUnsignedByteInstance( final ImagePlus imp, int[] ids )
{
return new BigWarpImageStackImageLoader< UnsignedByteType, ByteArray >( new UnsignedByteType(), imp, ids )
{
@Override
protected ByteArray wrapPixels( final Object array )
{
return new ByteArray( ( byte[] ) array );
}
@Override
protected void linkType( final PlanarImg< UnsignedByteType, ByteArray > img )
{
img.setLinkedType( new UnsignedByteType( img ) );
}
};
}
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:19,代码来源:BigWarpImageStackImageLoader.java
示例3: createImg
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的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());
}
开发者ID:imglib,项目名称:imglib2-script,代码行数:24,代码来源:BufferedImageImg.java
示例4: createCellImage
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
private CellImg<UnsignedByteType, ByteArray> createCellImage() {
final UnsignedByteType type = new UnsignedByteType();
final int cellSize = ( int ) Math.pow( Integer.MAX_VALUE / type.getEntitiesPerPixel().getRatio(), 1.0 / numDimensions );
// test whether there were rounding errors and cellSize is actually too big
long t = 1;
for ( int d = 0; d < numDimensions; ++d )
t *= cellSize;
t *= type.getEntitiesPerPixel().getNumerator();
t /= type.getEntitiesPerPixel().getDenominator();
if ( t > Integer.MAX_VALUE )
throw new RuntimeException( "there were rounding errors and cellSize is actually too big" );
@SuppressWarnings( "unchecked" )
final
CellImg<UnsignedByteType, ByteArray> cellContainer = ( CellImg<UnsignedByteType, ByteArray> ) createImage( dimensions, new CellImgFactory< UnsignedByteType >( cellSize ) );
return cellContainer;
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:19,代码来源:ImglibBenchmark.java
示例5: main0
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public static void main0( final String[] args )
{
ImageJ.main( args );
final ArrayImg< UnsignedByteType, ByteArray > img = ArrayImgs.unsignedBytes( 19, 19, 19 );
final ArrayRandomAccess< UnsignedByteType > ra = img.randomAccess();
ra.setPosition( new long[] { 9, 9, 9 } );
ra.get().set( 255 );
final int[] radiuses = new int[] { 2, 3, 5 };
for ( final int radius : radiuses )
{
final List< Shape > strelStd = StructuringElements.diamond( radius, img.numDimensions(), false );
final Img< UnsignedByteType > std = Dilation.dilate( img, strelStd, 1 );
final List< Shape > strelOpt = StructuringElements.diamond( radius, img.numDimensions(), true );
final Img< UnsignedByteType > opt = Dilation.dilate( img, strelOpt, 1 );
ImageJFunctions.show( std, "Std " + radius );
ImageJFunctions.show( opt, "Opt " + radius );
}
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:21,代码来源:DiamondNeighborhoodTest.java
示例6: openAndClose
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public static void openAndClose() {
final ArrayImg<UnsignedByteType, ByteArray> img = ArrayImgs.unsignedBytes(new long[] { 50, 50 });
final Random ran = new Random();
for (final UnsignedByteType pixel : img) {
if (ran.nextDouble() > 0.95)
pixel.set(255);
}
final Shape strel = new HyperSphereShape(3);
final Img< UnsignedByteType > open = Opening.open( img, strel, 4 );
final Img< UnsignedByteType > closed = Closing.close( img, strel, 4 );
new ImageJ();
ImageJFunctions.show(img);
ImageJFunctions.show(open);
ImageJFunctions.show(closed);
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:18,代码来源:MorphologyOperationsTest.java
示例7: standardErode
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public static void standardErode() {
final ArrayImg<UnsignedByteType, ByteArray> img = ArrayImgs.unsignedBytes(new long[] { 10, 9 });
for (final UnsignedByteType pixel : img) {
pixel.set(255);
}
final ArrayRandomAccess<UnsignedByteType> ra = img.randomAccess();
ra.setPosition(new int[] { 1, 4 });
ra.get().set(0);
final Shape strel = new CenteredRectangleShape(new int[] { 3, 2 }, false);
// final Shape strel = new HyperSphereShape(radius)
final Img< UnsignedByteType > full = Erosion.erodeFull( img, strel, 4 );
final Img< UnsignedByteType > std = Erosion.erode( img, strel, 4 );
new ImageJ();
ImageJFunctions.show(img);
ImageJFunctions.show(full);
ImageJFunctions.show(std);
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:20,代码来源:MorphologyOperationsTest.java
示例8: standardDilate
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public static void standardDilate() {
final ArrayImg<UnsignedByteType, ByteArray> img = ArrayImgs.unsignedBytes(new long[] { 3, 9 });
final ArrayRandomAccess<UnsignedByteType> ra = img.randomAccess();
ra.setPosition(new int[] { 1, 4 });
ra.get().set(255);
final Shape strel = new CenteredRectangleShape(new int[] { 5, 2 }, true);
// final Shape strel = new HyperSphereShape(radius)
final Img< UnsignedByteType > full = Dilation.dilateFull( img, strel, new UnsignedByteType( 0 ), 4 );
final Img< UnsignedByteType > std = Dilation.dilate( img, strel, new UnsignedByteType( 0 ), 4 );
new ImageJ();
ImageJFunctions.show(img);
ImageJFunctions.show(full);
ImageJFunctions.show(std);
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:17,代码来源:MorphologyOperationsTest.java
示例9: generateKnownByteArrayTestImgLarge
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public ArrayImg<ByteType, ByteArray> generateKnownByteArrayTestImgLarge() {
final long[] dims = new long[] { 3, 3 };
final byte[] array = new byte[9];
array[0] = (byte) 40;
array[1] = (byte) 40;
array[2] = (byte) 20;
array[3] = (byte) 40;
array[4] = (byte) 40;
array[5] = (byte) 20;
array[6] = (byte) 20;
array[7] = (byte) 20;
array[8] = (byte) 100;
return ArrayImgs.bytes(array, dims);
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:LocalThresholdTest.java
示例10: getConstantUnsignedByteImg
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
/**
* @param dim a long array with the desired dimensions of the image
* @param constValue constant image value
* @return an {@link Img} of {@link UnsignedByteType} filled with a constant
* value.
*/
public Img<UnsignedByteType> getConstantUnsignedByteImg(final long[] dim,
final int constValue)
{
final ArrayImg<UnsignedByteType, ByteArray> img = ArrayImgs.unsignedBytes(
dim);
final UnsignedByteType type = img.firstElement();
if (constValue < type.getMinValue() || constValue >= type.getMaxValue()) {
throw new IllegalArgumentException("Can't create image for constant [" +
constValue + "]");
}
final ArrayCursor<UnsignedByteType> cursor = img.cursor();
while (cursor.hasNext()) {
cursor.next().set(constValue);
}
return img;
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:26,代码来源:AbstractFeatureTest.java
示例11: testXYZCropping
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
private void testXYZCropping(int t) {
Img<ByteType> inSequence = ArrayImgs.bytes(20, 20, 21, t);
ArrayImg<ByteType, ByteArray> outSequence = ArrayImgs.bytes(20, 20, 21, t);
// fill array img with values (plane position = value in px);
for (final Cursor<ByteType> cur = inSequence.cursor(); cur.hasNext();) {
cur.fwd();
cur.get().set((byte) cur.getIntPosition(2));
}
// selected interval XYZ
final int[] xyAxis = new int[] { 0, 1, 2 };
ops.run(SliceRAI2RAI.class, outSequence, inSequence, new DummyOp(), xyAxis);
for (final Cursor<ByteType> cur = outSequence.cursor(); cur.hasNext();) {
cur.fwd();
assertEquals(cur.getIntPosition(2), cur.get().getRealDouble(), 0);
}
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:22,代码来源:SliceTest.java
示例12: generateKnownByteArrayTestImg
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public ArrayImg<ByteType, ByteArray> generateKnownByteArrayTestImg() {
final long[] dims = new long[] { 3, 3 };
final byte[] array = new byte[9];
array[0] = (byte) 4;
array[1] = (byte) 4;
array[2] = (byte) 2;
array[3] = (byte) 4;
array[4] = (byte) 4;
array[5] = (byte) 2;
array[6] = (byte) 2;
array[7] = (byte) 2;
array[8] = (byte) 6;
return ArrayImgs.bytes(array, dims);
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:SquareIntegralImgTest.java
示例13: generateKnownByteArrayTestImg
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public ArrayImg<ByteType, ByteArray> generateKnownByteArrayTestImg() {
final long[] dims = new long[] { 3, 3 };
final byte[] array = new byte[9];
array[0] = (byte) 1;
array[1] = (byte) 2;
array[2] = (byte) 3;
array[3] = (byte) 4;
array[4] = (byte) 5;
array[5] = (byte) 6;
array[6] = (byte) 7;
array[7] = (byte) 8;
array[8] = (byte) 9;
return ArrayImgs.bytes(array, dims);
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:IntegralCursorTest.java
示例14: createUnsignedByteInstance
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
public static ImageStackImageLoader< UnsignedByteType, ByteArray > createUnsignedByteInstance( final ImagePlus imp )
{
return new ImageStackImageLoader< UnsignedByteType, ByteArray >( new UnsignedByteType(), imp )
{
@Override
protected ByteArray wrapPixels( final Object array )
{
return new ByteArray( ( byte[] ) array );
}
@Override
protected void linkType( final PlanarImg< UnsignedByteType, ByteArray > img )
{
img.setLinkedType( new UnsignedByteType( img ) );
}
};
}
开发者ID:bigdataviewer,项目名称:bigdataviewer_fiji,代码行数:18,代码来源:ImageStackImageLoader.java
示例15: testCacheAllToggle
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
@Test
public void testCacheAllToggle() throws FormatException, IOException {
final SCIFIOCellCache<ByteArray> cache1 = makeCache(128l * 128l);
final SCIFIOCell<ByteArray> cell =
cache1.load(0, new int[] { 128, 128 }, new long[] { 0l, 0l });
// Enable caching non-dirty data
cs.cacheAll(true);
// Should be able to cache even though the cell isn't dirty
assertEquals(CacheResult.SUCCESS, cs.cache(cache1.toString(), 0, cell));
// Verify the cell was cached
assertEquals(cell, cs.retrieve(cache1.toString(), 0));
enableCells(false, cell);
}
开发者ID:scifio,项目名称:scifio,代码行数:18,代码来源:CacheServiceTest.java
示例16: testEnabledToggle
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
@Test
public void testEnabledToggle() throws FormatException, IOException {
final SCIFIOCellCache<ByteArray> cache1 = makeCache(128l * 128l);
final SCIFIOCell<ByteArray> cell =
cache1.load(0, new int[] { 128, 128 }, new long[] { 0l, 0l });
cs.cacheAll(true);
cs.enable(false);
// Caching should be disabled
assertEquals(CacheResult.CACHE_DISABLED, cs.cache(cache1.toString(), 0,
cell));
// Verify the cell wasn't cached
assertNull(cs.retrieve(cache1.toString(), 0));
// Re-enable the cache
cs.enable(true);
assertEquals(CacheResult.SUCCESS, cs.cache(cache1.toString(), 0, cell));
// Verify the cell was cached
assertEquals(cell, cs.retrieve(cache1.toString(), 0));
enableCells(false, cell);
}
开发者ID:scifio,项目名称:scifio,代码行数:26,代码来源:CacheServiceTest.java
示例17: createByteArray
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
private static byte[] createByteArray(
final RandomAccessibleInterval<ByteType> image)
{
final long[] dims = Intervals.dimensionsAsLongArray(image);
final ArrayImg<ByteType, ByteArray> dest = ArrayImgs.bytes(dims);
copy(image, dest);
return dest.update(null).getCurrentStorageArray();
}
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:9,代码来源:Tensors.java
示例18: extractByteArray
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
private static byte[] extractByteArray(
final RandomAccessibleInterval<ByteType> image)
{
if (!(image instanceof ArrayImg)) return null;
@SuppressWarnings("unchecked")
final ArrayImg<ByteType, ?> arrayImg = (ArrayImg<ByteType, ?>) image;
final Object dataAccess = arrayImg.update(null);
return dataAccess instanceof ByteArray ? //
((ByteArray) dataAccess).getCurrentStorageArray() : null;
}
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:11,代码来源:Tensors.java
示例19: createArrayImage
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
private Img<UnsignedByteType> createArrayImage(final byte[] data,
final int w, final int h)
{
// return createImage(data, width, height, new ArrayContainerFactory());
// NB: Avoid copying the data.
final ByteArray byteAccess = new ByteArray(data);
final ArrayImg<UnsignedByteType, ByteArray> array =
new ArrayImg<UnsignedByteType, ByteArray>(byteAccess,
new long[] { w, h }, new Fraction());
array.setLinkedType(new UnsignedByteType(array));
return array;
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:13,代码来源:PerformanceBenchmark.java
示例20: createPlanarImage
import net.imglib2.img.basictypeaccess.array.ByteArray; //导入依赖的package包/类
private Img<UnsignedByteType> createPlanarImage(final byte[] data,
final int w, final int h)
{
// return createImage(data, width, height, new PlanarContainerFactory());
// NB: Avoid copying the data.
final PlanarImg<UnsignedByteType, ByteArray> planarContainer =
new PlanarImg<UnsignedByteType, ByteArray>(new long[] { w, h }, new Fraction());
planarContainer.setPlane(0, new ByteArray(data));
planarContainer.setLinkedType(new UnsignedByteType(planarContainer));
return planarContainer;
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:12,代码来源:PerformanceBenchmark.java
注:本文中的net.imglib2.img.basictypeaccess.array.ByteArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论