use of com.forstudy.efjava.ch03.item10.Point in project imagej-ops by imagej.
the class NonCirculantNormalizationFactor method createNormalizationImageSemiNonCirculant.
protected void createNormalizationImageSemiNonCirculant() {
// k is the window size (valid image region)
final int length = k.numDimensions();
final long[] n = new long[length];
final long[] nFFT = new long[length];
// also referred to as object space size
for (int d = 0; d < length; d++) {
n[d] = k.dimension(d) + l.dimension(d) - 1;
}
for (int d = 0; d < length; d++) {
nFFT[d] = imgConvolutionInterval.dimension(d);
}
FinalDimensions fd = new FinalDimensions(nFFT);
// create the normalization image
normalization = create.calculate(fd);
// size of the measurement window
final Point size = new Point(length);
final long[] sizel = new long[length];
for (int d = 0; d < length; d++) {
size.setPosition(k.dimension(d), d);
sizel[d] = k.dimension(d);
}
// starting point of the measurement window when it is centered in fft space
final Point start = new Point(length);
final long[] startl = new long[length];
final long[] endl = new long[length];
for (int d = 0; d < length; d++) {
start.setPosition((nFFT[d] - k.dimension(d)) / 2, d);
startl[d] = (nFFT[d] - k.dimension(d)) / 2;
endl[d] = startl[d] + sizel[d] - 1;
}
// size of the object space
final Point maskSize = new Point(length);
final long[] maskSizel = new long[length];
for (int d = 0; d < length; d++) {
maskSize.setPosition(Math.min(n[d], nFFT[d]), d);
maskSizel[d] = Math.min(n[d], nFFT[d]);
}
// starting point of the object space within the fft space
final Point maskStart = new Point(length);
final long[] maskStartl = new long[length];
for (int d = 0; d < length; d++) {
maskStart.setPosition((Math.max(0, nFFT[d] - n[d]) / 2), d);
maskStartl[d] = (Math.max(0, nFFT[d] - n[d]) / 2);
}
final RandomAccessibleInterval<O> temp = Views.interval(normalization, new FinalInterval(startl, endl));
final Cursor<O> normCursor = Views.iterable(temp).cursor();
// draw a cube the size of the measurement space
while (normCursor.hasNext()) {
normCursor.fwd();
normCursor.get().setReal(1.0);
}
final Img<O> tempImg = create.calculate(fd);
// 3. correlate psf with the output of step 2.
correlater.compute(normalization, tempImg);
normalization = tempImg;
final Cursor<O> cursorN = normalization.cursor();
while (cursorN.hasNext()) {
cursorN.fwd();
if (cursorN.get().getRealFloat() <= 1e-3f) {
cursorN.get().setReal(1.0f);
}
}
}
use of com.forstudy.efjava.ch03.item10.Point in project java-mapollage by trixon.
the class Operation method addPolygons.
private void addPolygons(Folder polygonParent, List<Feature> features) {
for (Feature feature : features) {
if (feature instanceof Folder) {
Folder folder = (Folder) feature;
if (folder != mPathFolder && folder != mPathGapFolder && folder != mPolygonFolder) {
Folder polygonFolder = polygonParent.createAndAddFolder().withName(folder.getName()).withOpen(true);
mFolderPolygonInputs.put(polygonFolder, new ArrayList<>());
addPolygons(polygonFolder, folder.getFeature());
if (mFolderPolygonInputs.get(polygonFolder) != null) {
addPolygon(folder.getName(), mFolderPolygonInputs.get(polygonFolder), polygonParent);
}
}
}
if (feature instanceof Placemark) {
Placemark placemark = (Placemark) feature;
Point point = (Point) placemark.getGeometry();
ArrayList<Coordinate> coordinates = mFolderPolygonInputs.computeIfAbsent(polygonParent, k -> new ArrayList<>());
coordinates.addAll(point.getCoordinates());
}
}
ArrayList<Coordinate> rootCoordinates = mFolderPolygonInputs.get(mPolygonFolder);
if (polygonParent == mPolygonFolder && rootCoordinates != null) {
addPolygon(mPolygonFolder.getName(), rootCoordinates, polygonParent);
}
}
use of com.forstudy.efjava.ch03.item10.Point in project workbench by all-of-us.
the class WorkspaceAdminServiceImpl method getCloudStorageTraffic.
@Override
public CloudStorageTraffic getCloudStorageTraffic(String workspaceNamespace) {
CloudStorageTraffic response = new CloudStorageTraffic().receivedBytes(new ArrayList<>());
String googleProject = getWorkspaceByNamespaceOrThrow(workspaceNamespace).getGoogleProject();
for (TimeSeries timeSeries : cloudMonitoringService.getCloudStorageReceivedBytes(googleProject, TRAILING_TIME_TO_QUERY)) {
for (Point point : timeSeries.getPointsList()) {
response.addReceivedBytesItem(new TimeSeriesPoint().timestamp(Timestamps.toMillis(point.getInterval().getEndTime())).value(point.getValue().getDoubleValue()));
}
}
response.getReceivedBytes().sort(Comparator.comparing(TimeSeriesPoint::getTimestamp));
return response;
}
use of com.forstudy.efjava.ch03.item10.Point in project java-docs-samples by GoogleCloudPlatform.
the class BigQueryRunner method prepareMetric.
// Returns a metric time series with a single int64 data point.
private TimeSeries prepareMetric(MetricDescriptor requiredMetric, long metricValue) {
TimeInterval interval = TimeInterval.newBuilder().setEndTime(Timestamps.fromMillis(System.currentTimeMillis())).build();
TypedValue value = TypedValue.newBuilder().setInt64Value(metricValue).build();
Point point = Point.newBuilder().setInterval(interval).setValue(value).build();
List<Point> pointList = Lists.newArrayList();
pointList.add(point);
Metric metric = Metric.newBuilder().setType(requiredMetric.getName()).build();
return TimeSeries.newBuilder().setMetric(metric).addAllPoints(pointList).build();
}
use of com.forstudy.efjava.ch03.item10.Point in project java-docs-samples by GoogleCloudPlatform.
the class Snippets method writeTimeSeries.
/**
* Demonstrates writing a time series value for the metric type
* 'custom.google.apis.com/my_metric'.
*
* <p>This method assumes `my_metric` descriptor has already been created as a DOUBLE value_type
* and GAUGE metric kind. If the metric descriptor doesn't exist, it will be auto-created.
*/
// CHECKSTYLE OFF: VariableDeclarationUsageDistance
void writeTimeSeries() throws IOException {
// [START monitoring_write_timeseries]
String projectId = System.getProperty("projectId");
// Instantiates a client
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);
ProjectName name = ProjectName.of(projectId);
// 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(name.toString()).addAllTimeSeries(timeSeriesList).build();
// Writes time series data
metricServiceClient.createTimeSeries(request);
System.out.println("Done writing time series value.");
// [END monitoring_write_timeseries]
}
Aggregations