public float average(Roi roi) { Rectangle r = roi.getBoundingRect(); float psiSum = 0; int s = 0; for (int y = 0; y < r.height; y++) { for (int x = 0; x < r.width; x++) { if (! (roi instanceof Roi) || roi.contains(r.x + x, r.y + y)) { psiSum += psi[r.y + y][r.x + x]; s++; } } } return psiSum / (float) s; } public void computePsi(FlowJFlow flow, FlowJFlow trueFlow)
public int average(Roi roi) /* compute the average flow over an area defined in Roi. Return the surface area in pixels. */ { Rectangle r = roi.getBoundingRect(); float xSum = 0; float ySum = 0; int s = 0; for (int y = 0; y < r.height; y++) { for (int x = 0; x < r.width; x++) { if (full[r.y + y][r.x + x] && roi.contains(r.x + x, r.y + y)) { xSum += v.v[r.y + y][r.x + x][0]; ySum += v.v[r.y + y][r.x + x][1]; s++; } } } avg[0] = xSum / (float) s; avg[1] = ySum / (float) s; return s; } /** Return the angle of the previously computed average flow. */
Rectangle bounds; if(roi != null){ bounds = roi.getBoundingRect(); }else{ bounds = new Rectangle(0,0,width, pixelData.length/width);
bounds = roi.getBoundingRect(); }else{ bounds = new Rectangle(0,0,width, pixelData.length/width);
private Point2D getImageOffset(CrossCorrelationResult2D result, ImagePlus imp1, ImagePlus imp2) { // see "ROI shift to Image Shift.ppt" for details of nomenclature Point2D r1, r2, sr, sir, si; // relative shift between rois (all shifts relative to upper left front corner) sr = result.shift; if (imp1.getRoi() == null || imp2.getRoi() == null) { // there are no rois....so we already have the relative shift between the images si = sr; } else { Roi roi1 = imp1.getRoi(); Roi roi2 = imp2.getRoi(); int x1 = roi1.getBoundingRect().x; int y1 = roi1.getBoundingRect().y; int x2 = roi2.getBoundingRect().x; int y2 = roi2.getBoundingRect().y; r1 = new Point2D(x1, y1); r2 = new Point2D(x2, y2); sir = add(r1, sr); si = subtract(sir, r2); } return si; }
/** Method to return types supported * @param arg unused * @param imp The ImagePlus, used to get the spatial calibration * @return Code describing supported formats etc. * (see ij.plugin.filter.PlugInFilter & ExtendedPlugInFilter) */ public int setup(String arg, ImagePlus imp) { this.imp = imp; if (imp!=null && imp.getRoi()!=null) { Rectangle roiRect = imp.getRoi().getBoundingRect(); if (roiRect.y > 0 || roiRect.y+roiRect.height < imp.getDimensions()[1]) flags |= SNAPSHOT; // snapshot for pixels above and/or below roi rectangle } return flags; }
int x = r.getBoundingRect().x; int y = r.getBoundingRect().y; int w = r.getBoundingRect().width; int h = r.getBoundingRect().height;
private Point3D getImageOffset(CrossCorrelationResult3D result, ImagePlus imp1, ImagePlus imp2) { // see "ROI shift to Image Shift.ppt" for details of nomenclature Point3D r1, r2, sr, sir, si; // relative shift between rois (all shifts relative to upper left front // corner) sr = result.shift; if (imp1.getRoi() == null || imp2.getRoi() == null) { // there are no rois....so we already have the relative shift // between the images si = sr; } else { Roi roi1 = imp1.getRoi(); Roi roi2 = imp2.getRoi(); int x1 = roi1.getBoundingRect().x; int y1 = roi1.getBoundingRect().y; int x2 = roi2.getBoundingRect().x; int y2 = roi2.getBoundingRect().y; r1 = new Point3D(x1, y1, 0); r2 = new Point3D(x2, y2, 0); sir = add(r1, sr); si = subtract(sir, r2); } return si; }
int x = r.getBoundingRect().x; int y = r.getBoundingRect().y; int w = r.getBoundingRect().width; int h = r.getBoundingRect().height;
/** Method to return types supported * @param arg unused * @param imp The ImagePlus, used to get the spatial calibration * @return Code describing supported formats etc. * (see ij.plugin.filter.PlugInFilter & ExtendedPlugInFilter) */ public int setup(String arg, ImagePlus imp) { this.imp = imp; if (imp!=null && imp.getRoi()!=null) { Rectangle roiRect = imp.getRoi().getBoundingRect(); if (roiRect.y > 0 || roiRect.y+roiRect.height < imp.getDimensions()[1]) flags |= SNAPSHOT; // snapshot for pixels above and/or below roi rectangle } return flags; }
/** * Compute the width of the images in imp, or the ROI if one has been selected. * @param imp an ImageJ ImagePlus * @return the width of the images in imp. */ public static int getMatrixWidth(ImagePlus imp) { int width = imp.getWidth(); if (imp.getRoi() != null) { Rectangle roiRect = imp.getRoi().getBoundingRect(); width = roiRect.width; } return width; } /**
if (imp.getRoi() != null) Rectangle roiRect = imp.getRoi().getBoundingRect(); width = roiRect.width; height = roiRect.height;
int[] cx = ((PolygonRoi)roi).getXCoordinates(); int[] cy = ((PolygonRoi)roi).getYCoordinates(); Rectangle rect=roi.getBoundingRect(); int x0=rect.x; int y0=rect.y;
if (imp.getRoi() != null) Rectangle roiRect = imp.getRoi().getBoundingRect(); width = roiRect.width; height = roiRect.height;
if (imp.getRoi() != null) Rectangle roiRect = imp.getRoi().getBoundingRect(); width = roiRect.width; height = roiRect.height;
r = roi.getBoundingRect(); int fulls = 0; for (int y = 0; y < getHeight(); y++)
Rectangle r = roi.getBoundingRect();
rect=imp.getRoi(). getBoundingRect();
else roi = new PolygonRoi(x, y, height, type); Rectangle r = roi.getBoundingRect(); ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getWidth()<r.x+r.width || imp.getHeight()<r.y+r.height) {
else roi = new PolygonRoi(x, y, height, type); Rectangle r = roi.getBoundingRect(); ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getWidth()<r.x+r.width || imp.getHeight()<r.y+r.height) {