Search in sources :

Example 46 with Point

use of com.forstudy.efjava.ch03.item10.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());
}
Also used : Point(de.micromata.opengis.kml.v_2_2_0.Point) Test(org.junit.Test)

Example 47 with Point

use of com.forstudy.efjava.ch03.item10.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);
}
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) Set(java.util.Set) Label(sc.fiji.labkit.ui.labeling.Label) Point(net.imglib2.Point) Labeling(sc.fiji.labkit.ui.labeling.Labeling) ImgLabeling(net.imglib2.roi.labeling.ImgLabeling) Test(org.junit.Test)

Example 48 with Point

use of com.forstudy.efjava.ch03.item10.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");
    }
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) MetricServiceClient(com.google.cloud.monitoring.v3.MetricServiceClient) TimeInterval(com.google.monitoring.v3.TimeInterval) HashMap(java.util.HashMap) CreateTimeSeriesRequest(com.google.monitoring.v3.CreateTimeSeriesRequest) ArrayList(java.util.ArrayList) MonitoredResource(com.google.api.MonitoredResource) Point(com.google.monitoring.v3.Point) Metric(com.google.api.Metric) TypedValue(com.google.monitoring.v3.TypedValue)

Example 49 with Point

use of com.forstudy.efjava.ch03.item10.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);
    }
}
Also used : HyperSphere(net.imglib2.algorithm.region.hypersphere.HyperSphere) Point(net.imglib2.Point) Point(net.imglib2.Point)

Example 50 with Point

use of com.forstudy.efjava.ch03.item10.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;
}
Also used : Point(net.imglib2.Point) FloatType(net.imglib2.type.numeric.real.FloatType) ComplexFloatType(net.imglib2.type.numeric.complex.ComplexFloatType)

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