本文整理了Java中net.imglib2.util.Intervals.equals()
方法的一些代码示例,展示了Intervals.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intervals.equals()
方法的具体详情如下:
包路径:net.imglib2.util.Intervals
类名称:Intervals
方法名:equals
[英]Tests weather two intervals are equal in their min / max
[中]测试两个间隔的最小/最大值是否相等
代码示例来源:origin: scifio/scifio
/**
* Returns true if we have a cached copy of the requested plane available.
*/
private boolean haveCached(final int imageIndex, final long planeIndex,
final Interval bounds)
{
// TODO It would be nice to fix up this logic so that we can use
// cached planes when requesting a sub-region of the cached plane.
// See https://github.com/scifio/scifio/issues/155
return planeIndex == lastPlaneIndex && //
imageIndex == lastImageIndex && //
lastPlane != null && lastPlaneBounds != null && //
Intervals.equals(bounds, lastPlaneBounds);
}
代码示例来源:origin: io.scif/scifio
/**
* Returns true if we have a cached copy of the requested plane available.
*/
private boolean haveCached(final int imageIndex, final long planeIndex,
final Interval bounds)
{
// TODO It would be nice to fix up this logic so that we can use
// cached planes when requesting a sub-region of the cached plane.
// See https://github.com/scifio/scifio/issues/155
return planeIndex == lastPlaneIndex && //
imageIndex == lastImageIndex && //
lastPlane != null && lastPlaneBounds != null && //
Intervals.equals(bounds, lastPlaneBounds);
}
代码示例来源:origin: imglib/imglib2
/**
* Throws an AssertionError, if the two Intervals differ.
*/
public static void assertIntervalEquals( Interval a, Interval b )
{
if ( !Intervals.equals( a, b ) )
fail( "Intervals are different, expected: " + intervalToString( a ) + ", actual: " + intervalToString( b ) );
}
代码示例来源:origin: net.imglib2/imglib2
/**
* Throws an AssertionError, if the two Intervals differ.
*/
public static void assertIntervalEquals( Interval a, Interval b )
{
if ( !Intervals.equals( a, b ) )
fail( "Intervals are different, expected: " + intervalToString( a ) + ", actual: " + intervalToString( b ) );
}
代码示例来源:origin: net.imglib2/imglib2
/**
* Checks if both images have equal intervals and content.
* A predicate must be given to check if two pixels are equal.
*/
public static < T, U > boolean imagesEqual( final RandomAccessibleInterval< ? extends T > a, final RandomAccessibleInterval< ? extends U > b, final BiPredicate< T, U > pixelEquals )
{
if ( !Intervals.equals( a, b ) )
return false;
for ( final Pair< ? extends T, ? extends U > pair : Views.interval( Views.pair( a, b ), b ) )
if ( !pixelEquals.test( pair.getA(), pair.getB() ) )
return false;
return true;
}
代码示例来源:origin: imglib/imglib2
/**
* Checks if both images have equal intervals and content.
* A predicate must be given to check if two pixels are equal.
*/
public static < T, U > boolean imagesEqual( final RandomAccessibleInterval< ? extends T > a, final RandomAccessibleInterval< ? extends U > b, final BiPredicate< T, U > pixelEquals )
{
if ( !Intervals.equals( a, b ) )
return false;
for ( final Pair< ? extends T, ? extends U > pair : Views.interval( Views.pair( a, b ), b ) )
if ( !pixelEquals.test( pair.getA(), pair.getB() ) )
return false;
return true;
}
代码示例来源:origin: imagej/imagej-ops
@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;
}
}
代码示例来源:origin: imagej/imagej-ops
@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));
}
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalSubsampleSteps() {
Img<DoubleType> img = ArrayImgs.doubles(10,10);
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
for (DoubleType d : img) {
d.set(r.nextDouble());
}
SubsampleIntervalView<DoubleType> expected = Views.subsample((RandomAccessibleInterval<DoubleType>) img, 2, 1);
SubsampleIntervalView<DoubleType> actual = (SubsampleIntervalView<DoubleType>) ops.transform().subsampleView((RandomAccessibleInterval<DoubleType>)img, 2, 1);
Cursor<DoubleType> il2C = Views.interval(expected, new long[] { 0, 0 }, new long[] { 4, 9 }).localizingCursor();
RandomAccess<DoubleType> oprRA = actual.randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalSubsample() {
Img<DoubleType> img = ArrayImgs.doubles(10, 10);
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
for (DoubleType d : img) {
d.set(r.nextDouble());
}
SubsampleIntervalView<DoubleType> expected = Views.subsample((RandomAccessibleInterval<DoubleType>) img, 2);
SubsampleIntervalView<DoubleType> actual = (SubsampleIntervalView<DoubleType>) ops.transform().subsampleView((RandomAccessibleInterval<DoubleType>)img, 2);
Cursor<DoubleType> il2C = Views.interval(expected, new long[] { 0, 0 }, new long[] { 4, 4 }).localizingCursor();
RandomAccess<DoubleType> oprRA = actual.randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalPermuteDimensionCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
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));
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalPermuteCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
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));
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalPermuteInverseDimensionCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
while (c.hasNext()) {
c.next().set(r.nextDouble());
}
IntervalView<DoubleType> expected = Views.permuteCoordinatesInverse(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));
}
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalPermuteInverseCoordinates() {
Img<DoubleType> img = ArrayImgs.doubles(2, 2);
Cursor<DoubleType> c = img.cursor();
MersenneTwisterFast r = new MersenneTwisterFast(SEED);
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));
}
内容来源于网络,如有侵权,请联系作者删除!