本文整理汇总了Java中net.imglib2.view.IntervalView类的典型用法代码示例。如果您正苦于以下问题:Java IntervalView类的具体用法?Java IntervalView怎么用?Java IntervalView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntervalView类属于net.imglib2.view包,在下文中一共展示了IntervalView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testCube
import net.imglib2.view.IntervalView; //导入依赖的package包/类
/**
* Tests the op on a cube. All vectors should enter and exit it, i.e. their
* length should be 0.5.
*/
@Test
public void testCube() {
final Img<BitType> cube = ArrayImgs.bits(100, 100, 100);
final IntervalView<BitType> foreground = Views.interval(cube, new long[] {
1, 1, 1 }, new long[] { 98, 98, 98 });
foreground.cursor().forEachRemaining(BitType::setOne);
final double expectedLength = 1.0 / 2.0;
@SuppressWarnings("unchecked")
final List<Vector3d> milVectors =
(List<Vector3d>) ((ArrayList<Object>) IMAGE_J.op().run(MILGrid.class,
cube, IDENTITY_ROTATION, 10L, DEFAULT_INCREMENT, new Random(0xc0ff33)))
.get(0);
assertEquals("Regression test failed: some vectors have unexpected length",
milVectors.size(), milVectors.stream().filter(v -> v
.length() == expectedLength).count());
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:23,代码来源:MILGridTest.java
示例2: testXZSheets
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Test
public void testXZSheets() {
// SETUP
final Img<BitType> sheets = ArrayImgs.bits(100, 100, 100);
// Draw 19 XZ sheets
final long numSheets = 19;
for (long y = 5; y < 100; y += 5) {
final IntervalView<BitType> sheet = Views.interval(sheets, new long[] { 0,
y, 0 }, new long[] { 99, y, 99 });
sheet.cursor().forEachRemaining(BitType::setOne);
}
// EXECUTE
@SuppressWarnings("unchecked")
final List<Vector3d> milVectors =
(List<Vector3d>) ((ArrayList<Object>) IMAGE_J.op().run(MILGrid.class,
sheets, IDENTITY_ROTATION, DEFAULT_BINS, DEFAULT_INCREMENT, new Random(
0xc0ff33))).get(0);
// VERIFY
final Stream<Vector3d> yVectors = milVectors.stream().filter(v -> isParallel
.test(v, new Vector3d(0, 1, 0)));
assertTrue("MIL vectors in the Y-direction have unexpected length", yVectors
.allMatch(v -> v.length() == 1.0 / (2 * numSheets)));
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:26,代码来源:MILGridTest.java
示例3: getVisibleIds
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Override
public synchronized TLongHashSet getVisibleIds()
{
final TLongHashSet visibleIds = new TLongHashSet();
final int w = viewer.getWidth();
final int h = viewer.getHeight();
final AffineTransform3D viewerTransform = new AffineTransform3D();
viewer.getState().getViewerTransform( viewerTransform );
IntervalView< LabelMultisetType > screenLabels =
Views.interval(
Views.hyperSlice(
RealViews.affine( labels, viewerTransform ), 2, 0 ),
new FinalInterval( w, h ) );
for ( final LabelMultisetType pixel : Views.iterable( screenLabels ) )
{
for ( final Entry< Label > entry : pixel.entrySet() )
visibleIds.add( entry.getElement().id() );
}
return visibleIds;
}
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:23,代码来源:LabelMultiSetIdPicker.java
示例4: act
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Override
public < T extends RealType< T > > void act(
final int iteration,
final RandomAccessibleInterval< T > matrix,
final RandomAccessibleInterval< T > scaledMatrix,
final double[] lut,
final int[] permutation,
final int[] inversePermutation,
final double[] multipliers,
final RandomAccessibleInterval< double[] > estimatedFit )
{
final T dummy = scaledMatrix.randomAccess().get().createVariable();
dummy.setReal( Double.NaN );
final String path = fileDir( iteration );
if ( iteration == 0 )
createParentDirectory( path );
final LUTRealTransform tf = new LUTRealTransform( lut, 2, 2 );
final RealTransformRealRandomAccessible< T, InverseRealTransform > transformed = RealViews.transformReal( Views.interpolate( Views.extendValue( scaledMatrix, dummy ), new NLinearInterpolatorFactory<>() ), tf );
final double s = 1.0 / ( lut[ lut.length - 1 ] - lut[ 0 ] ) * lut.length;
final double o = -lut[ 0 ];
final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation( new double[] { s, s }, new double[] { o, o } );
final IntervalView< T > offset = Views.interval( Views.raster( RealViews.transformReal( transformed, scaleAndTranslation ) ), scaledMatrix );
final RandomAccessibleInterval< T > strip = MatrixStripConversion.matrixToStrip( offset, range, dummy );
new FileSaver( ImageJFunctions.wrap( strip, "" ) ).saveAsTiff( path );
}
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:27,代码来源:MatrixVisitor.java
示例5: run
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Override
public void run() {
// parse the spacing, and scales strings.
spacing = checkDimensions(spacingString, input.numDimensions(), "Spacings");
scales = Arrays.stream(scaleString.split(regex)).mapToInt(Integer::parseInt)
.toArray();
Dimensions resultDims = Views.addDimension(input, 0, scales.length - 1);
// create output image, potentially-filtered input
result = opService.create().img(resultDims, new FloatType());
for (int s = 0; s < scales.length; s++) {
// Determine whether or not the user would like to apply the gaussian
// beforehand and do it.
RandomAccessibleInterval<T> vesselnessInput = doGauss ? opService.filter()
.gauss(input, scales[s]) : input;
IntervalView<FloatType> scaleResult = Views.hyperSlice(result, result
.numDimensions() - 1, s);
opService.filter().frangiVesselness(scaleResult, vesselnessInput, spacing,
scales[s]);
}
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:22,代码来源:FrangiVesselness.java
示例6: calculate
import net.imglib2.view.IntervalView; //导入依赖的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
示例7: getIntegralImage
import net.imglib2.view.IntervalView; //导入依赖的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
示例8: addLeadingZeros
import net.imglib2.view.IntervalView; //导入依赖的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
示例9: sectionView
import net.imglib2.view.IntervalView; //导入依赖的package包/类
/**
* Creates a {@link net.imglib2.View} of the given grid section in the
* interval
* <p>
* Fits the view inside the bounds of the interval.
* </p>
*
* @param interval An n-dimensional interval with binary elements
* @param sizes Sizes of the interval's dimensions
* @param coordinates Starting coordinates of the section
* @param sectionSize Size of the section (n * n * ... n)
* @return A view of the interval spanning n pixels in each dimension from the
* coordinates. Null if view couldn't be set inside the interval
*/
private static <B extends BooleanType<B>> IntervalView<B> sectionView(
final RandomAccessibleInterval<B> interval, final long[] sizes,
final long[] coordinates, final long sectionSize)
{
final int n = sizes.length;
final long[] startPosition = IntStream.range(0, n).mapToLong(i -> Math.max(
0, coordinates[i])).toArray();
final long[] endPosition = IntStream.range(0, n).mapToLong(i -> Math.min(
(sizes[i] - 1), (coordinates[i] + sectionSize - 1))).toArray();
final boolean badBox = IntStream.range(0, n).anyMatch(
d -> (startPosition[d] >= sizes[d]) || (endPosition[d] < 0) ||
(endPosition[d] < startPosition[d]));
if (badBox) {
return null;
}
final BoundingBox box = new BoundingBox(n);
box.update(startPosition);
box.update(endPosition);
return Views.offsetInterval(interval, box);
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:35,代码来源:BoxCount.java
示例10: countGrid
import net.imglib2.view.IntervalView; //导入依赖的package包/类
/**
* Recursively counts the number of foreground sections in the grid over the
* given interval
*
* @param interval An n-dimensional interval with binary elements
* @param dimension Current dimension processed, start from the last
* @param sizes Sizes of the interval's dimensions in pixels
* @param translation Translation of grid start in each dimension
* @param sectionPosition The accumulated position of the current grid section
* (start from [0, 0, ... 0])
* @param sectionSize Size of a grid section (n * n * ... n)
* @param foreground Number of foreground sections found so far (start from 0)
*/
private static <B extends BooleanType<B>> void countGrid(
final RandomAccessibleInterval<B> interval, final int dimension,
final long[] sizes, final long[] translation, final long[] sectionPosition,
final long sectionSize, final LongType foreground)
{
for (int p = 0; p < sizes[dimension]; p += sectionSize) {
sectionPosition[dimension] = translation[dimension] + p;
if (dimension == 0) {
final IntervalView<B> box = sectionView(interval, sizes,
sectionPosition, sectionSize);
if (box != null && hasForeground(box)) {
foreground.inc();
}
}
else {
countGrid(interval, dimension - 1, sizes, translation, sectionPosition,
sectionSize, foreground);
}
}
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:34,代码来源:BoxCount.java
示例11: compute
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> input,
final RandomAccessibleInterval<T> output)
{
// input may potentially be translated
final long[] translation = new long[input.numDimensions()];
input.min(translation);
final IntervalView<T> tmpInterval = Views.interval(Views.translate(
(RandomAccessible<T>) tmpCreator.calculate(input), translation), output);
gauss1.compute(input, tmpInterval);
gauss2.compute(input, output);
// TODO: Match the Subtract Op in initialize() once we have BinaryOp
ops().run(Ops.Math.Subtract.class, output, output, tmpInterval);
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:18,代码来源:DefaultDoG.java
示例12: testIntervalTranslate
import net.imglib2.view.IntervalView; //导入依赖的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
示例13: IntervalHyperSliceTest
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Test
public void IntervalHyperSliceTest() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10, 10 },
new DoubleType());
final IntervalView<DoubleType> il2 = Views.hyperSlice((RandomAccessibleInterval<DoubleType>) img, 1, 8);
final IntervalView<DoubleType> opr = ops.transform().hyperSliceView(img, 1, 8);
for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix()[i].length; j++) {
assertEquals(
((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j],
((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
assertEquals(img.numDimensions() - 1, opr.numDimensions());
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:HyperSliceViewTest.java
示例14: permuteCoordinatesInverseOfDimensionTest
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Test
public void permuteCoordinatesInverseOfDimensionTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{2, 2}, new DoubleType());
Cursor<DoubleType> c = img.cursor();
Random r = new Random();
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> out = Views.permuteCoordinateInverse(img, new int[]{0, 1}, 1);
Cursor<DoubleType> il2 = out.cursor();
RandomAccess<DoubleType> opr = ops.transform().permuteCoordinatesInverseView(img, new int[]{0, 1}, 1).randomAccess();
while (il2.hasNext()) {
il2.next();
opr.setPosition(il2);
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:21,代码来源:PermuteViewTest.java
示例15: testIntervalPermuteCoordinates
import net.imglib2.view.IntervalView; //导入依赖的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
示例16: testIntervalPermuteDimensionCoordinates
import net.imglib2.view.IntervalView; //导入依赖的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
示例17: testIntervalPermuteInverseCoordinates
import net.imglib2.view.IntervalView; //导入依赖的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
示例18: testIntervalPermuteInverseDimensionCoordinates
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Test
public void testIntervalPermuteInverseDimensionCoordinates() {
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.permuteCoordinateInverse(img, new int[]{0, 1}, 1);
Cursor<DoubleType> e = expected.cursor();
RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesInverseView(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
示例19: testIntervalRotate
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Test
public void testIntervalRotate() {
final Img<DoubleType> img = ArrayImgs.doubles(20,10);
final IntervalView<DoubleType> il2 = Views.rotate((RandomAccessibleInterval<DoubleType>) img, 1, 0);
final IntervalView<DoubleType> opr = (IntervalView<DoubleType>) ops.transform().rotateView((RandomAccessibleInterval<DoubleType>) img, 1, 0);
for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix()[i].length; j++) {
assertEquals(
((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j],
((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:RotateViewTest.java
示例20: testIntervalRotateInterval
import net.imglib2.view.IntervalView; //导入依赖的package包/类
@Test
public void testIntervalRotateInterval() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 20, 10 }, new DoubleType());
final IntervalView<DoubleType> il2 = Views.rotate((RandomAccessibleInterval<DoubleType>) img, 1, 0);
final IntervalView<DoubleType> opr = ops.transform().rotateView((RandomAccessibleInterval<DoubleType>) img, 1, 0);
assertEquals(img.min(1), il2.min(0));
assertEquals(img.max(1), il2.max(0));
assertEquals(img.min(0), -il2.max(1));
assertEquals(img.max(0), -il2.min(1));
for (int i = 0; i < il2.numDimensions(); i++) {
assertEquals(il2.max(i), opr.max(i));
assertEquals(il2.min(i), opr.min(i));
}
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:RotateViewTest.java
注:本文中的net.imglib2.view.IntervalView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论