本文整理汇总了Java中net.imglib2.Cursor.fwd方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.fwd方法的具体用法?Java Cursor.fwd怎么用?Java Cursor.fwd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.Cursor
的用法示例。
在下文中一共展示了Cursor.fwd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import net.imglib2.Cursor; //导入方法依赖的package包/类
public static void main( String[] args )
{
new ImageJ();
Img< FloatType > img = ArrayImgs.floats( 500, 500 );
BlendingRealRandomAccess blend = new BlendingRealRandomAccess(
img,
new float[]{ 100, 0 },
new float[]{ 12, 150 } );
Cursor< FloatType > c = img.localizingCursor();
while ( c.hasNext() )
{
c.fwd();
blend.setPosition( c );
c.get().setReal( blend.get().getRealFloat() );
}
ImageJFunctions.show( img );
}
示例2: convertToGenericTexture
import net.imglib2.Cursor; //导入方法依赖的package包/类
public static GenericTexture convertToGenericTexture( Dataset d ) {
long width = d.getWidth();
long height = d.getHeight();
GLVector dims = new GLVector( width, height, 1 );
int nChannels = 3;
ByteBuffer bb = BufferUtils.BufferUtils.allocateByte((int) (width * height * nChannels));
System.out.println("Size:" + width + " " + height + " " + nChannels);
Cursor cur = d.cursor();
while( cur.hasNext() ) {
cur.fwd();
int val = ((UnsignedByteType) cur.get()).get();
//System.out.println( (byte)val );
bb.put( (byte) val );
//bb.put((byte)(Math.random()*255));
}
bb.flip();
return new GenericTexture("neverUsed", dims, nChannels, GLTypeEnum.UnsignedByte, bb, true, true, false);
}
示例3: compute
import net.imglib2.Cursor; //导入方法依赖的package包/类
@Override
public void compute(final IterableInterval<I> input, final O output) {
final double moment00 = moment00Func.calculate(input).getRealDouble();
final double moment01 = moment01Func.calculate(input).getRealDouble();
final double centerY = moment01 / moment00;
double centralmoment03 = 0;
final Cursor<I> it = input.localizingCursor();
while (it.hasNext()) {
it.fwd();
final double y = it.getDoublePosition(1) - centerY;
final double val = it.get().getRealDouble();
centralmoment03 += val * y * y * y;
}
output.setReal(centralmoment03);
}
示例4: copyImgNoOutputTest
import net.imglib2.Cursor; //导入方法依赖的package包/类
@Test
public void copyImgNoOutputTest() {
final Img<DoubleType> inputCopy = input.factory().create(input, input
.firstElement());
copy(input, inputCopy);
@SuppressWarnings("unchecked")
final RandomAccessibleInterval<DoubleType> output =
(RandomAccessibleInterval<DoubleType>) ops.run(CopyImg.class, input);
final Cursor<DoubleType> inc = input.localizingCursor();
final RandomAccess<DoubleType> inCopyRA = inputCopy.randomAccess();
final RandomAccess<DoubleType> outRA = output.randomAccess();
while (inc.hasNext()) {
inc.fwd();
inCopyRA.setPosition(inc);
outRA.setPosition(inc);
assertEquals(inc.get().get(), outRA.get().get(), 0.0);
assertEquals(inc.get().get(), inCopyRA.get().get(), 0.0);
}
}
示例5: testMean
import net.imglib2.Cursor; //导入方法依赖的package包/类
@Test
public void testMean() {
final Img<ByteType> image = generateByteArrayTestImg(true, 40, 50);
final DoubleType mean = new DoubleType();
ops.run(IterableMean.class, mean, image);
assertEquals(1.0 / 15.625, mean.get(), 0.0);
Cursor<ByteType> c = image.cursor();
// this time lets just make every value 100
while (c.hasNext()) {
c.fwd();
c.get().setReal(100.0);
}
ops.run(IterableMean.class, mean, image);
// the mean should be 100
assertEquals(100.0, mean.get(), 0.0);
}
示例6: compute
import net.imglib2.Cursor; //导入方法依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> input,
final IterableInterval<V> output)
{
final Cursor<V> cursor = output.localizingCursor();
final RandomAccess<T> access = input.randomAccess();
while (cursor.hasNext()) {
cursor.fwd();
for (int d = 0; d < input.numDimensions(); d++) {
if (d != dim) {
access.setPosition(cursor.getIntPosition(d - (d > dim ? -1 : 0)), d);
}
}
method.compute(new DimensionIterable(input.dimension(dim), access),
cursor.get());
}
}
示例7: getImageMin
import net.imglib2.Cursor; //导入方法依赖的package包/类
/**
* Calculates the min of an image.
*
* @param img The image to calculate the min of
* @return The min of the image passed
*/
final public static <T extends Type<T> & Comparable<T>> T getImageMin(
final RandomAccessibleInterval<T> img )
{
final Cursor<T> cursor = Views.iterable(img).cursor();
cursor.fwd();
// copy first element as current maximum
final T min = cursor.get().copy();
while ( cursor.hasNext() )
{
cursor.fwd();
final T currValue = cursor.get();
if ( currValue.compareTo( min ) < 0 )
min.set( currValue );
}
return min;
}
示例8: copyToFloatImagePlus
import net.imglib2.Cursor; //导入方法依赖的package包/类
/** Copy the contents from img to an ImagePlus; assumes containers are compatible. */
static public ImagePlus copyToFloatImagePlus(final Img<? extends RealType<?>> img, final String title) {
ImagePlusImgFactory<FloatType> factory = new ImagePlusImgFactory<FloatType>();
ImagePlusImg<FloatType, ?> iml = factory.create(img, new FloatType());
Cursor<FloatType> c1 = iml.cursor();
Cursor<? extends RealType<?>> c2 = img.cursor();
while (c1.hasNext()) {
c1.fwd();
c2.fwd();
c1.get().set(c2.get().getRealFloat());
}
try {
ImagePlus imp = iml.getImagePlus();
imp.setTitle(title);
return imp;
} catch (ImgLibException e) {
e.printStackTrace();
return null;
}
}
示例9: testIntegralHistogram2d
import net.imglib2.Cursor; //导入方法依赖的package包/类
@Test
public <R extends IntegerType<R> & NativeType<R>> void testIntegralHistogram2d() {
// Create a 2d image with values 0-9 in every dimension, so bottom right is 81.
Img<UnsignedByteType> img =
new UnsignedByteType().createSuitableNativeImg(
new ArrayImgFactory<UnsignedByteType>(),
new long[]{10, 10});
long[] p = new long[2];
Cursor<UnsignedByteType> c = img.cursor();
while (c.hasNext()) {
c.fwd();
c.localize(p);
c.get().setInteger(p[0] * p[1]);
}
// Create integral histogram with 10 bins
LinearHistogram<UnsignedByteType> lh = new LinearHistogram<UnsignedByteType>(10, 2, new UnsignedByteType(0), new UnsignedByteType(81));
Img<R> ih = IntegralHistogram.create(img, lh);
new ImageJ();
try {
ImgLib.wrap((Img)ih, "histogram").show();
} catch (ImgLibException e) {
e.printStackTrace();
}
}
示例10: upsample
import net.imglib2.Cursor; //导入方法依赖的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;
}
示例11: copy
import net.imglib2.Cursor; //导入方法依赖的package包/类
private static <T extends RealType<T>> void copy(
final RandomAccessibleInterval<T> source,
final IterableInterval<T> dest)
{
final RandomAccess<T> sourceAccess = source.randomAccess();
final Cursor<T> destCursor = dest.localizingCursor();
while (destCursor.hasNext()) {
destCursor.fwd();
sourceAccess.setPosition(destCursor);
destCursor.get().set(sourceAccess.get());
}
}
示例12: copyRealImage
import net.imglib2.Cursor; //导入方法依赖的package包/类
public static <T extends RealType<T>, S extends RealType<S>> void copyRealImage(IterableInterval<T> source, RandomAccessibleInterval<S> dest) {
RandomAccess<S> destRA = dest.randomAccess();
Cursor<T> srcC = source.cursor();
while (srcC.hasNext()){
srcC.fwd();
destRA.setPosition(srcC);
destRA.get().setReal(srcC.get().getRealDouble());
}
}
示例13: map
import net.imglib2.Cursor; //导入方法依赖的package包/类
public static <I1, I2, O> void map(final IterableInterval<I1> a,
final RandomAccessibleInterval<I2> b, final IterableInterval<O> c,
final BinaryComputerOp<I1, I2, O> op)
{
final Cursor<I1> aCursor = a.localizingCursor();
final RandomAccess<I2> bAccess = b.randomAccess();
final Cursor<O> cCursor = c.cursor();
while (aCursor.hasNext()) {
aCursor.fwd();
bAccess.setPosition(aCursor);
op.compute(aCursor.get(), bAccess.get(), cCursor.next());
}
}
示例14: testIntegralCursor
import net.imglib2.Cursor; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testIntegralCursor() {
Shape rectangleShape = new RectangleShape(1, false);
IterableInterval<Neighborhood<ByteType>> ii = rectangleShape
.neighborhoodsSafe(img);
Cursor<Neighborhood<ByteType>> cursor = ii.cursor();
// Manually select the neighborhood that is centered on the image
cursor.fwd();
cursor.fwd();
cursor.fwd();
cursor.fwd();
cursor.fwd();
IntegralCursor<ByteType> integralCursor = new IntegralCursor<>(
(RectangleNeighborhood) cursor.get());
assertEquals(integralCursor.next(), new ByteType((byte) 1));
assertEquals(integralCursor.next(), new ByteType((byte) 2));
assertEquals(integralCursor.next(), new ByteType((byte) 5));
assertEquals(integralCursor.next(), new ByteType((byte) 4));
assertFalse(integralCursor.hasNext());
integralCursor.reset();
assertEquals(integralCursor.next(), new ByteType((byte) 1));
assertEquals(integralCursor.next(), new ByteType((byte) 2));
assertEquals(integralCursor.next(), new ByteType((byte) 5));
assertEquals(integralCursor.next(), new ByteType((byte) 4));
assertFalse(integralCursor.hasNext());
}
示例15: copyInto
import net.imglib2.Cursor; //导入方法依赖的package包/类
public static < A extends RealType<A>, B extends RealType<B>> void copyInto(
RandomAccessible<A> src,
IterableInterval<B> dest)
{
Cursor<B> c_dest = dest.cursor();
RandomAccess<A> ra = src.randomAccess();
while(c_dest.hasNext()){
c_dest.fwd();
ra.setPosition(c_dest);
c_dest.get().setReal( ra.get().getRealDouble() );
// System.out.println(" ra.get: " + ra.get());
}
}