| 59 | } |
| 60 | |
| 61 | public ImageStack makeStack(ImageProcessor ip, int rows, int columns, int border) { |
| 62 | int stackSize = rows*columns; |
| 63 | int width = ip.getWidth()/columns; |
| 64 | int height = ip.getHeight()/rows; |
| 65 | //IJ.log("makeStack: "+rows+" "+columns+" "+border+" "+width+" "+height); |
| 66 | ImageStack stack = new ImageStack(width, height); |
| 67 | for (int y=0; y<rows; y++) |
| 68 | for (int x=0; x<columns; x++) { |
| 69 | ip.setRoi(x*width, y*height, width, height); |
| 70 | stack.addSlice(null, ip.crop()); |
| 71 | } |
| 72 | if (border>0) { |
| 73 | int cropwidth = width-border-border/2; |
| 74 | int cropheight = height-border-border/2; |
| 75 | StackProcessor sp = new StackProcessor(stack,ip); |
| 76 | stack = sp.crop(border, border, cropwidth, cropheight); |
| 77 | } |
| 78 | return stack; |
| 79 | } |
| 80 | } |