MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / shrinkZ

Method shrinkZ

ij/src/main/java/ij/plugin/Binner.java:117–146  ·  view source on GitHub ↗
(ImageStack stack, int zshrink)

Source from the content-addressed store, hash-verified

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;

Callers 1

shrinkMethod · 0.95

Calls 14

addSliceMethod · 0.95
showProgressMethod · 0.95
setfMethod · 0.95
shrinkMethod · 0.95
setVoxelMethod · 0.95
getfMethod · 0.95
getVoxelMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
sizeMethod · 0.45
getColorModelMethod · 0.45
duplicateMethod · 0.45

Tested by

no test coverage detected