use of com.geophile.z.spatialobject.d2.Point in project ddf by codice.
the class KmlToJtsPointConverterTest method testKmlPointWithNoCoordinatesReturnsNullJtsPoint.
@Test
public void testKmlPointWithNoCoordinatesReturnsNullJtsPoint() {
org.locationtech.jts.geom.Point jtsPoint = KmlToJtsPointConverter.from(new Point());
assertThat(jtsPoint, nullValue());
}
use of com.geophile.z.spatialobject.d2.Point in project labkit-ui by juglab.
the class FloodFillTest method test3.
@Test
public void test3() {
Labeling labeling = Labeling.fromImgLabeling(exampleImgLabeling());
final Point seed = new Point(2, 2);
Label a = labeling.getLabel("a");
Label b = labeling.getLabel("b");
Label c = labeling.getLabel("c");
c.setVisible(false);
Label ab = labeling.addLabel("ab");
final Consumer<Set<Label>> operation = l -> l.add(ab);
FloodFill.doFloodFillOnActiveLabels((RandomAccessibleInterval) labeling, seed, operation);
assertLabelEqualsInterval(labeling, intervalA, a);
assertLabelEqualsInterval(labeling, intervalB, b);
assertLabelEqualsInterval(labeling, intervalC, c);
assertLabelEqualsInterval(labeling, intervalAintersectB, ab);
}
use of com.geophile.z.spatialobject.d2.Point in project java-monitoring by googleapis.
the class CreateTimeSeries method createTimeSeries.
public static void createTimeSeries(String projectId) throws ApiException, IOException {
// Instantiates a client
try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
// Prepares an individual data point
TimeInterval interval = TimeInterval.newBuilder().setEndTime(Timestamps.fromMillis(System.currentTimeMillis())).build();
TypedValue value = TypedValue.newBuilder().setDoubleValue(123.45).build();
Point point = Point.newBuilder().setInterval(interval).setValue(value).build();
List<Point> pointList = new ArrayList<>();
pointList.add(point);
// Prepares the metric descriptor
Map<String, String> metricLabels = new HashMap<>();
Metric metric = Metric.newBuilder().setType("custom.googleapis.com/my_metric").putAllLabels(metricLabels).build();
// Prepares the monitored resource descriptor
Map<String, String> resourceLabels = new HashMap<>();
resourceLabels.put("instance_id", "1234567890123456789");
resourceLabels.put("zone", "us-central1-f");
MonitoredResource resource = MonitoredResource.newBuilder().setType("gce_instance").putAllLabels(resourceLabels).build();
// Prepares the time series request
TimeSeries timeSeries = TimeSeries.newBuilder().setMetric(metric).setResource(resource).addAllPoints(pointList).build();
List<TimeSeries> timeSeriesList = new ArrayList<>();
timeSeriesList.add(timeSeries);
CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder().setName(ProjectName.of(projectId).toString()).addAllTimeSeries(timeSeriesList).build();
// Writes time series data
metricServiceClient.createTimeSeries(request);
System.out.println("Done writing time series value");
}
}
use of com.geophile.z.spatialobject.d2.Point in project multiview-simulation by PreibischLab.
the class SimulateMultiViewDataset method drawSpheres.
/**
* Draws a sphere that contains lots of small spheres into the center of the interval
*
* @param randomAccessible - the image data to write to
* @param minValue - the minimal intensity of one of the small spheres
* @param maxValue - the maximal intensity of one of the small spheres
* @param scale - the scale
* @param rnd - the random number generator
* @param <T> - the type
*/
public static <T extends RealType<T>> void drawSpheres(final RandomAccessibleInterval<T> randomAccessible, final double minValue, final double maxValue, final int scale, final boolean halfPixelOffset, final Random rnd) {
// the number of dimensions
int numDimensions = randomAccessible.numDimensions();
// define the center and radius
Point center = new Point(randomAccessible.numDimensions());
long minSize = randomAccessible.dimension(0);
for (int d = 0; d < numDimensions; ++d) {
long size = randomAccessible.dimension(d);
center.setPosition(size / 2, d);
minSize = Math.min(minSize, size);
}
// define the maximal radius of the small spheres
int maxRadius = 10 * scale;
// compute the radius of the large sphere so that we do not draw
// outside of the defined interval
long radiusLargeSphere = minSize / 2 - 47 * scale - 1;
// instantiate a random number generator
// Random rnd = new Random( System.currentTimeMillis() );
// define a hypersphere (n-dimensional sphere)
HyperSphere<T> hyperSphere = new HyperSphere<T>(randomAccessible, center, radiusLargeSphere);
// create a cursor on the hypersphere
HyperSphereCursor<T> cursor = hyperSphere.cursor();
int size = (int) hyperSphere.size();
IJ.showProgress(0.0);
int i = 0;
while (cursor.hasNext()) {
cursor.fwd();
// the random radius of the current small hypersphere
int radius = rnd.nextInt(maxRadius) + 1;
// instantiate a small hypersphere at the location of the current pixel
// in the large hypersphere
final HyperSphere<T> smallSphere;
if (halfPixelOffset) {
// shifting by one pixel in xy means half a pixel after downsampling
final long[] tmp = new long[randomAccessible.numDimensions()];
cursor.localize(tmp);
for (int d = 0; d < tmp.length - 1; ++d) tmp[d] += 1;
smallSphere = new HyperSphere<T>(randomAccessible, new Point(tmp), radius);
} else {
smallSphere = new HyperSphere<T>(randomAccessible, cursor, radius);
}
// define the random intensity for this small sphere
double randomValue = rnd.nextDouble();
// take only every 4^dimension'th pixel by chance so that it is not too crowded
if (Math.round(randomValue * 10000) % Util.pow(7 * scale, numDimensions) == 0) {
// scale to right range
randomValue = rnd.nextDouble() * (maxValue - minValue) + minValue;
// brighter than the existing one
for (final T value : smallSphere) value.setReal(Math.max(randomValue, value.getRealDouble()));
}
IJ.showProgress(++i, size);
}
}
use of com.geophile.z.spatialobject.d2.Point in project multiview-simulation by PreibischLab.
the class SimulateMultiViewDataset method attenuate3d.
public static Img<FloatType> attenuate3d(final RandomAccessibleInterval<FloatType> randomAccessible, final double delta) {
// the attenuated image
final Img<FloatType> img = new ArrayImgFactory<FloatType>().create(randomAccessible, new FloatType());
// make a plane that only contains x & z, this is the origin for the attenuation along y
final RandomAccessibleInterval<FloatType> startMatrix = Views.hyperSlice(randomAccessible, 1, 0);
final Cursor<FloatType> c = Views.iterable(startMatrix).localizingCursor();
final RandomAccess<FloatType> rIn = randomAccessible.randomAccess();
final RandomAccess<FloatType> rOut = img.randomAccess();
final int[] l = new int[3];
while (c.hasNext()) {
c.fwd();
l[0] = c.getIntPosition(0);
l[1] = (int) randomAccessible.dimension(1) - 1;
l[2] = c.getIntPosition(1);
rIn.setPosition(l);
rOut.setPosition(l);
// light intensity goes down from 1...0 depending on the image intensities
double n = 1;
for (int y = 0; y < randomAccessible.dimension(0); ++y) {
final double v = rIn.get().get();
// probability that light is absorbed at this point
final double phiN = v * delta * n;
// n is >=0
n = Math.max(n - phiN, 0);
// set attenuated intensity
rOut.get().set((float) (v * n));
rIn.bck(1);
rOut.bck(1);
}
}
return img;
}
Aggregations