/** 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; }
/** 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; }