本文整理汇总了Java中ij.gui.Roi.isArea方法的典型用法代码示例。如果您正苦于以下问题:Java Roi.isArea方法的具体用法?Java Roi.isArea怎么用?Java Roi.isArea使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.gui.Roi
的用法示例。
在下文中一共展示了Roi.isArea方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToPathROI
import ij.gui.Roi; //导入方法依赖的package包/类
/**
* Create a ROI from an ImageJ Roi.
*
* @param pathROI
* @param pathImage
* @return
*/
public static ROI convertToPathROI(Roi roi, Calibration cal, double downsampleFactor, final int c, final int z, final int t) {
// if (roi.getType() == Roi.POLYGON || roi.getType() == Roi.TRACED_ROI)
// return convertToPolygonROI((PolygonRoi)roi, cal, downsampleFactor);
if (roi.getType() == Roi.RECTANGLE && roi.getCornerDiameter() == 0)
return getRectangleROI(roi, cal, downsampleFactor, c, z, t);
if (roi.getType() == Roi.OVAL)
return convertToEllipseROI(roi, cal, downsampleFactor, c, z, t);
if (roi instanceof Line)
return convertToLineROI((Line)roi, cal, downsampleFactor, c, z, t);
if (roi instanceof PointRoi)
return convertToPointROI((PolygonRoi)roi, cal, downsampleFactor, c, z, t);
// if (roi instanceof ShapeRoi)
// return convertToAreaROI((ShapeRoi)roi, cal, downsampleFactor);
// // Shape ROIs should be able to handle most eventualities
if (roi instanceof ShapeRoi)
return convertToAreaROI((ShapeRoi)roi, cal, downsampleFactor, c, z, t);
if (roi.isArea())
return convertToPolygonOrAreaROI(roi, cal, downsampleFactor, c, z, t);
// TODO: Integrate ROI not supported exception...?
return null;
}
示例2: actionPerformed
import ij.gui.Roi; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e)
{
ImagePlus imp = WindowManager.getImage(results.getName() + " " + TITLE);
if (imp == null || output == null)
return;
// List the ROIs
Roi imageRoi = imp.getRoi();
if (imageRoi == null || !imageRoi.isArea())
return;
Roi[] rois;
if (imageRoi instanceof ShapeRoi)
rois = ((ShapeRoi) imageRoi).getRois();
else
rois = new Roi[] { imageRoi };
for (int i = 0; i < rois.length; i++)
{
drawLoop(imp, rois[i], i + 1);
}
}
示例3: getBounds
import ij.gui.Roi; //导入方法依赖的package包/类
private Rectangle getBounds(ImagePlus imp)
{
if (imp == null)
return null;
Roi roi = imp.getRoi();
if (roi != null && roi.isArea())
{
return roi.getBounds();
}
return null;
}
示例4: setup
import ij.gui.Roi; //导入方法依赖的package包/类
public int setup(String arg, ImagePlus imp)
{
UsageTracker.recordPlugin(this.getClass(), arg);
Roi roi = imp.getRoi();
if (roi == null || !roi.isArea())
{
IJ.error("Require a region ROI");
return DONE;
}
return DOES_ALL | NO_CHANGES;
}
示例5: buildMaskList
import ij.gui.Roi; //导入方法依赖的package包/类
private String[] buildMaskList(Roi roi)
{
ArrayList<String> newImageList = new ArrayList<String>();
if (roi != null && roi.isArea())
newImageList.add("[ROI]");
newImageList.addAll(Arrays.asList(Utils.getImageList(Utils.GREY_8_16, null)));
return newImageList.toArray(new String[newImageList.size()]);
}
示例6: addShapeStatistics
import ij.gui.Roi; //导入方法依赖的package包/类
public static void addShapeStatistics(MeasurementList measurementList, Roi roi, ImageProcessor ip, Calibration cal, String prefix) {
ip.setRoi(roi);
ImageStatistics stats = ImageStatistics.getStatistics(ip, ShapeStatsIJ.SHAPE_MEASUREMENT_OPTIONS, cal);
// For some shape stats it is necessary for the ImagePlus to be set... to ensure calibration is applied properly
// So check this is the case, and set the ROI image as needed
ImagePlus impRoi = roi.getImage();
boolean calibrationValid = impRoi != null && impRoi.getCalibration().equals(cal);
if (!calibrationValid) {
ImagePlus impTemp = new ImagePlus("Temp", ip);
impTemp.setCalibration(cal);
roi.setImage(impTemp);
}
ShapeStatsIJ shapeStats = new ShapeStatsIJ(roi, stats);
// Reset the ROI image, if necessary
if (!calibrationValid)
roi.setImage(impRoi);
// TODO: Add units!
if (roi.isArea())
measurementList.addMeasurement(prefix + "Area", shapeStats.area());
measurementList.addMeasurement(prefix + "Perimeter", shapeStats.perimeter());
measurementList.addMeasurement(prefix + "Circularity", shapeStats.circularity());
measurementList.addMeasurement(prefix + "Max caliper", shapeStats.maxCaliper());
measurementList.addMeasurement(prefix + "Min caliper", shapeStats.minCaliper());
// measurementList.addMeasurement(prefix + "Major axis", shapeStats.majorAxisLength());
// measurementList.addMeasurement(prefix + "Minor axis", shapeStats.minorAxisLength());
measurementList.addMeasurement(prefix + "Eccentricity", shapeStats.eccentricity());
// Note: Roundness correlates closely with eccentricity, so was removed
// Major & Minor axis correlate closely with max & min caliper, so were removed
// // If pixels are not square (sadly sometimes the case...) ellipse measurements fail... so we need to compute roundness manually
// // (we assume square pixels to do so, but otherwise the measurement is dimensionless)
// if (shapeStats.majorAxisLength() == shapeStats.minorAxisLength() && shapeStats.majorAxisLength() == 0) {
// stats = ImageStatistics.getStatistics(ip, Measurements.ELLIPSE, null);
// measurementList.addMeasurement(prefix + "Roundness", stats.minor / stats.major);
// } else {
// measurementList.addMeasurement(prefix + "Roundness", shapeStats.roundness());
// }
}
示例7: createProfile
import ij.gui.Roi; //导入方法依赖的package包/类
private void createProfile()
{
if (!parametersReady())
{
return;
}
double psfWidth, blur;
// Read settings
try
{
psfWidth = Double.parseDouble(widthTextField.getText());
blur = Double.parseDouble(blurTextField.getText());
gain = Double.parseDouble(gainTextField.getText());
msPerFrame = Double.parseDouble(exposureTextField.getText());
}
catch (NumberFormatException e)
{
IJ.error(TITLE, "Invalid numbers in the input parameters");
return;
}
ImagePlus imp = WindowManager.getImage(inputChoice.getSelectedItem());
// This should not be a problem but leave it in for now
if (imp == null || (imp.getType() != ImagePlus.GRAY8 && imp.getType() != ImagePlus.GRAY16 &&
imp.getType() != ImagePlus.GRAY32))
{
IJ.showMessage(TITLE, "Images must be grayscale.");
return;
}
Roi roi = imp.getRoi();
if (roi == null || !roi.isArea())
{
IJ.showMessage(TITLE, "Image must have an area ROI");
return;
}
int recommendedSize = (int) Math.ceil(8 * psfWidth);
Rectangle bounds = roi.getBounds();
if (bounds.width < recommendedSize || bounds.height < recommendedSize)
{
IJ.showMessage(TITLE, String.format("Recommend using an ROI of at least %d x %d for the PSF width",
recommendedSize, recommendedSize));
return;
}
// Check no existing spots are within the ROI
if (resultsWithinBounds(bounds))
{
GenericDialog gd = new GenericDialog(TITLE);
gd.enableYesNoCancel();
gd.hideCancelButton();
gd.addMessage("The results list contains a spot within the selected bounds\n \nDo you want to continue?");
gd.showDialog();
if (!gd.wasOKed())
return;
}
createProfile(imp, bounds, psfWidth, blur);
}
示例8: setup
import ij.gui.Roi; //导入方法依赖的package包/类
public int setup(String arg, ImagePlus imp)
{
if ("final".equals(arg))
{
showResults();
return DONE;
}
UsageTracker.recordPlugin(this.getClass(), arg);
if (imp == null || imp.getStackSize() == 1)
{
IJ.error(TITLE, "Require an input stack");
return DONE;
}
Roi roi = imp.getRoi();
if (roi == null || !roi.isArea())
{
IJ.error(TITLE, "Require an area ROI");
return DONE;
}
// Get the stack and the slice labels
stack = imp.getImageStack();
if (imp.getNDimensions() > 3)
{
IJ.error(TITLE, "Require a 3D stack (not a hyper-stack)");
return DONE;
}
// Try to determine the common prefix to the slice labels
String master = stack.getSliceLabel(1);
// Find the first index where the labels are different
int index = 0;
OUTER: while (index < master.length())
{
final char c = master.charAt(index);
for (int i = 2; i <= stack.getSize(); i++)
{
if (c != stack.getSliceLabel(i).charAt(index))
break OUTER;
}
index++;
}
if (index == master.length())
{
IJ.error(TITLE, "Unable to determine common prefix within slice labels");
return DONE;
}
commonIndex = index;
return flags;
}
示例9: checkMask
import ij.gui.Roi; //导入方法依赖的package包/类
private ImagePlus checkMask(ImagePlus imp, String maskImage)
{
ImagePlus maskImp = WindowManager.getImage(maskImage);
if (maskImp == null)
{
// Build a mask image using the input image ROI
Roi roi = imp.getRoi();
if (roi == null || !roi.isArea())
{
IJ.showMessage("Error", "No region defined (use an area ROI or an input mask)");
return null;
}
ShortProcessor ip = new ShortProcessor(imp.getWidth(), imp.getHeight());
ip.setValue(1);
ip.setRoi(roi);
ip.fill(roi);
// Label each separate region with a different number
labelRegions(ip);
maskImp = new ImagePlus("Mask", ip);
}
if (imp.getNSlices() > 1 && maskImp.getNSlices() != 1 && maskImp.getNSlices() != imp.getNSlices())
{
IJ.showMessage("Error", "Mask region has incorrect slice dimension");
return null;
}
if (imp.getNChannels() > 1 && maskImp.getNChannels() != 1 && maskImp.getNChannels() != imp.getNChannels())
{
IJ.showMessage("Error", "Mask region has incorrect channel dimension");
return null;
}
if (imp.getNFrames() > 1 && processFrames && maskImp.getNFrames() != 1 &&
maskImp.getNFrames() != imp.getNFrames())
{
IJ.showMessage("Error", "Mask region has incorrect frame dimension");
return null;
}
return maskImp;
}
示例10: createDistanceMap
import ij.gui.Roi; //导入方法依赖的package包/类
private FloatProcessor createDistanceMap(ImagePlus imp, String maskImage)
{
ImagePlus maskImp = WindowManager.getImage(maskImage);
ByteProcessor bp = null;
if (maskImp == null)
{
// Build a mask image using the input image ROI
Roi roi = (imp == null) ? null : imp.getRoi();
if (roi == null || !roi.isArea())
{
IJ.showMessage("Error", "No region defined (use an area ROI or an input mask)");
return null;
}
bp = new ByteProcessor(imp.getWidth(), imp.getHeight());
bp.setValue(255);
bp.setRoi(roi);
bp.fill(roi);
}
else
{
ImageProcessor ip = maskImp.getProcessor();
bp = new ByteProcessor(maskImp.getWidth(), maskImp.getHeight());
for (int i = 0; i < bp.getPixelCount(); i++)
if (ip.get(i) != 0)
bp.set(i, 255);
}
// Utils.display("Mask", bp);
// Create a distance map from the mask
EDM edm = new EDM();
FloatProcessor map = edm.makeFloatEDM(bp, 0, true);
// Utils.display("Map", map);
//
// float[] fmap = (float[])map.getPixels();
// byte[] mask = new byte[fmap.length];
// for (int i = 0; i < mask.length; i++)
// if (fmap[i] >= distance)
// mask[i] = -1;
// Utils.display("Mask2", new ByteProcessor(bp.getWidth(), bp.getHeight(), mask));
return map;
}
示例11: showDialog
import ij.gui.Roi; //导入方法依赖的package包/类
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
{
GenericDialog gd = new GenericDialog(TITLE);
spotChannel = imp.getChannel();
thresholdChannel = spotChannel;
Roi roi = imp.getRoi();
if (roi != null && roi.isArea())
{
containsRoiMask = true;
gd.addChoice("Threshold_Channel", maskOptions, maskOptions[maskOption]);
// Set up the mask using the ROI
maskIp = new ByteProcessor(imp.getWidth(), imp.getHeight());
maskIp.setColor(255);
maskIp.fill(roi);
maskIp.setThreshold(0, 254, ImageProcessor.NO_LUT_UPDATE);
}
String[] channels = new String[imp.getNChannels()];
for (int i = 0; i < channels.length; i++)
channels[i] = Integer.toString(i + 1);
gd.addChoice("Threshold_Channel", channels, channels[thresholdChannel - 1]);
gd.addSlider("Blur", 0.01, 5, blur);
gd.addChoice("Threshold_method", AutoThreshold.getMethods(), thresholdMethod);
gd.addChoice("Spot_Channel", channels, channels[spotChannel - 1]);
gd.addSlider("Min_size", 50, 10000, minSize);
gd.addCheckbox("Show_particles", showParticles);
gd.addSlider("Max_peaks", 1, 10, maxPeaks);
gd.addSlider("Fraction", 0.01, 1, fraction);
gd.addCheckbox("Show_spots", showSpots);
gd.addMessage("");
label = (Label) gd.getMessage();
gd.addHelp(gdsc.help.URL.UTILITY);
gd.addPreviewCheckbox(pfr);
gd.addDialogListener(this);
gd.showDialog();
if (gd.wasCanceled() || !dialogItemChanged(gd, null))
return DONE;
return flags;
}