本文整理汇总了Java中net.imglib2.util.ValuePair类的典型用法代码示例。如果您正苦于以下问题:Java ValuePair类的具体用法?Java ValuePair怎么用?Java ValuePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValuePair类属于net.imglib2.util包,在下文中一共展示了ValuePair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applySplit
import net.imglib2.util.ValuePair; //导入依赖的package包/类
/**
* Splits a subspace along the given coordinates
* <p>
* For example, if you have a 5D {X, Y, Z, C, T} hyperstack, and give the
* coordinates {{3, 0}, {4, 1}} you'll get a 3D {X, Y, Z} subspace of the
* first channel, and second time frame
* </p>
*
* @param hyperstack an n-dimensional image
* @param splitCoordinates (dimension, position) pairs describing the
* hyperstack split
* @return The subspace interval
*/
private static <T extends RealType<T> & NativeType<T>>
RandomAccessibleInterval<T> applySplit(final ImgPlus<T> hyperstack,
final List<ValuePair<IntType, LongType>> splitCoordinates)
{
final List<ValuePair<IntType, LongType>> workingSplit = createWorkingCopy(
splitCoordinates);
RandomAccessibleInterval<T> slice = hyperstack;
for (int i = 0; i < workingSplit.size(); i++) {
final int dimension = workingSplit.get(i).a.get();
final long position = workingSplit.get(i).b.get();
slice = Views.hyperSlice(slice, dimension, position);
decrementIndices(workingSplit, dimension);
}
return slice;
}
示例2: addSubspaceTable
import net.imglib2.util.ValuePair; //导入依赖的package包/类
private void addSubspaceTable(final Subspace<BitType> subspace,
final List<ValuePair<DoubleType, DoubleType>> pairs)
{
final String label = inputImage.getName() + " " + subspace.toString();
final GenericColumn labelColumn = ResultUtils.createLabelColumn(label, pairs
.size());
final DoubleColumn xColumn = new DoubleColumn("-log(size)");
final DoubleColumn yColumn = new DoubleColumn("log(count)");
pairs.stream().map(p -> p.a.get()).forEach(xColumn::add);
pairs.stream().map(p -> p.b.get()).forEach(yColumn::add);
final GenericTable resultsTable = new DefaultGenericTable();
resultsTable.add(labelColumn);
resultsTable.add(xColumn);
resultsTable.add(yColumn);
subspaceTables.add(resultsTable);
}
示例3: lines
import net.imglib2.util.ValuePair; //导入依赖的package包/类
private Stream<ValuePair<Point3d, Vector3d>> lines(final long bins,
final double sign)
{
final Vector3d direction = getNormal(sign);
final Vector3d t = new Vector3d(translation);
t.scale(sign);
final double range = 1.0 / bins;
final Builder<ValuePair<Point3d, Vector3d>> builder = Stream.builder();
for (int i = 0; i < bins; i++) {
final double minC = i * range;
for (int j = 0; j < bins; j++) {
final double minD = j * range;
final double c = (rng.nextDouble() * range + minC) * size - 0.5 *
size;
final double d = (rng.nextDouble() * range + minD) * size - 0.5 *
size;
final Point3d origin = createOrigin(c, d, t);
builder.add(new ValuePair<>(origin, direction));
}
}
return builder.build();
}
示例4: testValenceSorterOnFishGraph
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Test
public void testValenceSorterOnFishGraph() {
final Graph fishGraph = TestGraphs.createDownWardFacingFishGraph();
final Pair<Integer, Integer> range = new ValuePair<>(0, Integer.MAX_VALUE);
final Map<Integer, List<Vertex>> map = valenceSorterOp.calculate(fishGraph, range);
final Set<Integer> keySet = map.keySet();
final int[] expectedCounts = { 2, 2, 1 };
final int[] expectedValences = { 1, 2, 4 };
assertEquals("Wrong number of valences", 3, keySet.size());
for (int i = 0; i < expectedCounts.length; i++) {
assertTrue("Expected valence missing", map.containsKey(expectedValences[i]));
final List<Vertex> vertices = map.get(expectedValences[i]);
final int valence = expectedValences[i];
assertEquals("Wrong number of vertices with valence " + valence, expectedCounts[i], vertices.size());
assertTrue("A vertex has wrong number of branches (valence)",
vertices.stream().allMatch(v -> valence == v.getBranches().size()));
}
}
示例5: testRangeOnFishGraph
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Test
public void testRangeOnFishGraph() {
final Graph fishGraph = TestGraphs.createDownWardFacingFishGraph();
final Pair<Integer, Integer> range = new ValuePair<>(2, 3);
final Map<Integer, List<Vertex>> map = valenceSorterOp.calculate(fishGraph, range);
final Set<Integer> keySet = map.keySet();
final int expectedCount = 2;
final int expectedValence = 2;
assertEquals("Wrong number of valences", 1, keySet.size());
assertTrue("Expected valence missing", map.containsKey(expectedValence));
final List<Vertex> vertices = map.get(expectedValence);
assertEquals("Wrong number of vertices with valence " + expectedValence, expectedCount, vertices.size());
assertTrue("A vertex has wrong number of branches (valence)",
vertices.stream().allMatch(v -> expectedValence == v.getBranches().size()));
}
示例6: getComparisons
import net.imglib2.util.ValuePair; //导入依赖的package包/类
public List<Pair<? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup > >, ? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup >>>> getComparisons()
{
final List<Pair<? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup > >, ? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup >>>> res = new ArrayList<>();
// filter first
final List<BasicViewDescription< ? > > ungroupedElements =
SpimDataTools.getFilteredViewDescriptions( data.getSequenceDescription(), filters);
// then group
final List< Group< BasicViewDescription< ? > >> groupedElements =
Group.combineBy(ungroupedElements, groupingFactors);
// go through possible group pairs
for (int i = 0; i < groupedElements.size(); ++i)
for(int j = i+1; j < groupedElements.size(); ++j)
{
// we will want to process the pair if:
// the groups do not differ along an axis along which we want to treat elements individually (e.g. Angle)
// but they differ along an axis that we want to register (e.g Tile)
if (!groupsDifferByAny( groupedElements.get( i ), groupedElements.get( j ), axesOfApplication )
&& groupsDifferByAny( groupedElements.get( i ), groupedElements.get( j ), axesOfComparison ))
res.add(new ValuePair<>(groupedElements.get( i ), groupedElements.get( j )));
}
return res;
}
示例7: getInitialTransforms
import net.imglib2.util.ValuePair; //导入依赖的package包/类
/**
*
* @param vr the ViewRegistration to decompose
* @param is2d true or false
* @param dsCorrectionT downsampling correction
* @return (1) the ViewRegistration without Translation part and the translation, with the inverse of (1) and dsCorrection applied
*/
public static Pair<AffineGet, TranslationGet> getInitialTransforms( final ViewRegistration vr, final boolean is2d, final AffineTransform3D dsCorrectionT )
{
AffineTransform3D model = vr.getModel().copy();
// get model without translation (last column set to 0)
AffineTransform3D modelWithoutTranslation = model.copy();
modelWithoutTranslation.set( 0, 0, 3 );
modelWithoutTranslation.set( 0, 1, 3 );
modelWithoutTranslation.set( 0, 2, 3 );
// the translation with inverse of other part of model applied
final double[] target = model.getTranslation();
modelWithoutTranslation.applyInverse( target, target );
// we go from big to downsampled, thats why the inverse
dsCorrectionT.applyInverse( target, target );
if ( is2d )
return new ValuePair<>(modelWithoutTranslation, new Translation2D( target[ 0 ], target[ 1 ] ));
else
return new ValuePair<>(modelWithoutTranslation, new Translation3D( target[ 0 ], target[ 1 ], target[ 2 ] ));
}
示例8: selectedViewDescriptions
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Override
public void selectedViewDescriptions(
List< List< BasicViewDescription< ? extends BasicViewSetup > > > viewDescriptions)
{
List<Pair<Group<ViewId>, Group<ViewId>>> res = new ArrayList<>();
for (int i = 0; i<viewDescriptions.size(); i++)
for (int j = i+1; j<viewDescriptions.size(); j++)
{
Group<ViewId> groupA = new Group<>();
groupA.getViews().addAll( viewDescriptions.get( i ) );
Group<ViewId> groupB = new Group<>();
groupB.getViews().addAll( viewDescriptions.get( j ) );
res.add( new ValuePair< Group<ViewId>, Group<ViewId> >( groupA, groupB ) );
}
setActiveLinks( res );
}
示例9: calculate
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Override
public Pair<I, I> calculate(final Iterable<I> input) {
double tmpMin = Double.POSITIVE_INFINITY;
double tmpMax = Double.NEGATIVE_INFINITY;
for (final I in : input) {
final double n = in.getRealDouble();
if (tmpMin > n) {
tmpMin = n;
}
if (tmpMax < n) {
tmpMax = n;
}
}
final I min = input.iterator().next().createVariable();
min.setReal(tmpMin);
final I max = input.iterator().next().createVariable();
max.setReal(tmpMax);
return new ValuePair<>(min, max);
}
示例10: calculate
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Override
public Pair<RealLocalizable, RealLocalizable> calculate(Polygon input) {
final List<? extends RealLocalizable> points = function.calculate(input).getVertices();
double distance = Double.NEGATIVE_INFINITY;
RealLocalizable p0 = points.get(0);
RealLocalizable p1 = points.get(0);
for (int i = 0; i < points.size(); i++) {
for (int j = i + 2; j < points.size(); j++) {
final RealLocalizable tmpP0 = points.get(i);
final RealLocalizable tmpP1 = points.get(j);
final double tmp = Math.sqrt(Math.pow(tmpP0.getDoublePosition(0) - tmpP1.getDoublePosition(0), 2)
+ Math.pow(tmpP0.getDoublePosition(1) - tmpP1.getDoublePosition(1), 2));
if (tmp > distance) {
distance = tmp;
p0 = tmpP0;
p1 = tmpP1;
}
}
}
return new ValuePair<>(p0, p1);
}
示例11: testAllBackground
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Test
public void testAllBackground() throws Exception {
// SETUP
final double expectedCount = Math.log(0.0);
final Img<BitType> img = ArrayImgs.bits(TEST_DIMS);
// EXECUTE
final List<ValuePair<DoubleType, DoubleType>> points = ops.topology()
.boxCount(img, MAX_SIZE, MIN_SIZE, SCALING);
// VERIFY
assertNotNull(points);
assertEquals(ITERATIONS, points.size());
for (int i = 0; i < ITERATIONS; i++) {
assertEquals(EXPECTED_SIZES[i], points.get(i).a.get(), 1e-12);
assertEquals(expectedCount, points.get(i).b.get(), 1e-12);
}
}
示例12: testAllForeground
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Test
public void testAllForeground() {
// SETUP
final double scalingPow = DoubleStream.generate(() -> SCALING).limit(
DIMENSIONS).reduce((i, j) -> i * j).orElse(0);
final double[] expectedCounts = DoubleStream.iterate(1.0, i -> i *
scalingPow).map(Math::log).limit(ITERATIONS).toArray();
final Img<BitType> img = ArrayImgs.bits(TEST_DIMS);
img.forEach(BitType::setOne);
// EXECUTE
final List<ValuePair<DoubleType, DoubleType>> points = ops.topology()
.boxCount(img, MAX_SIZE, MIN_SIZE, SCALING);
// VERIFY
for (int i = 0; i < ITERATIONS; i++) {
assertEquals(EXPECTED_SIZES[i], points.get(i).a.get(), 1e-12);
assertEquals(expectedCounts[i], points.get(i).b.get(), 1e-12);
}
}
示例13: testHyperCube
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Test
public void testHyperCube() {
// SETUP
final double[] expectedSizes = DoubleStream.of(4, 2, 1).map(i -> -Math.log(
i)).toArray();
final double[] expectedCounts = DoubleStream.of(1, 16, 16).map(Math::log)
.toArray();
final Img<BitType> img = ArrayImgs.bits(4, 4, 4, 4);
final IntervalView<BitType> hyperView = Views.offsetInterval(img,
new long[] { 1, 1, 1, 1 }, new long[] { 2, 2, 2, 2 });
hyperView.forEach(BitType::setOne);
// EXECUTE
final List<ValuePair<DoubleType, DoubleType>> points = ops.topology()
.boxCount(img, 4L, 1L, 2.0);
// VERIFY
for (int i = 0; i < expectedSizes.length; i++) {
assertEquals(expectedSizes[i], points.get(i).a.get(), 1e-12);
assertEquals(expectedCounts[i], points.get(i).b.get(), 1e-12);
}
}
示例14: testHyperCubeTranslations
import net.imglib2.util.ValuePair; //导入依赖的package包/类
/**
* Test box counting with a hyper cube and one grid translation (should find a
* better fit than in @see {@link #testHyperCube()})
*/
@Test
public void testHyperCubeTranslations() {
final double[] expectedSizes = DoubleStream.of(4, 2, 1).map(i -> -Math.log(
i)).toArray();
final double[] expectedCounts = DoubleStream.of(1, 1, 16).map(Math::log)
.toArray();
final Img<BitType> img = ArrayImgs.bits(4, 4, 4, 4);
final IntervalView<BitType> hyperView = Views.offsetInterval(img,
new long[] { 1, 1, 1, 1 }, new long[] { 2, 2, 2, 2 });
hyperView.forEach(BitType::setOne);
// EXECUTE
final List<ValuePair<DoubleType, DoubleType>> points = ops.topology()
.boxCount(img, 4L, 1L, 2.0, 1L);
// VERIFY
for (int i = 0; i < expectedSizes.length; i++) {
assertEquals(expectedSizes[i], points.get(i).a.get(), 1e-12);
assertEquals(expectedCounts[i], points.get(i).b.get(), 1e-12);
}
}
示例15: testOneVoxel
import net.imglib2.util.ValuePair; //导入依赖的package包/类
@Test
public void testOneVoxel() {
// SETUP
final PrimitiveIterator.OfDouble sizes = DoubleStream.of(9, 3, 1).map(
i -> -Math.log(i)).iterator();
final PrimitiveIterator.OfDouble counts = DoubleStream.of(1, 1, 1).map(
Math::log).iterator();
final Img<BitType> img = ArrayImgs.bits(9, 9, 9);
final RandomAccess<BitType> access = img.randomAccess();
access.setPosition(new long[] { 4, 4, 4 });
access.get().setOne();
// EXECUTE
final List<ValuePair<DoubleType, DoubleType>> points = ops.topology()
.boxCount(img, 9L, 3L, 3.0);
// VERIFY
points.forEach(p -> {
assertEquals(p.a.get(), sizes.next(), 1e-12);
assertEquals(p.b.get(), counts.next(), 1e-12);
});
}