本文整理汇总了Java中ij.gui.Roi.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Roi.getBounds方法的具体用法?Java Roi.getBounds怎么用?Java Roi.getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.gui.Roi
的用法示例。
在下文中一共展示了Roi.getBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWarpedPointsCentered
import ij.gui.Roi; //导入方法依赖的package包/类
@Deprecated
public static List<Point2D> getWarpedPointsCentered(Roi roi, LinearMapping W) {
Rectangle bounds = roi.getBounds();
List<Point2D> oPts = new LinkedList<Point2D>();
float xC = bounds.width/2;
float yC = bounds.height/2;
oPts.add(new Point2D.Float(0 - xC, 0 - yC));
oPts.add(new Point2D.Float(bounds.width - xC, 0 - yC));
oPts.add(new Point2D.Float(bounds.width - xC, bounds.height - yC));
oPts.add(new Point2D.Float(0 - xC, bounds.height - yC));
List<Point2D> wPts = new LinkedList<Point2D>();
for (Point2D op : oPts) {
wPts.add(W.applyTo(op));
//pts.add(ipm);
}
return wPts;
}
示例2: copySlice
import ij.gui.Roi; //导入方法依赖的package包/类
/**
* Copies pixels under all the ROIs on a slide
*
* @param sourceProcessor The source image slide
* @param targetProcessor The target slide
* @param sliceRois List of all the ROIs on the source slide
* @param padding Number of pixels added on each side of the target slide
*/
private static void copySlice(final ImageProcessor sourceProcessor, final ImageProcessor targetProcessor,
final ArrayList<Roi> sliceRois, final int padding) {
for (final Roi sliceRoi : sliceRois) {
final Rectangle rectangle = sliceRoi.getBounds();
final boolean valid = getSafeRoiBounds(rectangle, sourceProcessor.getWidth(), sourceProcessor.getHeight());
if (!valid) {
continue;
}
final int minY = rectangle.y;
final int minX = rectangle.x;
final int maxY = rectangle.y + rectangle.height;
final int maxX = rectangle.x + rectangle.width;
final ImageProcessor mask = sourceProcessor.getMask();
if (mask == null) {
copyRoi(sourceProcessor, targetProcessor, minX, minY, maxX, maxY, padding);
} else {
copyRoiWithMask(sourceProcessor, targetProcessor, minX, minY, maxX, maxY, padding);
}
}
}
示例3: findClosestMaximumInROI
import ij.gui.Roi; //导入方法依赖的package包/类
private static Point findClosestMaximumInROI(ImageProcessor ip, Roi roi, Point p) {
Rectangle bounds = roi.getBounds();
Float maxVal = Float.NEGATIVE_INFINITY;
Double minDist = Double.POSITIVE_INFINITY;
Point maxPoint = null;
int y1 = Math.max(0, bounds.y);
int y2 = Math.min(ip.getHeight(), bounds.y+bounds.height);
int x1 = Math.max(0, bounds.x);
int x2 = Math.min(ip.getWidth(), bounds.x+bounds.width);
for (int y = y1; y < y2; y++) {
for (int x = x1; x < x2; x++) {
if (roi.contains(x, y)) {
float val = ip.getf(x, y);
if (val > maxVal || (val == maxVal && p.distance(x, y) < minDist)) {
maxVal = val;
maxPoint = new Point(x, y);
minDist = p.distance(x, y);
}
}
}
}
return maxPoint;
}
示例4: toShape
import ij.gui.Roi; //导入方法依赖的package包/类
/**
* Convert ImageJ's Roi to Java 3D Shape representation.
*
* @param roi source roi.
* @return translated to Shape.
*/
public static Shape toShape(final Roi roi) {
final Shape result;
if (roi instanceof PointRoi) {
final ByteProcessor mask = (ByteProcessor) roi.getMask();
final byte[] maskPixels = (byte[]) mask.getPixels();
final Rectangle maskBounds = roi.getBounds();
final int maskWidth = mask.getWidth();
final int maskHeight = mask.getHeight();
final Area area = new Area();
for (int y = 0; y < maskHeight; y++) {
final int yOffset = y * maskWidth;
for (int x = 0; x < maskWidth; x++) {
if (maskPixels[x + yOffset] != 0) {
area.add(new Area(new Rectangle(x + maskBounds.x, y + maskBounds.y, 1, 1)));
}
}
}
result = area;
} else {
result = makeShapeFromArray(new ShapeRoi(roi).getShapeAsArray());
}
return result;
}
示例5: markSeedPoints
import ij.gui.Roi; //导入方法依赖的package包/类
private static int markSeedPoints(final Region region, final ByteProcessor seedImage, final int regionId) {
int seedCount = 0;
for (final SubRegion subRegion : region.getSubRegions()) {
final Roi roi = subRegion.getRoi();
final Rectangle bounds = roi.getBounds();
for (int y = bounds.y; y < bounds.y + bounds.height; y++) {
for (int x = bounds.x; x < bounds.x + bounds.width; x++) {
if (roi.contains(x, y) && seedImage.get(x, y) == 0) {
seedImage.set(x, y, regionId);
seedCount++;
}
}
}
}
return seedCount;
}
示例6: run
import ij.gui.Roi; //导入方法依赖的package包/类
public void run(ImageProcessor ip)
{
// Calculate the histogram
final int[] h = (simulate) ? simulateHistogram(usePDF ? 0 : 1) : buildHistogram(imp);
// We need > 10^7 pixels from flat white-light images under constant exposure ...
final int size = getSize(h);
if (imp != null)
{
Roi roi = imp.getRoi();
Rectangle bounds;
if (roi == null)
bounds = new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
else
bounds = roi.getBounds();
Utils.log("Analysing %s [x=%d,y=%d,width=%d,height=%d]", imp.getTitle(), bounds.x, bounds.y, bounds.width,
bounds.height);
}
Utils.log("Histogram contains %d pixels", size);
if (size < MINIMUM_PIXELS)
Utils.log("WARNING : Recommend at least %d pixels (%sx more)", MINIMUM_PIXELS,
Utils.rounded((double) MINIMUM_PIXELS / size));
fit(h);
}
示例7: extractBorderPixels
import ij.gui.Roi; //导入方法依赖的package包/类
public static ArrayList<VPoint> extractBorderPixels(Roi roi){
ImageProcessor mask = roi.getMask();
ArrayList<VPoint> pixels = new ArrayList<VPoint>();
Rectangle r = roi.getBounds();
for (int x = 0; x < r.width; ++x){
for (int y = 0; y < r.height; ++y){
// int N = 0;
for (int i=0; mask.getPixel(x, y) > 0 && i < n8.length; i += 2) {
if ( mask.getPixel(x + n8[i].x, y + n8[i].y) == 0) {
// System.out.println("border = " + x + "," + y);
pixels.add(new VPoint(x + r.x, y + r.y));
// roi.getImage().getProcessor().putPixel(x + r.x, y + r.y, 255);
// roi.getImage().getProcessor().putPixel(x, y, 255);
break;
}
}
}
}
return pixels;
}
示例8: extractSelection
import ij.gui.Roi; //导入方法依赖的package包/类
private Roi extractSelection(ImageProcessor maskIp, int maskId, int channel, int slice, int frame)
{
maskIp.setThreshold(maskId, maskId, ImageProcessor.NO_LUT_UPDATE);
ThresholdToSelection ts = new ThresholdToSelection();
Roi roi = ts.convert(maskIp);
if (imp.getStackSize() == 1)
{
roi.setPosition(0);
}
else if (imp.isDisplayedHyperStack())
{
if (showOverlay != 1)
slice = 0; // Display across entire slice stack
roi.setPosition(channel, slice, frame);
}
else
{
// We cannot support display across the entire stack if this is not a hyperstack
int index = imp.getStackIndex(channel, slice, frame);
roi.setPosition(index);
}
Rectangle roiBounds = roi.getBounds();
roi.setLocation(bounds.x + roiBounds.x, bounds.y + roiBounds.y);
return roi;
}
示例9: copySlice
import ij.gui.Roi; //导入方法依赖的package包/类
/**
* Copies pixels under all the ROIs on a slide.
*
* @param sourceProcessor The source image slide
* @param targetProcessor The target slide
* @param sliceRois List of all the ROIs on the source slide
* @param padding Number of pixels added on each side of the target slide
*/
private static void copySlice(final ImageProcessor sourceProcessor,
final ImageProcessor targetProcessor, final List<Roi> sliceRois,
final int padding)
{
for (Roi sliceRoi : sliceRois) {
Rectangle rectangle = sliceRoi.getBounds();
boolean valid = getSafeRoiBounds(rectangle, sourceProcessor.getWidth(),
sourceProcessor.getHeight());
if (!valid) {
continue;
}
int minY = rectangle.y;
int minX = rectangle.x;
int maxY = rectangle.y + rectangle.height;
int maxX = rectangle.x + rectangle.width;
ImageProcessor mask = sourceProcessor.getMask();
if (mask == null) {
copyRoi(sourceProcessor, targetProcessor, minX, minY, maxX, maxY,
padding);
}
else {
copyRoiWithMask(sourceProcessor, targetProcessor, minX, minY, maxX,
maxY, padding);
}
}
}
示例10: measureMembrane
import ij.gui.Roi; //导入方法依赖的package包/类
public static void measureMembrane(PathObject po, ImageProcessor ip, String ipName, Calibration cal, double downsampleFactor) {
Roi roi = ROIConverterIJ.convertToIJRoi(po.getROI(), cal, downsampleFactor);
Rectangle bounds = roi.getBounds();
ByteProcessor bp = new ByteProcessor(bounds.width, bounds.height);
roi.setLocation(0, 0);
bp.setValue(255);
bp.draw(roi);
double sum = 0;
int count = 0;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
for (int y = 0; y < bounds.height; y++) {
for (int x = 0; x < bounds.width; x++) {
if (bp.get(x, y) != 0) {
double val = ip.getf(x+bounds.x, y+bounds.y);
sum += val;
count++;
if (val > max)
max = val;
if (val < min)
min = val;
}
}
}
roi.setLocation(bounds.x, bounds.y);
po.getMeasurementList().addMeasurement("Membrane mean"+SPLIT_CHAR+" "+ipName, sum/count);
// po.addMeasurement("Membrane min"+SPLIT_CHAR+" "+ipName, min);
// po.addMeasurement("Membrane max"+SPLIT_CHAR+" "+ipName, max);
}
示例11: getTransformedBoundsFromIJ
import ij.gui.Roi; //导入方法依赖的package包/类
protected static Rectangle2D getTransformedBoundsFromIJ(Roi roi, Calibration cal, double downsampleFactor) {
Rectangle2D bounds = roi.getBounds();
double x1 = convertXfromIJ(bounds.getMinX(), cal, downsampleFactor);
double y1 = convertYfromIJ(bounds.getMinY(), cal, downsampleFactor);
double x2 = convertXfromIJ(bounds.getMaxX(), cal, downsampleFactor);
double y2 = convertYfromIJ(bounds.getMaxY(), cal, downsampleFactor);
return new Rectangle2D.Double(
x1, y1, x2-x1, y2-y1);
// return new Rectangle2D.Double(
// convertXfromIJ(bounds.getX(), cal, downsampleFactor),
// convertYfromIJ(bounds.getY(), cal, downsampleFactor),
// convertXfromIJ(bounds.getWidth(), null, downsampleFactor),
// convertYfromIJ(bounds.getHeight(), null, downsampleFactor));
}
示例12: getLabel
import ij.gui.Roi; //导入方法依赖的package包/类
static String getLabel(final ImagePlus imp, final Roi roi, final int n) {
final Rectangle r = roi.getBounds();
int xc = r.x + r.width / 2;
int yc = r.y + r.height / 2;
if (n >= 0) {
xc = yc;
yc = n;
}
if (xc < 0) {
xc = 0;
}
if (yc < 0) {
yc = 0;
}
int digits = 4;
String xs = "" + xc;
if (xs.length() > digits) {
digits = xs.length();
}
String ys = "" + yc;
if (ys.length() > digits) {
digits = ys.length();
}
xs = "000000" + xc;
ys = "000000" + yc;
String label = ys.substring(ys.length() - digits) + "-" + xs.substring(xs.length() - digits);
if (imp.getStackSize() > 1) {
final String zs = "000000" + imp.getCurrentSlice();
label = zs.substring(zs.length() - digits) + "-" + label;
}
return label;
}
示例13: restrictToROIFilter
import ij.gui.Roi; //导入方法依赖的package包/类
public void restrictToROIFilter() {
double mag = new EmptyRendererUI().magnification.getValue();
IJResultsTable rt = IJResultsTable.getResultsTable();
ImagePlus preview = rt.getPreviewImage();
Roi roi2 = null;
if(preview != null) {
roi2 = preview.getRoi();
}
if(roi2 == null) {
GUI.showBalloonTip(restrictToROIButton, "There is no ROI in the preview image!");
return;
}
Rectangle2D[] rectangleList;
if(roi2 instanceof ShapeRoi) {
ShapeRoi shapeRoi = (ShapeRoi) roi2;
Roi[] roiList = shapeRoi.getRois();
rectangleList = new Rectangle2D[roiList.length];
for(int i = 0; i < roiList.length; i++) {
rectangleList[i] = roiList[i].getBounds();
}
} else {
rectangleList = new Rectangle2D[]{roi2.getBounds()};
}
Units ux = rt.getColumnUnits(LABEL_X);
Units uy = rt.getColumnUnits(LABEL_Y);
//
for(int i = 0; i < rectangleList.length; i++) {
rectangleList[i] = convertRectangleUnits(rectangleList[i], ux, uy, mag);
}
addNewRectanglesFilter(rectangleList);
}
示例14: getRoi
import ij.gui.Roi; //导入方法依赖的package包/类
private static Rectangle getRoi( final LayerSet layerset )
{
final Roi roi;
final Display front = Display.getFront();
if ( front == null )
roi = null;
else
roi = front.getRoi();
if ( roi == null )
return new Rectangle( 0, 0, ( int ) layerset.getLayerWidth(), ( int ) layerset.getLayerHeight() );
else
return roi.getBounds();
}
示例15: 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;
}