本文整理汇总了Java中net.imglib2.view.Views.extendMirrorSingle方法的典型用法代码示例。如果您正苦于以下问题:Java Views.extendMirrorSingle方法的具体用法?Java Views.extendMirrorSingle怎么用?Java Views.extendMirrorSingle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.view.Views
的用法示例。
在下文中一共展示了Views.extendMirrorSingle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gaussianSmooth
import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
* Gaussian Smooth of the input image using intermediate float format.
* @param <T>
* @param img
* @param sigma
* @return
*/
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> gaussianSmooth(
RandomAccessibleInterval<T> img, double[] sigma) {
Interval interval = Views.iterable(img);
ImgFactory<T> outputFactory = new ArrayImgFactory<T>();
final long[] dim = new long[ img.numDimensions() ];
img.dimensions(dim);
RandomAccessibleInterval<T> output = outputFactory.create( dim,
img.randomAccess().get().createVariable() );
final long[] pos = new long[ img.numDimensions() ];
Arrays.fill(pos, 0);
Localizable origin = new Point(pos);
ImgFactory<FloatType> tempFactory = new ArrayImgFactory<FloatType>();
RandomAccessible<T> input = Views.extendMirrorSingle(img);
Gauss.inFloat(sigma, input, interval, output, origin, tempFactory);
return output;
}
示例2: iterateWithRandomAccessiblePartial
import net.imglib2.view.Views; //导入方法依赖的package包/类
private void iterateWithRandomAccessiblePartial( final Interval interval ) {
final ExtendedRandomAccessibleInterval<T, Img<T>> extended = Views.extendMirrorSingle(input);
final Cursor<FloatType> oc = Views.iterable(Views.interval(output, interval)).localizingCursor();
final int n = input.numDimensions();
final long[] min = new long[ n ];
final long[] max = new long[ n ];
interval.min( min );
interval.max( max );
for ( int d = 0; d < n; ++d )
{
min[d] -= 1;
max[d] += 1;
}
final Interval raInterval = new FinalInterval( min, max );
final RandomAccess<T> ra = extended.randomAccess( raInterval );
float I, In, Ine, Ie, Ise, Is, Isw, Iw, Inw;
while(oc.hasNext()) {
oc.fwd();
ra.setPosition(oc);
I = ra.get().getRealFloat();
ra.bck(1);
In = ra.get().getRealFloat();
ra.fwd(0);
Ine = ra.get().getRealFloat();
ra.fwd(1);
Ie = ra.get().getRealFloat();
ra.fwd(1);
Ise = ra.get().getRealFloat();
ra.bck(0);
Is = ra.get().getRealFloat();
ra.bck(0);
Isw = ra.get().getRealFloat();
ra.bck(1);
Iw = ra.get().getRealFloat();
ra.bck(1);
Inw = ra.get().getRealFloat();
oc.get().set( I - 1/8f * (In+Ine+Ie+Ise+Is+Isw+Iw+Inw));
}
}
示例3: calculate
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public ExtendedRandomAccessibleInterval<T, F> calculate(F input) {
return Views.extendMirrorSingle(input);
}
示例4: process
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public boolean process()
{
// do not operate at the edge, 80% of the memory is a good idea I think
final long memAvail = Math.round( cudaDevice.getFreeDeviceMemory() * ( percentGPUMem / 100.0 ) );
final long imgBytes = numPixels() * 4 * 2; // float, two images on the card at once
final long[] numBlocksDim = net.imglib2.util.Util.int2long( computeNumBlocksDim( memAvail, imgBytes, percentGPUMem, img.numDimensions(), "CUDA-Device " + cudaDevice.getDeviceId() ) );
final BlockGenerator< Block > generator;
if ( accurate )
generator = new BlockGeneratorVariableSizePrecise( numBlocksDim );
else
generator = new BlockGeneratorVariableSizeSimple( numBlocksDim );
final Block[] blocks = generator.divideIntoBlocks( getImgSize( img ), getKernelSize( sigma ) );
if ( !accurate && blocks.length == 1 && ArrayImg.class.isInstance( img ) )
{
IOFunctions.println( "Conovlving image as one single block." );
long time = System.currentTimeMillis();
// copy the only directly into the result
blocks[ 0 ].copyBlock( img, result );
long copy = System.currentTimeMillis();
IOFunctions.println( "Copying data took " + ( copy - time ) + "ms" );
// convolve
final float[] resultF = ((FloatArray)((ArrayImg< net.imglib2.type.numeric.real.FloatType, ? > )result).update( null ) ).getCurrentStorageArray();
cudaconvolve.gauss( resultF, getImgSizeInt( result ), sigma, OutOfBounds.EXTEND_BORDER_PIXELS, 0 );
IOFunctions.println( "Convolution took " + ( System.currentTimeMillis() - copy ) + "ms using device=" + cudaDevice.getDeviceName() + " (id=" + cudaDevice.getDeviceId() + ")" );
// no copy back required
}
else
{
final RandomAccessible< net.imglib2.type.numeric.real.FloatType > input;
if ( accurate )
input = Views.extendMirrorSingle( img );
else
input = img;
for( final Block block : blocks )
{
//long time = System.currentTimeMillis();
final ArrayImg< net.imglib2.type.numeric.real.FloatType, FloatArray > imgBlock = ArrayImgs.floats( block.getBlockSize() );
// copy the block
block.copyBlock( input, imgBlock );
//long copy = System.currentTimeMillis();
//IOFunctions.println( "Copying block took " + ( copy - time ) + "ms" );
// convolve
final float[] imgBlockF = ((FloatArray)((ArrayImg< net.imglib2.type.numeric.real.FloatType, ? > )imgBlock).update( null ) ).getCurrentStorageArray();
cudaconvolve.gauss( imgBlockF, getImgSizeInt( imgBlock ), sigma, OutOfBounds.EXTEND_BORDER_PIXELS, 0 );
//long convolve = System.currentTimeMillis();
//IOFunctions.println( "Convolution took " + ( convolve - copy ) + "ms using device=" + cudaDevice.getDeviceName() + " (id=" + cudaDevice.getDeviceId() + ")" );
// no copy back required
block.pasteBlock( result, imgBlock );
//IOFunctions.println( "Pasting block took " + ( System.currentTimeMillis() - convolve ) + "ms" );
}
}
return true;
}