本文整理汇总了Java中net.imglib2.util.RealSum类的典型用法代码示例。如果您正苦于以下问题:Java RealSum类的具体用法?Java RealSum怎么用?Java RealSum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RealSum类属于net.imglib2.util包,在下文中一共展示了RealSum类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getMean
点赞 3
import net.imglib2.util.RealSum; //导入依赖的package包/类
public <T extends RealType<T>> T getMean(IterableInterval< T > img)
{
RealSum sum = new RealSum();
long nPix = 0;
for (T t : img)
{
sum.add( t.getRealDouble() );
nPix++;
}
T res = img.firstElement().createVariable();
res.setReal( sum.getSum()/nPix );
return res;
}
开发者ID:PreibischLab,
项目名称:BigStitcher,
代码行数:17,
代码来源:BrightestViewSelection.java
示例2: average
点赞 3
import net.imglib2.util.RealSum; //导入依赖的package包/类
private static final double[] average( final List< InterestPoint > list )
{
final int n = list.get( 0 ).getL().length;
final RealSum[] sum = new RealSum[ n ];
for ( int d = 0; d < n; ++d )
sum[ d ] = new RealSum();
for ( final InterestPoint i : list )
{
final double[] l = i.getL();
for ( int d = 0; d < n; ++d )
sum[ d ].add( l[ d ] );
}
final double[] center = new double[ n ];
for ( int d = 0; d < n; ++d )
center[ d ] = sum[ d ].getSum() / (double)list.size();
return center;
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:24,
代码来源:CenterOfMassPairwise.java
示例3: FirstIteration
点赞 3
import net.imglib2.util.RealSum; //导入依赖的package包/类
public FirstIteration(
final ImagePortion portion,
final RandomAccessibleInterval< FloatType > psi,
final ArrayList< RandomAccessibleInterval< FloatType > > imgs )
{
this.portion = portion;
this.psi = psi;
this.imgs = imgs;
this.psiIterable = Views.iterable( psi );
this.iterableImgs = new ArrayList< IterableInterval< FloatType > >();
this.realSum = new RealSum();
compatibleIteration = true;
for ( final RandomAccessibleInterval< FloatType > img : imgs )
{
final IterableInterval< FloatType > imgIterable = Views.iterable( img );
if ( !psiIterable.iterationOrder().equals( imgIterable.iterationOrder() ) )
compatibleIteration = false;
this.iterableImgs.add( imgIterable );
}
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:27,
代码来源:FirstIteration.java
示例4: getImageMean
点赞 3
import net.imglib2.util.RealSum; //导入依赖的package包/类
/**
* Calculates the mean of an image with respect to a mask.
*
* @param img The image to calculate the mean of
* @param mask The mask to respect
* @return The mean of the image passed
*/
final public static <T extends RealType<T>> double getImageMean(
final RandomAccessibleInterval<T> img,
final RandomAccessibleInterval<BitType> mask )
{
final RealSum sum = new RealSum();
long numPixels = 0;
// create cursor to walk an image with respect to a mask
final TwinCursor<T> cursor = new TwinCursor<T>(
img.randomAccess(),
img.randomAccess(),
Views.iterable(mask).localizingCursor());
while (cursor.hasNext()) {
sum.add(cursor.getFirst().getRealDouble());
++numPixels;
}
return sum.getSum() / numPixels;
}
开发者ID:fiji,
项目名称:Colocalisation_Analysis,
代码行数:26,
代码来源:ImageStatistics.java
示例5: getImageIntegral
点赞 3
import net.imglib2.util.RealSum; //导入依赖的package包/类
/**
* Calculates the integral of the pixel values of an image.
*
* @param img The image to calculate the integral of
* @return The pixel values integral of the image passed
*/
final public static <T extends RealType<T>> double getImageIntegral(
final RandomAccessibleInterval<T> img,
final RandomAccessibleInterval<BitType> mask )
{
final RealSum sum = new RealSum();
// create cursor to walk an image with respect to a mask
final TwinCursor<T> cursor = new TwinCursor<T>(
img.randomAccess(),
img.randomAccess(),
Views.iterable(mask).cursor());
while (cursor.hasNext())
sum.add( cursor.getFirst().getRealDouble() );
return sum.getSum();
}
开发者ID:fiji,
项目名称:Colocalisation_Analysis,
代码行数:22,
代码来源:ImageStatistics.java
示例6: call
点赞 2
import net.imglib2.util.RealSum; //导入依赖的package包/类
@Override
public Double call()
{
final RealSum sumA = new RealSum();
final RealSum sumAA = new RealSum();
final RealSum sumB = new RealSum();
final RealSum sumBB = new RealSum();
final RealSum sumAB = new RealSum();
int n = 0;
for ( int i = 0; i < ap.length; ++i )
{
final double va = ap[ i ];
final double vb = bp[ i ];
if ( Double.isNaN( va ) || Double.isNaN( vb ) )
continue;
++n;
sumA.add( va );
sumAA.add( va * va );
sumB.add( vb );
sumBB.add( vb * vb );
sumAB.add( va * vb );
}
final double suma = sumA.getSum();
final double sumaa = sumAA.getSum();
final double sumb = sumB.getSum();
final double sumbb = sumBB.getSum();
final double sumab = sumAB.getSum();
return ( n * sumab - suma * sumb ) / Math.sqrt( n * sumaa - suma * suma ) / Math.sqrt( n * sumbb - sumb * sumb );
}
开发者ID:saalfeldlab,
项目名称:z-spacing,
代码行数:34,
代码来源:RealSumFloatNCC.java
示例7: computeSmallestType
点赞 2
import net.imglib2.util.RealSum; //导入依赖的package包/类
/**
* Determine the smallest type that will correctly store the sums.
* For {@link Img} whose type has integer precision, the largest type is {@link LongType}.
* For {@link Img} whose type has floating-point precision, the largest type is {@link DoubleType}.
*
* @param img The input {@link Img}.
* @return
*/
static public final <R extends RealType<R>, T extends NativeType<T> & NumericType<T>> T computeSmallestType(final Img<R> img) {
final R type = img.firstElement();
final long maxSum = (long) (img.size() * (Math.pow(2, type.getBitsPerPixel()) -1));
T smallest = chooseSmallestType(type, maxSum);
if (null != smallest) return smallest;
// Else, slow way: sum all values and determine the smallest type
final RealSum sum = new RealSum();
for (final R r : img) sum.add(r.getRealDouble());
smallest = chooseSmallestType(type, sum.getSum());
if (null != smallest) return smallest;
throw new UnsupportedOperationException("Target image is too large!");
}
开发者ID:imglib,
项目名称:imglib2-script,
代码行数:21,
代码来源:FastIntegralImg.java
示例8: call
点赞 2
import net.imglib2.util.RealSum; //导入依赖的package包/类
@Override
public Double call()
{
final RealSum sumA = new RealSum();
final RealSum sumAA = new RealSum();
final RealSum sumB = new RealSum();
final RealSum sumBB = new RealSum();
final RealSum sumAB = new RealSum();
int n = 0;
for ( int i = 0; i < ap.length; ++i )
{
final int ra = ( ap[ i ] >> 16 ) & 0xff;
final int ga = ( ap[ i ] >> 8 ) & 0xff;
final int ba = ap[ i ] & 0xff;
final int rb = ( bp[ i ] >> 16 ) & 0xff;
final int gb = ( bp[ i ] >> 8 ) & 0xff;
final int bb = bp[ i ] & 0xff;
if ( ra == 0 || ga == 0 || ba == 0 ||
rb == 0 || gb == 0 || bb == 0 ||
ra == 255 || ga == 255 || ba == 255 ||
rb == 255 || gb == 255 || bb == 255 )
continue;
++n;
final double va = 0.3 * ra + 0.6 * ga + 0.1 * ba;
final double vb = 0.3 * rb + 0.6 * gb + 0.1 * bb;
sumA.add( va );
sumAA.add( va * va );
sumB.add( vb );
sumBB.add( vb * vb );
sumAB.add( va * vb );
}
final double suma = sumA.getSum();
final double sumaa = sumAA.getSum();
final double sumb = sumB.getSum();
final double sumbb = sumBB.getSum();
final double sumab = sumAB.getSum();
return ( n * sumab - suma * sumb ) / Math.sqrt( n * sumaa - suma * suma ) / Math.sqrt( n * sumbb - sumb * sumb );
}
开发者ID:saalfeldlab,
项目名称:z-spacing,
代码行数:42,
代码来源:RealSumARGBNCC.java
示例9: fuseFirstIteration
点赞 2
import net.imglib2.util.RealSum; //导入依赖的package包/类
protected static final double fuseFirstIteration( final Img< FloatType > psi, final ArrayList< MVDeconFFT > views )
{
final int nThreads = Threads.numThreads();
final int nPortions = nThreads * 2;
// split up into many parts for multithreading
final Vector< ImagePortion > portions = FusionHelper.divideIntoPortions( psi.size(), nPortions );
final ArrayList< Callable< Pair< RealSum, Long > > > tasks = new ArrayList< Callable< Pair< RealSum, Long > > >();
final ExecutorService taskExecutor = Executors.newFixedThreadPool( nThreads );
final ArrayList< RandomAccessibleInterval< FloatType > > imgs = new ArrayList< RandomAccessibleInterval< FloatType > >();
for ( final MVDeconFFT mvdecon : views )
imgs.add( mvdecon.getImage() );
for ( final ImagePortion portion : portions )
tasks.add( new FirstIteration( portion, psi, imgs ) );
final RealSum s = new RealSum();
long count = 0;
try
{
// invokeAll() returns when all tasks are complete
final List< Future< Pair< RealSum, Long > > > imgIntensities = taskExecutor.invokeAll( tasks );
for ( final Future< Pair< RealSum, Long > > future : imgIntensities )
{
s.add( future.get().getA().getSum() );
count += future.get().getB().longValue();
}
}
catch ( final Exception e )
{
IOFunctions.println( "Failed to fuse initial iteration: " + e );
e.printStackTrace();
return -1;
}
taskExecutor.shutdown();
return s.getSum() / (double)count;
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:45,
代码来源:MVDeconvolution.java