(ImageStack stack, int zshrink)
| 115 | } |
| 116 | |
| 117 | private ImageStack shrinkZ(ImageStack stack, int zshrink) { |
| 118 | int w = stack.getWidth(); |
| 119 | int h = stack.getHeight(); |
| 120 | int d = stack.size(); |
| 121 | int d2 = d/zshrink; |
| 122 | ImageStack stack2 = new ImageStack (w, h, stack.getColorModel()); |
| 123 | for (int z=1; z<=d2; z++) |
| 124 | stack2.addSlice(stack.getProcessor(z).duplicate()); |
| 125 | if (method==MEDIAN) // median z-binning does not work |
| 126 | method = AVERAGE; |
| 127 | boolean rgb = stack.getBitDepth()==24; |
| 128 | ImageProcessor ip = rgb?new ColorProcessor(d, h):new FloatProcessor(d, h); |
| 129 | for (int x=0; x<w; x++) { |
| 130 | IJ.showProgress(x+1, w); |
| 131 | for (int y=0; y<h; y++) { |
| 132 | float value; |
| 133 | for (int z=0; z<d; z++) { |
| 134 | value = (float)stack.getVoxel(x, y, z); |
| 135 | ip.setf(z, y, value); |
| 136 | } |
| 137 | } |
| 138 | ImageProcessor ip2 = shrink(ip, zshrink, 1, method); |
| 139 | for (int x2=0; x2<d2; x2++) { |
| 140 | for (int y2=0; y2<h; y2++) { |
| 141 | stack2.setVoxel(x, y2, x2, ip2.getf(x2,y2)); |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | return stack2; |
| 146 | } |
| 147 | |
| 148 | public ImageProcessor shrink(ImageProcessor ip, int xshrink, int yshrink, int method) { |
| 149 | this.xshrink = xshrink; |
no test coverage detected