use of uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettingsOrBuilder in project GDSC-SMLM by aherbert.
the class ImageJ3DResultsViewer method getPoints.
/**
* Gets the points.
*
* @param results the results
* @param settings the settings
* @return the points
*/
static LocalList<Point3f> getPoints(MemoryPeakResults results, ImageJ3DResultsViewerSettingsOrBuilder settings) {
final LocalList<Point3f> points = new LocalList<>(results.size());
if (results.is3D()) {
results.forEach(DistanceUnit.NM, (XyzResultProcedure) (x, y, z) -> {
points.push(new Point3f(x, y, z));
});
} else {
results.forEach(DistanceUnit.NM, (XyResultProcedure) (x, y) -> {
points.push(new Point3f(x, y, 0));
});
final double range = settings.getDepthRange();
if (range > 0 && results.size() > 1) {
final DepthMode mode = DepthMode.forNumber(settings.getDepthMode());
final double min = -settings.getDepthRange() / 2;
switch(mode) {
case DITHER:
final SplitMix r = SplitMix.new64(settings.getDitherSeed());
for (int i = points.size(); i-- > 0; ) {
points.unsafeGet(i).z += (min + r.nextDouble() * range);
}
break;
case INTENSITY:
// Rank by intensity, highest first
final StandardResultProcedure p = new StandardResultProcedure(results);
p.getI();
final int[] indices = SimpleArrayUtils.natural(results.size());
SortUtils.sortIndices(indices, p.intensity, true);
final double inc = range / indices.length;
for (int i = 0; i < indices.length; i++) {
// The standard rendering has +z going away so put the highest rank at min
points.unsafeGet(indices[i]).z += (min + i * inc);
}
break;
case NONE:
break;
default:
throw new IllegalStateException("Unknown depth mode: " + mode);
}
}
}
return points;
}
use of uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettingsOrBuilder in project GDSC-SMLM by aherbert.
the class ImageJ3DResultsViewer method sortPerspective.
private static void sortPerspective(ResultsMetaData data) {
final ImageJ3DResultsViewerSettingsOrBuilder settings = data.settings;
final Vector3d direction = getViewDirection(data.settings);
if (direction == null) {
throw new IllegalStateException("The view direction is not valid");
}
final Point3d eye = new Point3d(settings.getSortEyeX(), settings.getSortEyeY(), settings.getSortEyeZ());
final double[] d = getDistance(data.points, direction, eye);
final int[] indices = SimpleArrayUtils.natural(d.length);
SortUtils.sortIndices(indices, d, true);
reorder(indices, data);
}
Aggregations