public static <T extends Type<T> & Comparable<T>> int countLocalMaxima( final RandomAccessibleInterval<T> img, final Shape shape) { int nMaxima = 0; final RandomAccessibleInterval<T> source = Views.interval(img, Intervals.expand(img, -1)); final Cursor<T> center = Views.iterable(source).cursor(); A: for (final Neighborhood<T> neighborhood : shape.neighborhoods(source)) { final T c = center.next(); for (final T t : neighborhood) if (t.compareTo(c) > 0) continue A; ++nMaxima; } return nMaxima; }
public static <T extends Type<T> & Comparable<T>> int findLocalMaximaNeighborhood2( final RandomAccessibleInterval<T> img) { // final ArrayList< Point > maxima = new ArrayList< Point >(); int nMaxima = 0; final Cursor<T> center = Views.iterable(Views.interval(img, Intervals.expand(img, -1))).localizingCursor(); final LocalNeighborhood2<T> neighborhood = new LocalNeighborhood2<T>(img, center); final LocalNeighborhoodCursor2<T> nc = neighborhood.cursor(); A: while (center.hasNext()) { final T t = center.next(); neighborhood.updateCenter(center); nc.reset(); while (nc.hasNext()) { final T n = nc.next(); if (n.compareTo(t) > 0) continue A; } // maxima.add( new Point( center ) ); ++nMaxima; } return nMaxima; }
@Override public PointSet allOf(final Dataset ds) { return new HyperVolumePointSet(Intervals.dimensionsAsLongArray(ds)); }