本文整理汇总了Java中net.imglib2.img.Img.copy方法的典型用法代码示例。如果您正苦于以下问题:Java Img.copy方法的具体用法?Java Img.copy怎么用?Java Img.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.img.Img
的用法示例。
在下文中一共展示了Img.copy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageWithOverlay
import net.imglib2.img.Img; //导入方法依赖的package包/类
Img<T> getImageWithOverlay(Img<T> img, ArrayList<int[]> maskPixels, double outlineValue)
{
Img<T> tmpImage = img.copy();
final RandomAccess< T > r = tmpImage.randomAccess();
int[] currentPosition = new int[2];
for(int i=0;i<maskPixels.size();i++)
{
// Get current position index
currentPosition = maskPixels.get(i);
r.setPosition( (int)currentPosition[0], 0 );
r.setPosition( (int)currentPosition[1], 1 );
final RealType<T> t = r.get();
t.setReal(outlineValue);
}
return tmpImage;
}
示例2: testIIAndIIInplace
import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testIIAndIIInplace() {
final Img<ByteType> first = generateByteArrayTestImg(true, 10, 10);
final Img<ByteType> firstCopy = first.copy();
final Img<ByteType> second = generateByteArrayTestImg(false, 10, 10);
for (final ByteType px : second)
px.set((byte) 1);
final Img<ByteType> secondCopy = second.copy();
final Img<ByteType> secondDiffDims = generateByteArrayTestImg(false, 10, 10,
2);
sub = Inplaces.binary(ops, Ops.Math.Subtract.class, ByteType.class);
final BinaryInplaceOp<? super Img<ByteType>, Img<ByteType>> map = Inplaces
.binary(ops, MapIIAndIIInplace.class, firstCopy, second, sub);
map.run(firstCopy, second, firstCopy);
map.run(first, secondCopy, secondCopy);
assertImgSubEquals(first, second, firstCopy);
assertImgSubEquals(first, second, secondCopy);
// Expect exception when in2 has different dimensions
thrown.expect(IllegalArgumentException.class);
ops.op(MapIIAndIIInplace.class, first, secondDiffDims, sub);
}
示例3: testIIAndIIInplaceParallel
import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testIIAndIIInplaceParallel() {
final Img<ByteType> first = generateByteArrayTestImg(true, 10, 10);
final Img<ByteType> firstCopy = first.copy();
final Img<ByteType> second = generateByteArrayTestImg(false, 10, 10);
for (final ByteType px : second)
px.set((byte) 1);
final Img<ByteType> secondCopy = second.copy();
final Img<ByteType> secondDiffDims = generateByteArrayTestImg(false, 10, 10,
2);
sub = Inplaces.binary(ops, Ops.Math.Subtract.class, ByteType.class);
final BinaryInplaceOp<? super Img<ByteType>, Img<ByteType>> map = Inplaces
.binary(ops, MapIIAndIIInplaceParallel.class, firstCopy, second, sub);
map.run(firstCopy, second, firstCopy);
map.run(first, secondCopy, secondCopy);
assertImgSubEquals(first, second, firstCopy);
assertImgSubEquals(first, second, secondCopy);
// Expect exception when in2 has different dimensions
thrown.expect(IllegalArgumentException.class);
ops.op(MapIIAndIIInplaceParallel.class, first, secondDiffDims, sub);
}
示例4: testIIAndIIInplaceParallelCellImg
import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testIIAndIIInplaceParallelCellImg() {
final Img<ByteType> first = generateByteTestCellImg(true, 40, 20);
final Img<ByteType> firstCopy = first.copy();
final Img<ByteType> second = generateByteTestCellImg(false, 40, 20);
for (final ByteType px : second)
px.set((byte) 1);
final Img<ByteType> secondCopy = second.copy();
sub = Inplaces.binary(ops, Ops.Math.Subtract.class, ByteType.class);
final BinaryInplaceOp<? super Img<ByteType>, Img<ByteType>> map = Inplaces
.binary(ops, MapIIAndIIInplaceParallel.class, firstCopy, second, sub);
map.run(firstCopy, second, firstCopy);
map.run(first, secondCopy, secondCopy);
assertImgSubEquals(first, second, firstCopy);
assertImgSubEquals(first, second, secondCopy);
}
示例5: testIIInplaceParallel
import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testIIInplaceParallel() {
final Img<ByteType> arg = generateByteArrayTestImg(true, 10, 10);
final Img<ByteType> argCopy = arg.copy();
sub = Inplaces.unary(ops, Ops.Math.Subtract.class, ByteType.class,
new ByteType((byte) 1));
ops.run(MapIIInplaceParallel.class, argCopy, sub);
assertImgSubOneEquals(arg, argCopy);
}
示例6: testIterableInplace
import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testIterableInplace() {
final Img<ByteType> arg = generateByteArrayTestImg(true, 10, 10);
final Img<ByteType> argCopy = arg.copy();
sub = Inplaces.unary(ops, Ops.Math.Subtract.class, ByteType.class,
new ByteType((byte) 1));
ops.run(MapIterableInplace.class, argCopy, sub);
assertImgSubOneEquals(arg, argCopy);
}
示例7: testIIInplaceParallelCellImg
import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testIIInplaceParallelCellImg() {
final Img<ByteType> arg = generateByteTestCellImg(true, 40, 20);
final Img<ByteType> argCopy = arg.copy();
sub = Inplaces.unary(ops, Ops.Math.Subtract.class, ByteType.class,
new ByteType((byte) 1));
ops.run(MapIIInplaceParallel.class, argCopy, sub);
assertImgSubOneEquals(arg, argCopy);
}
示例8: MgdmDecomposition
import net.imglib2.img.Img; //导入方法依赖的package包/类
/**
* Constructor for a Mgdm decomposition
*
* @param segvol initial segmentation
* @param nmgdm the number of MGDM distance functions to store
* @param maskIn a mask outside of which MGDM computations will not be performed
*/
public MgdmDecomposition(Img<L> segvol, int nmgdm, Img<L> maskvol){
segmentation = segvol.copy();
// reshape and set the mask
if(maskvol!=null){
mask = maskvol.copy();
}
this.nmgdm=nmgdm;
fastMarchingInitializationFromSegmentation( );
}
示例9: main
import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T> & NativeType< T >> void main(String[] args) throws ImgIOException, IncompatibleTypeException {
// Open file in imglib2
// File file = new File( "E:/Users/JeanYves/Desktop/Data/Y.tif");
File file = new File( "/Users/tinevez/Desktop/Data/sYn.tif");
// File file = new File( "/Users/tinevez/Desktop/Data/StarryNight.tif");
// File file = new File( "/Users/tinevez/Desktop/Data/cross2.tif");
ImgFactory< ? > imgFactory = new ArrayImgFactory< T >();
Img< T > image = (Img< T >) new ImgOpener().openImg( file.getAbsolutePath(), imgFactory );
Img<T> copy = image.copy();
// Display it via ImgLib using ImageJ
new ImageJ();
// Compute tensor
MomentOfInertiaTensor2D<T> tensor = new MomentOfInertiaTensor2D<T>(image, 9);
// CoherenceEnhancingDiffusionTensor2D<T> tensor = new CoherenceEnhancingDiffusionTensor2D<T>(image);
tensor.process();
Img<FloatType> diffusionTensor = tensor.getResult();
ImagePlus imp = ImageJFunctions.wrap(image, "source");
imp.show();
// Instantiate diffusion solver
NonNegativityDiffusionScheme2D<T> algo = new NonNegativityDiffusionScheme2D<T>(image, diffusionTensor);
// StandardDiffusionScheme2D<T> algo = new StandardDiffusionScheme2D<T>(image, diffusionTensor);
for (int i = 0; i < 20; i++) {
System.out.println("Iteration "+i);
// tensor.process();
// diffusionTensor = tensor.getResult();
// algo.setDiffusionTensor(diffusionTensor);
algo.process();
imp.getProcessor().setPixels(ImageJFunctions.wrap(image, "result").getProcessor().getPixelsCopy());
imp.updateAndDraw();
}
// ImageJFunctions.show(algo.getIncrement());
ImageJFunctions.show(diffusionTensor);
ImageJFunctions.show(copy);
}
示例10: main
import net.imglib2.img.Img; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
Img<UnsignedByteType> image = createExampleImage(new UnsignedByteType());
Img<UnsignedByteType> copy = image.copy();
// Display it via ImgLib using ImageJ
ImageJ.main(args);
// Compute tensor
MomentOfInertiaTensor3D tensor = new MomentOfInertiaTensor3D(image, 5);
// long[] dimensions = new long[image.numDimensions()];
// image.dimensions(dimensions);
// IsotropicDiffusionTensor tensor = new IsotropicDiffusionTensor(dimensions , 1);
tensor.process();
Img<FloatType> diffusionTensor = tensor.getResult();
ImagePlus imp = ImageJFunctions.wrap(image, "Processed");
imp.show();
imp.getWindow().setLocation(100, 500);
// Instantiate diffusion solver
// StandardDiffusionScheme3D algo = new StandardDiffusionScheme3D(image, diffusionTensor);
NonNegativityDiffusionScheme3D algo = new NonNegativityDiffusionScheme3D(image, diffusionTensor);
for (int i = 0; i < 1; i++) {
System.out.println("Iteration "+(i+1));
// tensor.process();
// diffusionTensor = tensor.getResult();
// algo.setDiffusionTensor(diffusionTensor);
algo.process();
imp.updateAndDraw();
}
ImagePlus inc = ImageJFunctions.wrap(algo.getIncrement(), "Increment");
inc.show();
ImageWindow incWin = inc.getWindow();
incWin.setLocation(500, 500);
inc.setSlice(inc.getStackSize()/2+1);
// ImageJFunctions.wrapFloat(diffusionTensor, "Diffusion tensor").show();
for (int i = 0; i < 6; i++) {
ImagePlus diffimp = ImageJFunctions.wrap(Views.hyperSlice(diffusionTensor, 3, i), "DT_"+i);
diffimp.show();
ImageWindow win = diffimp.getWindow();
win.setLocation(300 * (3 - ( i % 3) ), 300 * ( i/3 ));
diffimp.setSlice(diffimp.getStackSize()/2+1);
}
ImageJFunctions.show(copy, "Original image");
}
示例11: main
import net.imglib2.img.Img; //导入方法依赖的package包/类
public static void main( final String[] args ) throws ImgIOException
{
ImageJ.main( args );
final File file = new File( "DrosophilaWing.tif" );
final SCIFIOImgPlus img = new ImgOpener().openImgs( file.getAbsolutePath() ).get( 0 );
final Img< UnsignedByteType > imgInv = img.copy();
final Cursor< UnsignedByteType > cursor = img.cursor();
final Cursor< UnsignedByteType > cursor2 = imgInv.cursor();
while ( cursor.hasNext() )
{
cursor.fwd();
cursor2.fwd();
cursor2.get().set( 255 - cursor.get().get() );
}
final Shape strel = new HyperSphereShape( 5 );
/*
* To new Img
*/
ImageJFunctions.show( imgInv, "Source" );
final Img blackTopHat = BlackTopHat.blackTopHat( imgInv, strel, 1 );
ImageJFunctions.show( blackTopHat, "BlackTopHatToNewImg" );
/*
* In place
*/
final Interval interval = FinalInterval.createMinSize( new long[] { 7, 35, 88, 32 } );
final Img copy2 = imgInv.copy();
BlackTopHat.blackTopHatInPlace( copy2, interval, strel, 1 );
ImageJFunctions.show( copy2, "BlackTopHatInPlace" );
/*
* To target
*/
final Img img2 = img.factory().create( interval, new UnsignedByteType() );
final long[] translation = new long[ interval.numDimensions() ];
interval.min( translation );
final IntervalView translate = Views.translate( img2, translation );
BlackTopHat.blackTopHat( imgInv, translate, strel, 1 );
ImageJFunctions.show( img2, "BlackTopHatToTarget" );
}