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;
}
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");
}
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;
}
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;
}
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;
}
}
Aggregations