Search in sources :

Example 1 with ImageJ3DResultsViewerSettingsOrBuilder

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;
}
Also used : Color(java.awt.Color) Arrays(java.util.Arrays) PickInfo(org.scijava.java3d.PickInfo) IndexedGeometryArray(org.scijava.java3d.IndexedGeometryArray) ItemGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGroup) GUI(ij.gui.GUI) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) TransparentItemShape(uk.ac.sussex.gdsc.smlm.ij.ij3d.TransparentItemShape) Future(java.util.concurrent.Future) Pair(org.apache.commons.lang3.tuple.Pair) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) Map(java.util.Map) FitProtosHelper(uk.ac.sussex.gdsc.smlm.data.config.FitProtosHelper) ImageWindow3D(ij3d.ImageWindow3D) Triple(org.apache.commons.lang3.tuple.Triple) LutHelper(uk.ac.sussex.gdsc.core.ij.process.LutHelper) KeyStroke(javax.swing.KeyStroke) Appearance(org.scijava.java3d.Appearance) CustomMesh(customnode.CustomMesh) ImageCanvas3D(ij3d.ImageCanvas3D) Rendering(uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper.Rendering) InputSource(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsManager.InputSource) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap) ImageJ3DResultsViewerSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings) UniverseSettings(ij3d.UniverseSettings) NamedObject(uk.ac.sussex.gdsc.smlm.data.NamedObject) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) ItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGeometryGroup) StopWatch(org.apache.commons.lang3.time.StopWatch) RawResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.RawResultProcedure) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) TextUtils(uk.ac.sussex.gdsc.core.utils.TextUtils) Executors(java.util.concurrent.Executors) ImagePlus(ij.ImagePlus) PlugIn(ij.plugin.PlugIn) WindowConstants(javax.swing.WindowConstants) Color3f(org.scijava.vecmath.Color3f) ListSelectionModel(javax.swing.ListSelectionModel) TransformGroup(org.scijava.java3d.TransformGroup) PeakResultProcedureX(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedureX) XyzResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.XyzResultProcedure) WindowManager(ij.WindowManager) PeakResult(uk.ac.sussex.gdsc.smlm.results.PeakResult) Point3f(org.scijava.vecmath.Point3f) Point3d(org.scijava.vecmath.Point3d) ContentNode(ij3d.ContentNode) SortUtils(uk.ac.sussex.gdsc.core.utils.SortUtils) CustomPointMesh(customnode.CustomPointMesh) RounderUtils(uk.ac.sussex.gdsc.core.data.utils.RounderUtils) PeakResultTableModel(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel) PeakResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure) CustomLineMesh(customnode.CustomLineMesh) ItemPointMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemPointMesh) GeometryArray(org.scijava.java3d.GeometryArray) Field(java.lang.reflect.Field) IntersectionInfo(org.scijava.java3d.PickInfo.IntersectionInfo) Point2d(org.scijava.vecmath.Point2d) MouseEvent(java.awt.event.MouseEvent) ExecutionException(java.util.concurrent.ExecutionException) ReferenceItemMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ReferenceItemMesh) Canvas3D(org.scijava.java3d.Canvas3D) MouseMotionListener(java.awt.event.MouseMotionListener) LineAttributes(org.scijava.java3d.LineAttributes) ItemTriangleMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemTriangleMesh) ResultsTableSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsTableSettings) ListSelectionListener(javax.swing.event.ListSelectionListener) UniverseListener(ij3d.UniverseListener) TransparentItemTriangleMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.TransparentItemTriangleMesh) Builder(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings.Builder) StandardResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.StandardResultProcedure) TriangleArray(org.scijava.java3d.TriangleArray) Transform3D(org.scijava.java3d.Transform3D) CustomContentHelper(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContentHelper) PointAttributes(org.scijava.java3d.PointAttributes) SplitMix(uk.ac.sussex.gdsc.core.utils.rng.SplitMix) ItemGroupNode(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGroupNode) Content(ij3d.Content) PickCanvas(org.scijava.java3d.utils.pickfast.PickCanvas) ItemShape(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemShape) TransparentItemPointMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.TransparentItemPointMesh) CoordinatePredicateUtils(uk.ac.sussex.gdsc.core.ij.roi.CoordinatePredicateUtils) XyResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.XyResultProcedure) CustomContent(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContent) Image3DUniverse(ij3d.Image3DUniverse) Locale(java.util.Locale) ListSelectionModelHelper(uk.ac.sussex.gdsc.smlm.ij.gui.ListSelectionModelHelper) MouseAdapter(java.awt.event.MouseAdapter) DataException(uk.ac.sussex.gdsc.core.data.DataException) ColoringAttributes(org.scijava.java3d.ColoringAttributes) MacroRunner(ij.macro.MacroRunner) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) ListSelectionEvent(javax.swing.event.ListSelectionEvent) UpdateableItemShape(uk.ac.sussex.gdsc.smlm.ij.ij3d.UpdateableItemShape) MouseListener(java.awt.event.MouseListener) SettingsManager(uk.ac.sussex.gdsc.smlm.ij.settings.SettingsManager) JMenuBar(javax.swing.JMenuBar) CoordinatePredicate(uk.ac.sussex.gdsc.core.ij.roi.CoordinatePredicate) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JMenu(javax.swing.JMenu) WindowEvent(java.awt.event.WindowEvent) List(java.util.List) PeakResultTableModelFrame(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame) OrderedItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.OrderedItemGeometryGroup) Modifier(java.lang.reflect.Modifier) SimpleArrayUtils(uk.ac.sussex.gdsc.core.utils.SimpleArrayUtils) Shape3DHelper(uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper) TransparencyAttributes(org.scijava.java3d.TransparencyAttributes) LUT(ij.process.LUT) SceneGraphPath(org.scijava.java3d.SceneGraphPath) TypeConverter(uk.ac.sussex.gdsc.core.data.utils.TypeConverter) Roi(ij.gui.Roi) PolygonAttributes(org.scijava.java3d.PolygonAttributes) PrecisionResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.PrecisionResultProcedure) PrecisionMethod(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.PrecisionMethod) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) TextField(java.awt.TextField) OptionListener(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog.OptionListener) ItemMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemMesh) JMenuItem(javax.swing.JMenuItem) ImageJTrackProgress(uk.ac.sussex.gdsc.core.ij.ImageJTrackProgress) CustomMeshNode(customnode.CustomMeshNode) View(org.scijava.java3d.View) ExecutorService(java.util.concurrent.ExecutorService) Shape3D(org.scijava.java3d.Shape3D) DefaultUniverse(ij3d.DefaultUniverse) TFloatArrayList(gnu.trove.list.array.TFloatArrayList) Vector3d(org.scijava.vecmath.Vector3d) PeakResultsDigest(uk.ac.sussex.gdsc.smlm.results.PeakResultsDigest) Iterator(java.util.Iterator) BranchGroup(org.scijava.java3d.BranchGroup) AxisAngle4d(org.scijava.vecmath.AxisAngle4d) Image3DMenubar(ij3d.Image3DMenubar) LutColour(uk.ac.sussex.gdsc.core.ij.process.LutHelper.LutColour) Ticker(uk.ac.sussex.gdsc.core.logging.Ticker) ActionEvent(java.awt.event.ActionEvent) ContentInstant(ij3d.ContentInstant) Rounder(uk.ac.sussex.gdsc.core.data.utils.Rounder) TimeUnit(java.util.concurrent.TimeUnit) CustomContentInstant(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContentInstant) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) IJ(ij.IJ) Nullable(uk.ac.sussex.gdsc.core.annotation.Nullable) ImageJ3DResultsViewerSettingsOrBuilder(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettingsOrBuilder) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Point3f(org.scijava.vecmath.Point3f) SplitMix(uk.ac.sussex.gdsc.core.utils.rng.SplitMix) StandardResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.StandardResultProcedure)

Example 2 with ImageJ3DResultsViewerSettingsOrBuilder

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);
}
Also used : Vector3d(org.scijava.vecmath.Vector3d) Point3d(org.scijava.vecmath.Point3d) ImageJ3DResultsViewerSettingsOrBuilder(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettingsOrBuilder)

Aggregations

CustomLineMesh (customnode.CustomLineMesh)1 CustomMesh (customnode.CustomMesh)1 CustomMeshNode (customnode.CustomMeshNode)1 CustomPointMesh (customnode.CustomPointMesh)1 TFloatArrayList (gnu.trove.list.array.TFloatArrayList)1 TObjectIntHashMap (gnu.trove.map.hash.TObjectIntHashMap)1 IJ (ij.IJ)1 ImagePlus (ij.ImagePlus)1 WindowManager (ij.WindowManager)1 GUI (ij.gui.GUI)1 Roi (ij.gui.Roi)1 MacroRunner (ij.macro.MacroRunner)1 PlugIn (ij.plugin.PlugIn)1 LUT (ij.process.LUT)1 Content (ij3d.Content)1 ContentInstant (ij3d.ContentInstant)1 ContentNode (ij3d.ContentNode)1 DefaultUniverse (ij3d.DefaultUniverse)1 Image3DMenubar (ij3d.Image3DMenubar)1 Image3DUniverse (ij3d.Image3DUniverse)1