/** Fills the polygon using the ImageProcessor's current drawing color. */ public void fill(ImageProcessor ip, Rectangle r) { ip.fill(getMask(r.width, r.height)); }
/** Constructs a PolygonFiller using the specified polygon. */ public PolygonFiller(int[] x, int[] y, int n) { setPolygon(x, y, n); }
/** Returns a byte mask containing a filled version of the polygon. */ public ImageProcessor getMask(int width, int height) { allocateArrays(n); buildEdgeTable(x, y, n); //printEdges(); int x1, x2, offset, index; ImageProcessor mask = new ByteProcessor(width, height); byte[] pixels = (byte[])mask.getPixels(); for (int y=0; y<height; y++) { removeInactiveEdges(y); activateEdges(y); offset = y*width; for (int i=0; i<activeEdges; i+=2) { x1 = (int)(ex[aedge[i]]+0.5); if (x1<0) x1=0; if (x1>width) x1 = width; x2 = (int)(ex[aedge[i+1]]+0.5); if (x2<0) x2=0; if (x2>width) x2 = width; //IJ.log(y+" "+x1+" "+x2); for (int x=x1; x<x2; x++) pixels[offset+x] = -1; // 255 (white) } updateXCoordinates(); } return mask; }
public ImageProcessor getMask() { if (cachedMask!=null && cachedMask.getPixels()!=null && cachedMask.getWidth()==width && cachedMask.getHeight()==height) return cachedMask; PolygonFiller pf = new PolygonFiller(); if (xSpline!=null) pf.setPolygon(toIntR(xSpline), toIntR(ySpline), splinePoints); else if (xpf!=null) pf.setPolygon(toIntR(xpf), toIntR(ypf), nPoints); else pf.setPolygon(xp, yp, nPoints); cachedMask = pf.getMask(width, height); return cachedMask; }
if (r.width>1 && r.height>1) { PolygonRoi proi = (PolygonRoi)roi; pf.setPolygon(proi.getXCoordinates(), proi.getYCoordinates(), proi.getNCoordinates()); ip2.setMask(pf.getMask(r.width, r.height)); if (floodFill) ff.particleAnalyzerFill(x, y, level1, level2, ip2.getMask(), r);
particleCount = 0; wand = new Wand(ip); pf = new PolygonFiller(); if (floodFill) { ImageProcessor ipf = ip.duplicate();
/** Updates the x coordinates in the active edges list and sorts the list if necessary. */ void updateXCoordinates() { int index; double x1=-Double.MAX_VALUE, x2; boolean sorted = true; for (int i=0; i<activeEdges; i++) { index = aedge[i]; x2 = ex[index] + eslope[index]; ex[index] = x2; if (x2<x1) sorted = false; x1 = x2; } if (!sorted) sortActiveEdges(); }
public ImageProcessor getMask() { if (cachedMask!=null && cachedMask.getPixels()!=null && cachedMask.getWidth()==width && cachedMask.getHeight()==height) return cachedMask; PolygonFiller pf = new PolygonFiller(); if (xSpline!=null) pf.setPolygon(toIntR(xSpline), toIntR(ySpline), splinePoints); else if (xpf!=null) pf.setPolygon(toIntR(xpf), toIntR(ypf), nPoints); else pf.setPolygon(xp, yp, nPoints); cachedMask = pf.getMask(width, height); return cachedMask; }
if (r.width>1 && r.height>1) { PolygonRoi proi = (PolygonRoi)roi; pf.setPolygon(proi.getXCoordinates(), proi.getYCoordinates(), proi.getNCoordinates()); ip2.setMask(pf.getMask(r.width, r.height)); if (floodFill) ff.particleAnalyzerFill(x, y, level1, level2, ip2.getMask(), r);
particleCount = 0; wand = new Wand(ip); pf = new PolygonFiller(); if (floodFill) { ImageProcessor ipf = ip.duplicate();
/** Updates the x coordinates in the active edges list and sorts the list if necessary. */ void updateXCoordinates() { int index; double x1=-Double.MAX_VALUE, x2; boolean sorted = true; for (int i=0; i<activeEdges; i++) { index = aedge[i]; x2 = ex[index] + eslope[index]; ex[index] = x2; if (x2<x1) sorted = false; x1 = x2; } if (!sorted) sortActiveEdges(); }
roi.ypoints[i] -= bounds.y; PolygonFiller pf = new PolygonFiller(); pf.setPolygon(roi.xpoints, roi.ypoints, roi.npoints); ImageProcessor mask = pf.getMask(bounds.width, bounds.height); setMask(mask); setRoi(bounds);
/** Returns a byte mask containing a filled version of the polygon. */ public ImageProcessor getMask(int width, int height) { allocateArrays(n); buildEdgeTable(x, y, n); //printEdges(); int x1, x2, offset, index; ImageProcessor mask = new ByteProcessor(width, height); byte[] pixels = (byte[])mask.getPixels(); for (int y=0; y<height; y++) { removeInactiveEdges(y); activateEdges(y); offset = y*width; for (int i=0; i<activeEdges; i+=2) { x1 = (int)(ex[aedge[i]]+0.5); if (x1<0) x1=0; if (x1>width) x1 = width; x2 = (int)(ex[aedge[i+1]]+0.5); if (x2<0) x2=0; if (x2>width) x2 = width; //IJ.log(y+" "+x1+" "+x2); for (int x=x1; x<x2; x++) pixels[offset+x] = -1; // 255 (white) } updateXCoordinates(); } return mask; }
/** Constructs a PolygonFiller using the specified polygon. */ public PolygonFiller(int[] x, int[] y, int n) { setPolygon(x, y, n); }
/** Fills the polygon using the ImageProcessor's current drawing color. */ public void fill(ImageProcessor ip, Rectangle r) { ip.fill(getMask(r.width, r.height)); }
private void fillPolygon(ImageProcessor ip, Polygon p, boolean internContour) { PolygonRoi proi = new PolygonRoi(p, PolygonRoi.POLYGON); Rectangle r = proi.getBounds(); PolygonFiller pf = new PolygonFiller(); pf.setPolygon(proi.getXCoordinates(), proi.getYCoordinates(), proi.getNCoordinates()); ip.setRoi(r); ImageProcessor objectMask = pf.getMask(r.width, r.height); ip.fill(objectMask); if(!internContour){ ip.drawPolygon(p); } }
roi.ypoints[i] -= bounds.y; PolygonFiller pf = new PolygonFiller(); pf.setPolygon(roi.xpoints, roi.ypoints, roi.npoints); ImageProcessor mask = pf.getMask(bounds.width, bounds.height); setMask(mask); setRoi(bounds);