Commit 9135315c authored by Aliaksandr Halavatyi's avatar Aliaksandr Halavatyi
Browse files

Add function to select set of Randon ROIs to Particle filterer

parent 470473f3
package automic.utils.roi;
import java.awt.Polygon;
import java.util.Random;
import automic.utils.ArrIndUtils;
import ij.IJ;
......@@ -335,6 +336,25 @@ public class ParticleFilterer{
}
}
public void selectRandomObjects(int _nsel)throws Exception{
Random rand=new Random();
int[] passedInds=this.getPassedInds();
int nPassed=passedInds.length;
if (nPassed<_nsel)
throw new Exception("ParticleFilterer.selectObjects: specified number of objects to select bigger that number of available objects");
while(passedInds.length>_nsel) {
int testInd=passedInds[rand.nextInt(passedInds.length)];
Passed[testInd]=false;
passedInds=getPassedInds();
}
}
private double getPolygonArea(Polygon p) {
if (p==null) return Double.NaN;
int carea = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment