本文整理汇总了Java中ij.process.FloatPolygon类的典型用法代码示例。如果您正苦于以下问题:Java FloatPolygon类的具体用法?Java FloatPolygon怎么用?Java FloatPolygon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FloatPolygon类属于ij.process包,在下文中一共展示了FloatPolygon类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writePointRoi
import ij.process.FloatPolygon; //导入依赖的package包/类
/** Write a PointRoi */
private void writePointRoi(
final XMLStreamWriter xsw,
final PointRoi roi)
throws SlideSetException {
final FloatPolygon fp = roi.getFloatPolygon();
try {
for(int i=0; i<fp.npoints; i++) {
xsw.writeStartElement("line");
xsw.writeAttribute("class", "roi PointRoi");
xsw.writeAttribute("x1", String.valueOf(fp.xpoints[i]));
xsw.writeAttribute("y1", String.valueOf(fp.ypoints[i]));
xsw.writeAttribute("x2", String.valueOf(fp.xpoints[i]));
xsw.writeAttribute("y2", String.valueOf(fp.ypoints[i]));
applyDefaultStyles(xsw);
xsw.writeAttribute("stroke-linecap", "round");
xsw.writeEndElement();
}
} catch(Exception e) {
throw new SlideSetException(e);
}
}
示例2: writePolygonRoi
import ij.process.FloatPolygon; //导入依赖的package包/类
/** Write a PolygonRoi */
private void writePolygonRoi(
final XMLStreamWriter xsw,
final PolygonRoi roi)
throws SlideSetException {
final FloatPolygon fp = roi.getFloatPolygon();
try {
if(roi.getType() == Roi.POLYGON)
xsw.writeStartElement("polygon");
else
xsw.writeStartElement("polyline");
xsw.writeAttribute("class", "roi PolygonRoi");
String coords = "";
for(int i=0; i < fp.npoints; i++) {
coords += String.valueOf(
fp.xpoints[i]) +
"," + String.valueOf(
fp.ypoints[i]) + " ";
}
xsw.writeAttribute("points", coords);
applyDefaultStyles(xsw);
xsw.writeEndElement();
} catch(Exception e) {
throw new SlideSetException(e);
}
}
示例3: findFitRegion
import ij.process.FloatPolygon; //导入依赖的package包/类
private boolean findFitRegion()
{
// Get the centre
Roi roi = imp.getRoi();
if (roi != null && roi.getType() == Roi.POINT)
{
FloatPolygon p = roi.getFloatPolygon();
int n = p.npoints;
if (n != 1)
{
IJ.error(TITLE, "Require a single point ROI");
return false;
}
cx = (int) p.xpoints[0];
cy = (int) p.ypoints[0];
return true;
}
IJ.error(TITLE, "Require a single point ROI");
return false;
}
示例4: getSpots
import ij.process.FloatPolygon; //导入依赖的package包/类
/**
* @return Extract all the ROI points
*/
private BasePoint[] getSpots()
{
float z = imp.getStackSize() / 2;
Roi roi = imp.getRoi();
if (roi != null && roi.getType() == Roi.POINT)
{
FloatPolygon p = roi.getFloatPolygon();
int n = p.npoints;
float offset = 0.5f;
// Check if already float coordinates
if (!SimpleArrayUtils.isInteger(p.xpoints) || !SimpleArrayUtils.isInteger(p.ypoints))
offset = 0;
BasePoint[] roiPoints = new BasePoint[n];
for (int i = 0; i < n; i++)
{
roiPoints[i] = new BasePoint(p.xpoints[i] + offset, p.ypoints[i] + offset, z);
}
return roiPoints;
}
return new BasePoint[0];
}
示例5: testPolygonRoi
import ij.process.FloatPolygon; //导入依赖的package包/类
private static void testPolygonRoi() {
FloatPolygon test = new FloatPolygon();
test.addPoint(1, 0);
test.addPoint(2, 0);
test.addPoint(3, 0);
test.addPoint(3, 1);
test.addPoint(2, 2);
test.addPoint(1, 2);
test.addPoint(0, 1);
S.out(test.contains(1, 0));
S.out(test.contains(2, 0));
S.out(test.contains(3, 0));
S.out(test.contains(3, 1));
S.out(test.contains(2, 2));
S.out(test.contains(1, 2));
S.out(test.contains(0, 1));
}
示例6: generateVisualizationRoisFromTrack
import ij.process.FloatPolygon; //导入依赖的package包/类
public static ArrayList<Roi> generateVisualizationRoisFromTrack(Subtrajectory t, Color c, boolean showID, double pixelsize){
ArrayList<Roi> proi = new ArrayList<Roi>();
FloatPolygon p = new FloatPolygon();
double sumx = 0;
double sumy = 0;
TextRoi.setFont("TimesRoman", 5, Font.PLAIN);
for(int i = 0; i < t.getParent().size(); i++){
int to = t.size();
if(i< t.size()){
sumx += t.get(i).x/pixelsize;
sumy += t.get(i).y/pixelsize;
p.addPoint(t.get(i).x/pixelsize, t.get(i).y/pixelsize);
to = i+1;
}
PolygonRoi pr = new PolygonRoi(new FloatPolygon(p.xpoints, p.ypoints,to), PolygonRoi.POLYLINE);
pr.setStrokeColor(c);
pr.setPosition(t.getRelativeStartTimepoint()+i+1);
proi.add(pr);
if(showID){
long parentID = t.getParent().getID();
TextRoi troi = new TextRoi(sumx/to, sumy/to," "+parentID+":"+t.getID()+" ");
troi.setPosition(t.getRelativeStartTimepoint()+i+1);
troi.setFillColor(Color.BLACK);
troi.setStrokeColor(c);
troi.setAntialiased(true);
proi.add(troi);
}
}
return proi;
}
示例7: smoothPolygonRoi
import ij.process.FloatPolygon; //导入依赖的package包/类
private static PolygonRoi smoothPolygonRoi(PolygonRoi r) {
FloatPolygon poly = r.getFloatPolygon();
FloatPolygon poly2 = new FloatPolygon();
int nPoints = poly.npoints;
for (int i = 0; i < nPoints; i += 2) {
int iMinus = (i + nPoints - 1) % nPoints;
int iPlus = (i + 1) % nPoints;
poly2.addPoint((poly.xpoints[iMinus] + poly.xpoints[iPlus] + poly.xpoints[i])/3,
(poly.ypoints[iMinus] + poly.ypoints[iPlus] + poly.ypoints[i])/3);
}
// return new PolygonRoi(poly2, r.getType());
return new PolygonRoi(poly2, Roi.POLYGON);
}
示例8: convertToPointsList
import ij.process.FloatPolygon; //导入依赖的package包/类
public static List<Point2> convertToPointsList(FloatPolygon polygon, Calibration cal, double downsampleFactor) {
if (polygon == null)
return null;
List<Point2> points = new ArrayList<>();
for (int i = 0; i < polygon.npoints; i++) {
float x = (float)convertXfromIJ(polygon.xpoints[i], cal, downsampleFactor);
float y = (float)convertYfromIJ(polygon.ypoints[i], cal, downsampleFactor);
points.add(new Point2(x, y));
}
return points;
}
示例9: getShape
import ij.process.FloatPolygon; //导入依赖的package包/类
private Shape getShape(PolygonRoi r)
{
Path2D.Float path = new Path2D.Float();
FloatPolygon p = r.getFloatPolygon();
path.moveTo(p.xpoints[0], p.ypoints[0]);
for (int i = 1; i < p.xpoints.length; i++)
{
path.lineTo(p.xpoints[i], p.ypoints[i]);
}
return path;
}
示例10: drawEllipse
import ij.process.FloatPolygon; //导入依赖的package包/类
/**
* Draws the elliptical cell
*
* @param params
* @return
*/
public FloatPolygon drawEllipse(final double[] params)
{
final double centreX = params[0];
final double centreY = params[1];
final double axis1 = params[2];
final double axis2 = params[3];
final double minor = params[4];
final double phi = params[5];
return drawEllipse(centreX, centreY, axis1, axis2, minor, phi);
}
示例11: createWeightMap
import ij.process.FloatPolygon; //导入依赖的package包/类
/**
* Draw the current elliptical cell. Then create an Euclidian Distance Map to use as the weights
* within the provided range. All other points a zeros.
*
* @param pointBounds
* @param params
* @param range
* @return
*/
private FloatProcessor createWeightMap(Rectangle pointBounds, double[] params, double range)
{
EllipticalCell cell = new EllipticalCell();
FloatPolygon ellipse = cell.drawEllipse(params);
ByteProcessor mask = new ByteProcessor(pointBounds.width, pointBounds.height);
mask.setValue(255);
mask.draw(new PolygonRoi(ellipse.xpoints, ellipse.ypoints, ellipse.npoints, PolygonRoi.POLYGON));
EDM edm = new EDM();
FloatProcessor map = edm.makeFloatEDM(mask, (byte) 255, false);
if (map == null)
{
// Preview thread has been interrupted
return null;
}
map.invert();
double max = map.getMax();
double min = Math.max(max - range, 0);
float[] data = (float[]) map.getPixels();
for (int i = 0; i < data.length; i++)
data[i] = (float) ((data[i] > min) ? (data[i] - min) / range : 0f);
// Apply a gamma function for a smoother roll-off
double g = weightingGamma;
if (g > 0)
{
g = 1.0 / g;
for (int i = 0; i < data.length; i++)
data[i] = (float) Math.pow(data[i], g);
}
if (debug)
{
map.resetMinAndMax();
ImagePlus mapImp = displayImage(map, "Current weight map");
mapImp.updateAndDraw();
}
return map;
}
示例12: PointRoi2
import ij.process.FloatPolygon; //导入依赖的package包/类
/** Creates a new PointRoi2 from a FloatPolygon. */
public PointRoi2(FloatPolygon poly)
{
super(poly);
}
示例13: createInterpolatedPolygon
import ij.process.FloatPolygon; //导入依赖的package包/类
/** Copied from ImageJ's ij.gui.PolygonRoi.getInterpolatedPolygon, by Wayne Rasband and collaborators.
* The reason I copied this method is that creating a new PolygonRoi just to get an interpolated polygon
* processes the float[] arrays of the coordinates, subtracting the minimum x,y. Not only it is an extra
* operation but it is also in place, altering data arrays. Fortunately FloatPolygon does not touch the arrays. */
final static public FloatPolygon createInterpolatedPolygon(
final FloatPolygon p,
final double interval,
final boolean isLine) {
final double length = p.getLength(isLine);
final int npoints2 = (int)((length*1.2)/interval);
final float[] xpoints2 = new float[npoints2];
final float[] ypoints2 = new float[npoints2];
xpoints2[0] = p.xpoints[0];
ypoints2[0] = p.ypoints[0];
int n=1, n2;
final double inc = 0.01;
double distance=0.0, distance2=0.0, dx=0.0, dy=0.0, xinc, yinc;
double x, y, lastx, lasty, x1, y1, x2=p.xpoints[0], y2=p.ypoints[0];
int npoints = p.npoints;
if (!isLine) npoints++;
for (int i=1; i<npoints; i++) {
x1=x2; y1=y2;
x=x1; y=y1;
if (i<p.npoints) {
x2=p.xpoints[i];
y2=p.ypoints[i];
} else {
x2=p.xpoints[0];
y2=p.ypoints[0];
}
dx = x2-x1;
dy = y2-y1;
distance = Math.sqrt(dx*dx+dy*dy);
xinc = dx*inc/distance;
yinc = dy*inc/distance;
lastx=xpoints2[n-1]; lasty=ypoints2[n-1];
//n2 = (int)(dx/xinc);
n2 = (int)(distance/inc);
if (npoints==2) n2++;
do {
dx = x-lastx;
dy = y-lasty;
distance2 = Math.sqrt(dx*dx+dy*dy);
//IJ.log(i+" "+IJ.d2s(xinc,5)+" "+IJ.d2s(yinc,5)+" "+IJ.d2s(distance,2)+" "+IJ.d2s(distance2,2)+" "+IJ.d2s(x,2)+" "+IJ.d2s(y,2)+" "+IJ.d2s(lastx,2)+" "+IJ.d2s(lasty,2)+" "+n+" "+n2);
if (distance2>=interval-inc/2.0 && n<xpoints2.length-1) {
xpoints2[n] = (float)x;
ypoints2[n] = (float)y;
//IJ.log("--- "+IJ.d2s(x,2)+" "+IJ.d2s(y,2)+" "+n);
n++;
lastx=x; lasty=y;
}
x += xinc;
y += yinc;
} while (--n2>0);
}
return new FloatPolygon(xpoints2, ypoints2, n);
}