Search in sources :

Example 1 with Point

use of effectivejava.chapter3.item10.Point in project bacmman by jeanollion.

the class SubPixelLocalizator method getPeaks.

public static List<Point> getPeaks(Image img, List<Region> objects) {
    List<Point> peaks = new ArrayList<>(objects.size());
    for (Region o : objects) {
        // get max value within map
        double max = Double.NEGATIVE_INFINITY;
        Voxel maxV = null;
        for (Voxel v : o.getVoxels()) {
            double value = img.getPixel(v.x, v.y, v.z);
            if (value > max) {
                max = value;
                maxV = v;
            }
        }
        if (img.sizeZ() > 1)
            peaks.add(new Point(maxV.x, maxV.y, maxV.z));
        else
            peaks.add(new Point(maxV.x, maxV.y));
    }
    return peaks;
}
Also used : Voxel(bacmman.data_structure.Voxel) ArrayList(java.util.ArrayList) Region(bacmman.data_structure.Region) Point(net.imglib2.Point)

Example 2 with Point

use of effectivejava.chapter3.item10.Point in project labkit-ui by juglab.

the class FloodFillTest method test2.

@Test
public void test2() {
    RandomAccessibleInterval<LabelingType<String>> labeling = exampleImgLabeling();
    Predicate<LabelingType<String>> visit = set -> set.contains("a") && set.contains("b") && !set.contains("ab");
    final Point seed = new Point(2, 2);
    FloodFill.cachedFloodFill(labeling, seed, visit, l -> l.add("ab"));
    assertLabelEqualsInterval(labeling, intervalA, "a");
    assertLabelEqualsInterval(labeling, intervalB, "b");
    assertLabelEqualsInterval(labeling, intervalC, "c");
    assertLabelEqualsInterval(labeling, intervalAintersectB, "ab");
}
Also used : BitType(net.imglib2.type.logic.BitType) Point(net.imglib2.Point) Predicate(java.util.function.Predicate) Set(java.util.Set) Test(org.junit.Test) Consumer(java.util.function.Consumer) Intervals(net.imglib2.util.Intervals) Cursor(net.imglib2.Cursor) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) LabelingType(net.imglib2.roi.labeling.LabelingType) ArrayImgs(net.imglib2.img.array.ArrayImgs) ImgLabeling(net.imglib2.roi.labeling.ImgLabeling) Interval(net.imglib2.Interval) Label(sc.fiji.labkit.ui.labeling.Label) Views(net.imglib2.view.Views) Assert.assertEquals(org.junit.Assert.assertEquals) Point(net.imglib2.Point) LabelingType(net.imglib2.roi.labeling.LabelingType) Test(org.junit.Test)

Example 3 with Point

use of effectivejava.chapter3.item10.Point in project labkit-ui by juglab.

the class SparseRandomAccessIntTypeBenchmark2 method floodfill.

@Benchmark
public int floodfill() {
    sparse.clear();
    FloodFill.fill(Views.extendValue(sparse, 255), sparse, new Point(10, 10, 10), new IntType(7), new DiamondShape(1));
    return dummyResult;
}
Also used : DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) Point(net.imglib2.Point) IntType(net.imglib2.type.numeric.integer.IntType)

Example 4 with Point

use of effectivejava.chapter3.item10.Point in project bacmman by jeanollion.

the class Curvature method getCurvatureWatershedMap.

public static ImageFloat getCurvatureWatershedMap(final Image edm, final ImageInteger mask, KDTree<Double> curvature) {
    final ImageFloat res = new ImageFloat("CurvatureWatershedMap", edm);
    final NearestNeighborSearchOnKDTree<Double> search = new NearestNeighborSearchOnKDTree(curvature);
    final TreeSet<Voxel> heap = new TreeSet<>(Voxel.getComparator());
    final EllipsoidalNeighborhood neigh = new EllipsoidalNeighborhood(1.5, true);
    // initialize with the border of objects
    BoundingBox.loop(mask.getBoundingBox().resetOffset(), (int x, int y, int z) -> {
        if (mask.insideMask(x, y, z) && neigh.hasNullValue(x, y, z, mask, true)) {
            double edmValue = edm.getPixel(x, y, z);
            search.search(new Point(x + mask.xMin(), y + mask.yMin()));
            res.setPixel(x, y, z, search.getSampler().get());
            Voxel next;
            for (int i = 0; i < neigh.getSize(); ++i) {
                next = new Voxel(x + neigh.dx[i], y + neigh.dy[i], 0);
                if (!mask.contains(next.x, next.y, next.z) || !mask.insideMask(x, y, z))
                    continue;
                next.value = edm.getPixel(next.x, next.y, 0);
                if (next.value > edmValue)
                    heap.add(next);
            }
        }
    });
    Voxel next;
    while (!heap.isEmpty()) {
        Voxel v = heap.pollFirst();
        double value = 0, count = 0;
        for (int i = 0; i < neigh.getSize(); ++i) {
            next = new Voxel(v.x + neigh.dx[i], v.y + neigh.dy[i], 0);
            next.value = edm.getPixel(next.x, next.y, next.z);
            if (next.value > v.value)
                heap.add(next);
            else {
                value += res.getPixel(next.x, next.y, 0);
                ++count;
                if (count > 0)
                    res.setPixel(v.x, v.y, 0, value / count);
            }
        }
    }
    return res;
}
Also used : NearestNeighborSearchOnKDTree(net.imglib2.neighborsearch.NearestNeighborSearchOnKDTree) Voxel(bacmman.data_structure.Voxel) TreeSet(java.util.TreeSet) EllipsoidalNeighborhood(bacmman.processing.neighborhood.EllipsoidalNeighborhood) Point(net.imglib2.Point) RealPoint(net.imglib2.RealPoint) ImageFloat(bacmman.image.ImageFloat) Point(net.imglib2.Point) RealPoint(net.imglib2.RealPoint)

Example 5 with Point

use of effectivejava.chapter3.item10.Point in project fdb-record-layer by FoundationDB.

the class GeophilePointWithinDistanceQueryPlan method getFilter.

@Nullable
@Override
protected SpatialJoin.Filter<RecordWithSpatialObject, GeophileRecordImpl> getFilter(@Nonnull EvaluationContext context) {
    if (covering) {
        Double distanceValue = distance.getValue(context);
        Double centerLatitudeValue = centerLatitude.getValue(context);
        Double centerLongitudeValue = centerLongitude.getValue(context);
        if (distanceValue == null || centerLatitudeValue == null || centerLongitudeValue == null) {
            return null;
        }
        final GeometryFactory geometryFactory = new GeometryFactory();
        final Geometry center = geometryFactory.createPoint(new Coordinate(centerLatitudeValue, centerLongitudeValue));
        return (spatialObject, record) -> {
            Point point = (Point) record.spatialObject();
            Geometry geometry = geometryFactory.createPoint(new Coordinate(point.x(), point.y()));
            return geometry.isWithinDistance(center, distanceValue);
        };
    } else {
        return null;
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) IndexEntry(com.apple.foundationdb.record.IndexEntry) BiFunction(java.util.function.BiFunction) Coordinate(org.locationtech.jts.geom.Coordinate) RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) SpatialObject(com.geophile.z.SpatialObject) PlanHashable(com.apple.foundationdb.record.PlanHashable) Tuple(com.apple.foundationdb.tuple.Tuple) ImmutableList(com.google.common.collect.ImmutableList) Attribute(com.apple.foundationdb.record.query.plan.temp.explain.Attribute) Map(java.util.Map) AliasMap(com.apple.foundationdb.record.query.plan.temp.AliasMap) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) DoubleValueOrParameter(com.apple.foundationdb.record.spatial.common.DoubleValueOrParameter) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) SpatialJoin(com.geophile.z.SpatialJoin) RecordWithSpatialObject(com.geophile.z.index.RecordWithSpatialObject) ImmutableMap(com.google.common.collect.ImmutableMap) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) QueriedValue(com.apple.foundationdb.record.query.predicates.QueriedValue) RelationalExpression(com.apple.foundationdb.record.query.plan.temp.RelationalExpression) Objects(java.util.Objects) Value(com.apple.foundationdb.record.query.predicates.Value) List(java.util.List) Point(com.geophile.z.spatialobject.d2.Point) EvaluationContext(com.apple.foundationdb.record.EvaluationContext) ObjectPlanHash(com.apple.foundationdb.record.ObjectPlanHash) Geometry(org.locationtech.jts.geom.Geometry) API(com.apple.foundationdb.annotation.API) PlannerGraph(com.apple.foundationdb.record.query.plan.temp.explain.PlannerGraph) NodeInfo(com.apple.foundationdb.record.query.plan.temp.explain.NodeInfo) AvailableFields(com.apple.foundationdb.record.query.plan.AvailableFields) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) Point(com.geophile.z.spatialobject.d2.Point) Nullable(javax.annotation.Nullable)

Aggregations

Point (net.imglib2.Point)33 ArrayList (java.util.ArrayList)16 FloatType (net.imglib2.type.numeric.real.FloatType)11 Test (org.junit.Test)9 List (java.util.List)8 Point (com.google.monitoring.v3.Point)7 Point (hr.fer.oop.recap2.task2.Point)7 FinalInterval (net.imglib2.FinalInterval)7 RealPoint (net.imglib2.RealPoint)7 TimeSeries (com.google.monitoring.v3.TimeSeries)6 Point (de.micromata.opengis.kml.v_2_2_0.Point)6 Interval (net.imglib2.Interval)6 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)6 HyperSphere (net.imglib2.algorithm.region.hypersphere.HyperSphere)6 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)6 HashMap (java.util.HashMap)5 Metric (com.google.api.Metric)4 TimeInterval (com.google.monitoring.v3.TimeInterval)4 TypedValue (com.google.monitoring.v3.TypedValue)4 Map (java.util.Map)4