本文整理汇总了Java中net.imglib2.Cursor.reset方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.reset方法的具体用法?Java Cursor.reset怎么用?Java Cursor.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.Cursor
的用法示例。
在下文中一共展示了Cursor.reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import net.imglib2.Cursor; //导入方法依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> op,
final RandomAccessibleInterval<T> r)
{
final IterableInterval<T> iterOp = Views.flatIterable(op);
final IterableInterval<T> iterR = Views.flatIterable(r);
long[] dim = new long[r.numDimensions()];
r.dimensions(dim);
Cursor<T> rc = iterR.cursor();
Cursor<T> opc = iterOp.localizingCursor();
// Fill with non background marker
while (rc.hasNext()) {
rc.next().setOne();
}
rc.reset();
boolean border;
// Flood fill from every background border voxel
while (rc.hasNext()) {
rc.next();
opc.next();
if (rc.get().get() && !opc.get().get()) {
border = false;
for (int i = 0; i < r.numDimensions(); i++) {
if (rc.getLongPosition(i) == 0 || rc.getLongPosition(i) == dim[i] -
1)
{
border = true;
break;
}
}
if (border) {
floodFillComp.compute(op, rc, r);
}
}
}
}
示例2: main
import net.imglib2.Cursor; //导入方法依赖的package包/类
static public final void main(String[] arg) {
final String src = "/home/albert/lab/TEM/abd/microvolumes/Seg/180-220-int/180-220-int-00.tif";
try {
final Img<UnsignedByteType> img = new ImgOpener().openImg(src, new ArrayImgFactory<UnsignedByteType>(), new UnsignedByteType());
// copy as short
Img<UnsignedShortType> copyShort = ArrayImgs.unsignedShorts(Intervals.dimensionsAsLongArray(img));
Cursor<UnsignedByteType> c1 = img.cursor();
Cursor<UnsignedShortType> c2 = copyShort.cursor();
while (c1.hasNext()) {
c2.next().setInteger(c1.next().get());
}
// copy as float
Img<FloatType> copyFloat = ArrayImgs.floats(Intervals.dimensionsAsLongArray(img));
c1.reset();
Cursor<FloatType> c3 = copyFloat.cursor();
while (c1.hasNext()) {
c3.next().setReal(c1.next().get());
}
final int nIterations = 5;
// Test as byte
System.out.println("As byte/long: ");
for (int i=0; i < nIterations; ++i) {
test(img, new LongType());
}
System.out.println("As byte/int: ");
for (int i=0; i < nIterations; ++i) {
test(img, new IntType());
}
// Test as short
System.out.println("As short/long: ");
for (int i=0; i < nIterations; ++i) {
test(copyShort, new LongType());
}
System.out.println("As short/int: ");
for (int i=0; i < nIterations; ++i) {
test(copyShort, new LongType());
}
// Test as float
System.out.println("As float/double: ");
for (int i=0; i < nIterations; ++i) {
test(copyFloat, new DoubleType());
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: setToStart
import net.imglib2.Cursor; //导入方法依赖的package包/类
public static void setToStart(final Cursor<?> c, int startIndex) {
c.reset();
c.jumpFwd(startIndex + 1);
}
示例4: compute
import net.imglib2.Cursor; //导入方法依赖的package包/类
@Override
public void compute(final RandomAccessible<I> input,
final RandomAccessibleInterval<O> output)
{
// TODO: try a decomposition of the kernel into n 1-dim kernels
final long[] min = new long[input.numDimensions()];
final long[] max = new long[input.numDimensions()];
for (int d = 0; d < kernel.numDimensions(); d++) {
min[d] = -kernel.dimension(d);
max[d] = kernel.dimension(d) + output.dimension(d);
}
final RandomAccess<I> inRA =
input.randomAccess(new FinalInterval(min, max));
final Cursor<K> kernelC = Views.iterable(kernel).localizingCursor();
final Cursor<O> outC = Views.iterable(output).localizingCursor();
final long[] pos = new long[input.numDimensions()];
final long[] kernelRadius = new long[kernel.numDimensions()];
for (int i = 0; i < kernelRadius.length; i++) {
kernelRadius[i] = kernel.dimension(i) / 2;
}
float val;
while (outC.hasNext()) {
// image
outC.fwd();
outC.localize(pos);
// kernel inlined version of the method convolve
val = 0;
inRA.setPosition(pos);
kernelC.reset();
while (kernelC.hasNext()) {
kernelC.fwd();
for (int i = 0; i < kernelRadius.length; i++) {
// dimension can have zero extension e.g. vertical 1d kernel
if (kernelRadius[i] > 0) {
inRA.setPosition(pos[i] + kernelC.getLongPosition(i) -
kernelRadius[i], i);
}
}
val += inRA.get().getRealDouble() * kernelC.get().getRealDouble();
}
outC.get().setReal(val);
}
}