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));
}
}
}
Aggregations