本文整理汇总了Java中net.imglib2.util.Intervals类的典型用法代码示例。如果您正苦于以下问题:Java Intervals类的具体用法?Java Intervals怎么用?Java Intervals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Intervals类属于net.imglib2.util包,在下文中一共展示了Intervals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gradient
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Compute the partial derivative of source in a particular dimension.
*
* @param source
* source image, has to provide valid data in the interval of the
* gradient image plus a one pixel border in dimension.
* @param target
* output image, the partial derivative of source in the
* specified dimension.
* @param dimension
* along which dimension the partial derivatives are computed
* @param <T> pixel type source
* @param <S> pixel type target
*/
public static < T extends RealType< T >, S extends RealType< S > > void gradient(
final RandomAccessible< T > source,
final RandomAccessibleInterval< S > target,
final int dimension )
{
final Cursor< T > front = Views.flatIterable(
Views.interval( source,
Intervals.translate( target, 1, dimension ) ) ).cursor();
final Cursor< T > back = Views.flatIterable(
Views.interval( source,
Intervals.translate( target, -1, dimension ) ) ).cursor();
for( final S t : Views.flatIterable( target ) )
{
t.setReal( front.next().getRealDouble() - back.next().getRealDouble());
t.mul( 0.5 );
}
}
示例2: BlendedExtendedMirroredRandomAccesible2
import net.imglib2.util.Intervals; //导入依赖的package包/类
public BlendedExtendedMirroredRandomAccesible2(RandomAccessibleInterval<T> img, int[] border) {
this.img = img;
this.numDimensions = img.numDimensions();
float[] blendingBorder = new float[numDimensions];
float[] border2 = new float[numDimensions];
this.extDims = new FinalInterval(img);
for (int i = 0; i < numDimensions; i++)
{
extDims = Intervals.expand(extDims, border[i], i);
blendingBorder[i] = border[i];
border2[i] = 0.0f;
}
this.blending = new BlendingRealRandomAccessible(extDims, border2, blendingBorder);
}
示例3: initRaw
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Load raw data, find maximum raw dimensions
*
* @param params
* @throws IOException
*/
@Override
protected void initRaw( final P params ) throws IOException
{
System.out.println( "Opening raw from " + params.inFile );
final IHDF5Reader reader = HDF5Factory.openForReading( params.inFile );
/* raw pixels */
Arrays.fill( maxRawDimensions, 0 );
for ( final String raw : params.raws )
if ( reader.exists( raw ) )
{
final H5UnsignedByteSetupImageLoader rawLoader = new H5UnsignedByteSetupImageLoader( reader, raw, setupId++, cellDimensions, cache );
raws.add( rawLoader );
max( maxRawDimensions, Intervals.dimensionsAsLongArray( rawLoader.getVolatileImage( 0, 0 ) ) );
}
else
System.out.println( "no raw dataset '" + raw + "' found" );
}
示例4: createUnsignedByte
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Save a {@link RandomAccessibleInterval} of {@link LongType} into an HDF5
* uint8 dataset.
*
* @param source source
* @param dimensions dimensions of the dataset if created new
* @param writer
* @param dataset
* @param cellDimensions
*/
static public void createUnsignedByte(
final IHDF5Writer writer,
final String dataset,
final Dimensions datasetDimensions,
final int[] cellDimensions )
{
final IHDF5ByteWriter uint8Writer = writer.uint8();
if ( writer.exists( dataset ) )
writer.delete( dataset );
uint8Writer.createMDArray(
dataset,
reorder( Intervals.dimensionsAsLongArray( datasetDimensions ) ),
reorder( cellDimensions ),
HDF5IntStorageFeatures.INT_AUTO_SCALING_DEFLATE );
}
示例5: createUnsignedLong
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Save a {@link RandomAccessibleInterval} of {@link LongType} into an HDF5
* uint64 dataset.
*
* @param source source
* @param dimensions dimensions of the dataset if created new
* @param writer
* @param dataset
* @param cellDimensions
*/
static public void createUnsignedLong(
final IHDF5Writer writer,
final String dataset,
final Dimensions datasetDimensions,
final int[] cellDimensions )
{
final IHDF5LongWriter uint64Writer = writer.uint64();
if ( writer.exists( dataset ) )
writer.delete( dataset );
uint64Writer.createMDArray(
dataset,
reorder( Intervals.dimensionsAsLongArray( datasetDimensions ) ),
reorder( cellDimensions ),
HDF5IntStorageFeatures.INT_AUTO_SCALING_DEFLATE );
}
示例6: createLong
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Create anHDF5 int64 dataset.
*
* @param source source
* @param dimensions dimensions of the dataset if created new
* @param writer
* @param dataset
* @param cellDimensions
*/
static public void createLong(
final IHDF5Writer writer,
final String dataset,
final Dimensions datasetDimensions,
final int[] cellDimensions )
{
final IHDF5LongWriter int64Writer = writer.int64();
if ( writer.exists( dataset ) )
writer.delete( dataset );
int64Writer.createMDArray(
dataset,
reorder( Intervals.dimensionsAsLongArray( datasetDimensions ) ),
reorder( cellDimensions ),
HDF5IntStorageFeatures.INT_AUTO_SCALING_DEFLATE );
}
示例7: testUnsignedAnyBitImg
import net.imglib2.util.Intervals; //导入依赖的package包/类
public void testUnsignedAnyBitImg() {
try {
Img<UnsignedByteType> img1 = (Img<UnsignedByteType>) new ImgOpener().openImgs("/home/albert/Desktop/t2/bridge-crop.tif").get(0);
Img<UnsignedVariableBitLengthType> img2 = new UnsignedVariableBitLengthType(10).createSuitableNativeImg(new ArrayImgFactory<UnsignedVariableBitLengthType>(), Intervals.dimensionsAsLongArray(img1));
Cursor<UnsignedByteType> c1 = img1.cursor();
Cursor<UnsignedVariableBitLengthType> c2 = img2.cursor();
while (c1.hasNext()) {
c1.fwd();
c2.fwd();
c2.get().set(c1.get().getIntegerLong());
}
new ImageJ();
ImgLib.wrap(img2, "copy").show();
} catch (Exception e) {
e.printStackTrace();
}
}
示例8: findLocalMaximaNeighborhood
import net.imglib2.util.Intervals; //导入依赖的package包/类
public static < T extends Type< T > & Comparable< T > > int findLocalMaximaNeighborhood( final RandomAccessibleInterval< T > img )
{
// final ArrayList< Point > maxima = new ArrayList< Point >();
int nMaxima = 0;
final Cursor< T > center = Views.iterable( Views.interval( img, Intervals.expand( img, -1 ) ) ).localizingCursor();
final LocalNeighborhood< T > neighborhood = new LocalNeighborhood< T >( img, center );
final LocalNeighborhoodCursor< T > nc = neighborhood.cursor();
A: while ( center.hasNext() )
{
final T t = center.next();
nc.updateCenter( center );
while ( nc.hasNext() )
{
final T n = nc.next();
if ( n.compareTo( t ) > 0 )
continue A;
}
// maxima.add( new Point( center ) );
++nMaxima;
}
return nMaxima;
}
示例9: findLocalMaximaNeighborhood2
import net.imglib2.util.Intervals; //导入依赖的package包/类
public static < T extends Type< T > & Comparable< T > > int findLocalMaximaNeighborhood2( final RandomAccessibleInterval< T > img )
{
// final ArrayList< Point > maxima = new ArrayList< Point >();
int nMaxima = 0;
final Cursor< T > center = Views.iterable( Views.interval( img, Intervals.expand( img, -1 ) ) ).localizingCursor();
final LocalNeighborhood2< T > neighborhood = new LocalNeighborhood2< T >( img, center );
final LocalNeighborhoodCursor2< T > nc = neighborhood.cursor();
A: while ( center.hasNext() )
{
final T t = center.next();
neighborhood.updateCenter( center );
nc.reset();
while ( nc.hasNext() )
{
final T n = nc.next();
if ( n.compareTo( t ) > 0 )
continue A;
}
// maxima.add( new Point( center ) );
++nMaxima;
}
return nMaxima;
}
示例10: main
import net.imglib2.util.Intervals; //导入依赖的package包/类
public static void main( final String[] args ) throws ImgIOException
{
final String fn = "/home/tobias/workspace/data/DrosophilaWing.tif";
final int span = 3;
final ArrayImgFactory< FloatType > factory = new ArrayImgFactory< FloatType >();
final FloatType type = new FloatType();
final Img< FloatType > imgInput = new ImgOpener().openImg( fn, factory, type );
final Img< FloatType > imgOutput = factory.create( imgInput, type );
final Interval computationInterval = Intervals.expand( imgInput, -span );
final RandomAccessibleInterval< FloatType > input = Views.interval( imgInput, computationInterval );
final RandomAccessibleInterval< FloatType > output = Views.interval( imgOutput, computationInterval );
minFilter( input, output, new RectangleShape( span, false ) );
// minFilter( input, output, new HyperSphereShape( span ) );
ImageJFunctions.show( imgInput, "input" );
ImageJFunctions.show( imgOutput, "min filtered" );
}
示例11: calculate
import net.imglib2.util.Intervals; //导入依赖的package包/类
@Override
public RandomAccessibleInterval<T> calculate(final RandomAccessibleInterval<T> input, final Interval interval) {
boolean oneSizedDims = false;
if (dropSingleDimensions) {
for (int d = 0; d < interval.numDimensions(); d++) {
if (interval.dimension(d) == 1) {
oneSizedDims = true;
break;
}
}
}
if (Intervals.equals(input, interval) && !oneSizedDims)
return input;
if (!Intervals.contains(input, interval))
throw new RuntimeException("Intervals don't match!");
IntervalView<T> res = Views.offsetInterval(input, interval);
return oneSizedDims ? Views.dropSingletonDimensions(res) : res;
}
示例12: getIntegralImage
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Computes integral images of a given order and extends them such that
* {@link IntegralMean} et al work with them.
*
* @param input The RAI for which an integral image is computed
* @param order
* @return An extended integral image for the input RAI
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private RandomAccessibleInterval<RealType> getIntegralImage(
final RandomAccessibleInterval<I> input, final int order)
{
ExtendedRandomAccessibleInterval<I, RandomAccessibleInterval<I>> extendedInput =
Views.extend(input, outOfBoundsFactory);
FinalInterval expandedInterval = Intervals.expand(input, shape.getSpan()-1);
IntervalView<I> offsetInterval2 = Views.offsetInterval(extendedInput, expandedInterval);
RandomAccessibleInterval<RealType> img = null;
switch (order) {
case 1:
img = (RandomAccessibleInterval) integralImgOp.calculate(offsetInterval2);
break;
case 2:
img = (RandomAccessibleInterval) squareIntegralImgOp.calculate(offsetInterval2);
break;
}
img = addLeadingZeros(img);
return img;
}
示例13: addLeadingZeros
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Add 0s before axis minimum.
*
* @param input Input RAI
* @return An extended and cropped version of input
*/
private <T extends RealType<T>> RandomAccessibleInterval<T> addLeadingZeros(
RandomAccessibleInterval<T> input)
{
final long[] min = Intervals.minAsLongArray(input);
final long[] max = Intervals.maxAsLongArray(input);
for (int i = 0; i < max.length; i++) {
min[i]--;
}
final T realZero = Util.getTypeFromInterval(input).copy();
realZero.setZero();
final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extendedImg = Views.extendValue(input,
realZero);
final IntervalView<T> offsetInterval = Views.interval(extendedImg,
min, max);
return Views.zeroMin(offsetInterval);
}
示例14: removeLeadingZeros
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Removes leading 0s from integral image after composite creation.
*
* @param input Input RAI (can be a RAI of Composite)
* @return An extended and cropped version of input
*/
private <T> RandomAccessibleInterval<T> removeLeadingZeros(
final RandomAccessibleInterval<T> input)
{
// Remove 0s from integralImg by shifting its interval by +1
final long[] min = Intervals.minAsLongArray(input);
final long[] max = Intervals.maxAsLongArray(input);
for (int d = 0; d < input.numDimensions(); ++d) {
int correctedSpan = getShape().getSpan() - 1;
min[d] += (1 + correctedSpan);
max[d] -= correctedSpan;
}
// Define the Interval on the infinite random accessibles
final FinalInterval interval = new FinalInterval(min, max);
final RandomAccessibleInterval<T> extendedImg = Views.offsetInterval(Views
.extendBorder(input), interval);
return extendedImg;
}
示例15: call
import net.imglib2.util.Intervals; //导入依赖的package包/类
@Override
public Void call() throws Exception {
final FinalInterval interval = new FinalInterval(in.dimension(0), in.dimension(1));
for (int j = 0; j < in.dimension(1); j++) {
// sum up the magnitudes of all bins in a neighborhood
raNeighbor.setPosition(new long[] { i, j });
final Cursor<FloatType> cursorNeighborHood = raNeighbor.get().cursor();
while (cursorNeighborHood.hasNext()) {
cursorNeighborHood.next();
if (Intervals.contains(interval, cursorNeighborHood)) {
raAngles.setPosition(cursorNeighborHood);
raMagnitudes.setPosition(cursorNeighborHood);
raOut.setPosition(new long[] { i, j,
(int) (raAngles.get().getRealFloat() / (360 / numOrientations) - 0.5) });
raOut.get().add(raMagnitudes.get());
}
}
}
return null;
}