本文整理汇总了Java中net.imglib2.util.Intervals类的典型用法代码示例。如果您正苦于以下问题:Java Intervals类的具体用法?Java Intervals怎么用?Java Intervals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Intervals类属于net.imglib2.util包,在下文中一共展示了Intervals类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
}
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:32,代码来源:Align.java
示例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);
}
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:18,代码来源:BlendedExtendedMirroredRandomAccesible2.java
示例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" );
}
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:25,代码来源:BigCat.java
示例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 );
}
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:30,代码来源:H5Utils.java
示例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 );
}
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:28,代码来源:H5Utils.java
示例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 );
}
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:27,代码来源:H5Utils.java
示例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();
}
}
开发者ID:imglib,项目名称:imglib2-script,代码行数:23,代码来源:IntegralHistogramExpectationChecking.java
示例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;
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:25,代码来源:LocalMaximaBenchmark.java
示例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;
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:25,代码来源:LocalMaximaBenchmark.java
示例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" );
}
开发者ID:imglib,项目名称:imglib2-tests,代码行数:21,代码来源:MinFilterExample.java
示例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;
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:21,代码来源:CropRAI.java
示例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;
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:32,代码来源:LocalThresholdIntegral.java
示例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);
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:27,代码来源:LocalThresholdIntegral.java
示例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;
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:27,代码来源:LocalThresholdIntegral.java
示例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;
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:22,代码来源:HistogramOfOrientedGradients2D.java
示例16: mean
import net.imglib2.util.Intervals; //导入依赖的package包/类
/**
* Apply mean filter with given size of reactangle shape
*
* @param input
* Input image
* @param i
* Size of rectangle shape
* @return Filered mean image
*/
@SuppressWarnings("unchecked")
private Img<I> mean(final RandomAccessibleInterval<I> input, final int i) {
long[] dims = new long[input.numDimensions()];
input.dimensions(dims);
final byte[] array = new byte[(int) Intervals.numElements(new FinalInterval(dims))];
Img<I> meanImg = (Img<I>) ArrayImgs.unsignedBytes(array, dims);
OutOfBoundsMirrorFactory<ByteType, Img<ByteType>> oobFactory = new OutOfBoundsMirrorFactory<>(
Boundary.SINGLE);
ops().run(MeanFilterOp.class, meanImg, input, new RectangleShape(i, true), oobFactory);
return meanImg;
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:26,代码来源:DefaultCoarsenessFeature.java
示例17: testIntervalTranslate
import net.imglib2.util.Intervals; //导入依赖的package包/类
@Test
public void testIntervalTranslate() {
Img<DoubleType> img = ArrayImgs.doubles(10,10);
IntervalView<DoubleType> expected = Views.translate(img, 2, 5);
IntervalView<DoubleType> actual = ops.transform().translateView(img, 2, 5);
for (int i = 0; i < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i][j], ((MixedTransformView<DoubleType>) actual.getSource()).getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
assertTrue(Intervals.equals(expected, actual));
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:17,代码来源:TranslateViewTest.java
示例18: testIntervalPermuteCoordinates
import net.imglib2.util.Intervals; //导入依赖的package包/类
@Test
public void testIntervalPermuteCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[]{0, 1});
Cursor<DoubleType> e = expected.cursor();
RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[]{0, 1});
RandomAccess<DoubleType> actualRA = actual.randomAccess();
while (e.hasNext()) {
e.next();
actualRA.setPosition(e);
assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:PermuteViewTest.java
示例19: testIntervalPermuteDimensionCoordinates
import net.imglib2.util.Intervals; //导入依赖的package包/类
@Test
public void testIntervalPermuteDimensionCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[]{0, 1}, 1);
Cursor<DoubleType> e = expected.cursor();
RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[]{0, 1}, 1);
RandomAccess<DoubleType> actualRA = actual.randomAccess();
while (e.hasNext()) {
e.next();
actualRA.setPosition(e);
assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:PermuteViewTest.java
示例20: testIntervalPermuteInverseCoordinates
import net.imglib2.util.Intervals; //导入依赖的package包/类
@Test
public void testIntervalPermuteInverseCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> expected = Views.permuteCoordinatesInverse(img, new int[]{0, 1});
Cursor<DoubleType> e = expected.cursor();
RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesInverseView(img, new int[]{0, 1});
RandomAccess<DoubleType> actualRA = actual.randomAccess();
while (e.hasNext()) {
e.next();
actualRA.setPosition(e);
assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:PermuteViewTest.java
注:本文中的net.imglib2.util.Intervals类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论