Search in sources :

Example 11 with PointRoi

use of ij.gui.PointRoi in project GDSC-SMLM by aherbert.

the class SpotInspector method mouseClicked.

public void mouseClicked(MouseEvent e) {
    if (id != currentId)
        return;
    // Show the result that was double clicked in the result table
    if (e.getClickCount() > 1) {
        int rank = textPanel.getSelectionStart() + 1;
        // Show the spot that was double clicked
        ImagePlus imp = WindowManager.getImage(TITLE);
        if (imp != null && rank > 0 && rank <= imp.getStackSize()) {
            imp.setSlice(rank);
            if (imp.getWindow() != null)
                imp.getWindow().toFront();
            // Add an ROI to to the image containing all the spots in that part of the frame
            PeakResult r = rankedResults.get(rank - 1).peakResult;
            final int x = (int) (r.params[Gaussian2DFunction.X_POSITION]);
            final int y = (int) (r.params[Gaussian2DFunction.Y_POSITION]);
            // Find bounds
            int minX = x - radius;
            int minY = y - radius;
            int maxX = x + radius + 1;
            int maxY = y + radius + 1;
            // Create ROIs
            ArrayList<float[]> spots = new ArrayList<float[]>();
            for (PeakResult peak : results.getResults()) {
                if (peak.getXPosition() > minX && peak.getXPosition() < maxX && peak.getYPosition() > minY && peak.getYPosition() < maxY) {
                    // Use only unique points
                    final float xPosition = peak.getXPosition() - minX;
                    final float yPosition = peak.getYPosition() - minY;
                    if (contains(spots, xPosition, yPosition))
                        continue;
                    spots.add(new float[] { xPosition, yPosition });
                }
            }
            int points = spots.size();
            float[] ox = new float[points];
            float[] oy = new float[points];
            for (int i = 0; i < points; i++) {
                ox[i] = spots.get(i)[0];
                oy[i] = spots.get(i)[1];
            }
            imp.setRoi(new PointRoi(ox, oy, points));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ImagePlus(ij.ImagePlus) PeakResult(gdsc.smlm.results.PeakResult) PointRoi(ij.gui.PointRoi)

Aggregations

PointRoi (ij.gui.PointRoi)11 ImagePlus (ij.ImagePlus)5 PeakResult (gdsc.smlm.results.PeakResult)4 Overlay (ij.gui.Overlay)4 Color (java.awt.Color)3 Rectangle (java.awt.Rectangle)3 ArrayList (java.util.ArrayList)3 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)2 ImageStack (ij.ImageStack)2 LUT (ij.process.LUT)2 BasePoint (gdsc.core.match.BasePoint)1 Coordinate (gdsc.core.match.Coordinate)1 MatchResult (gdsc.core.match.MatchResult)1 PointPair (gdsc.core.match.PointPair)1 MaximaSpotFilter (gdsc.smlm.filters.MaximaSpotFilter)1 Spot (gdsc.smlm.filters.Spot)1 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)1 FitResult (gdsc.smlm.fitting.FitResult)1 Gaussian2DFitter (gdsc.smlm.fitting.Gaussian2DFitter)1 IJImageSource (gdsc.smlm.ij.IJImageSource)1