本文整理汇总了Java中ij.gui.Roi.FREEROI属性的典型用法代码示例。如果您正苦于以下问题:Java Roi.FREEROI属性的具体用法?Java Roi.FREEROI怎么用?Java Roi.FREEROI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类ij.gui.Roi
的用法示例。
在下文中一共展示了Roi.FREEROI属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doWand
/** Traces the boundary of the area with pixel values within
* 'tolerance' of the value of the pixel at the starting location.
* 'tolerance' is in uncalibrated units.
* 'mode' can be "4-connected", "8-connected" or "Legacy".
* "Legacy" is for compatibility with previous versions of ImageJ;
* it is ignored if 'tolerance' > 0.
*/
public static int doWand(int x, int y, double tolerance, String mode) {
ImagePlus img = getImage();
ImageProcessor ip = img.getProcessor();
if ((img.getType()==ImagePlus.GRAY32) && Double.isNaN(ip.getPixelValue(x,y)))
return 0;
int imode = Wand.LEGACY_MODE;
if (mode!=null) {
if (mode.startsWith("4"))
imode = Wand.FOUR_CONNECTED;
else if (mode.startsWith("8"))
imode = Wand.EIGHT_CONNECTED;
}
Wand w = new Wand(ip);
double t1 = ip.getMinThreshold();
if (t1==ImageProcessor.NO_THRESHOLD || (ip.getLutUpdateMode()==ImageProcessor.NO_LUT_UPDATE&& tolerance>0.0))
w.autoOutline(x, y, tolerance, imode);
else
w.autoOutline(x, y, t1, ip.getMaxThreshold(), imode);
if (w.npoints>0) {
Roi previousRoi = img.getRoi();
int type = Wand.allPoints()?Roi.FREEROI:Roi.TRACED_ROI;
Roi roi = new PolygonRoi(w.xpoints, w.ypoints, w.npoints, type);
img.killRoi();
img.setRoi(roi);
// add/subtract this ROI to the previous one if the shift/alt key is down
if (previousRoi!=null)
roi.update(shiftKeyDown(), altKeyDown());
}
return w.npoints;
}
示例2: roiMeasurements
private void roiMeasurements(final ImagePlus imp, final double min, final double max) {
final Roi initialRoi = imp.getRoi();
final int xMin = imp.getImageStack().getRoi().x;
double[] feretValues = new double[3];
this.feretAngle = new double[this.al];
this.feretMax = new double[this.al];
this.feretMin = new double[this.al];
this.perimeter = new double[this.al];
this.principalDiameter = new double[this.al];
this.secondaryDiameter = new double[this.al];
final int initialSlice = imp.getCurrentSlice();
// for the required slices...
for (int s = this.startSlice; s <= this.endSlice; s++) {
final ImageProcessor ip = imp.getImageStack().getProcessor(s);
final Wand w = new Wand(ip);
w.autoOutline(xMin, (int) Math.round(this.sliceCentroids[1][s] / this.vH), min, max, Wand.EIGHT_CONNECTED);
if (this.emptySlices[s] || w.npoints == 0) {
this.feretMin[s] = Double.NaN;
this.feretAngle[s] = Double.NaN;
this.feretMax[s] = Double.NaN;
this.perimeter[s] = Double.NaN;
this.principalDiameter[s] = Double.NaN;
this.secondaryDiameter[s] = Double.NaN;
continue;
}
final int type = Wand.allPoints() ? Roi.FREEROI : Roi.TRACED_ROI;
final PolygonRoi roi = new PolygonRoi(w.xpoints, w.ypoints, w.npoints, type);
feretValues = roi.getFeretValues();
this.feretMin[s] = feretValues[2] * this.vW;
this.feretAngle[s] = feretValues[1] * Math.PI / 180;
this.feretMax[s] = feretValues[0] * this.vW;
this.perimeter[s] = roi.getLength() * this.vW;
if (this.doOriented && orienteer != null) {
final double[][] points = new double[w.npoints][2];
for (int i = 0; i < w.npoints; i++) {
points[i][0] = w.xpoints[i] * this.vW;
points[i][1] = w.ypoints[i] * this.vH;
}
final double[] diameters = orienteer.getDiameters(points);
this.principalDiameter[s] = diameters[0];
this.secondaryDiameter[s] = diameters[1];
}
feretValues = null;
}
IJ.setSlice(initialSlice);
imp.setRoi(initialRoi);
return;
}