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

Method resliceHyperstack

ij/src/main/java/ij/plugin/Slicer.java:174–218  ·  view source on GitHub ↗
(ImagePlus imp)

Source from the content-addressed store, hash-verified

172 }
173
174 ImagePlus resliceHyperstack(ImagePlus imp) {
175 int channels = imp.getNChannels();
176 int slices = imp.getNSlices();
177 int frames = imp.getNFrames();
178 if (slices==1)
179 return resliceTimeLapseHyperstack(imp);
180 int c1 = imp.getChannel();
181 int z1 = imp.getSlice();
182 int t1 = imp.getFrame();
183 int width = imp.getWidth();
184 int height = imp.getHeight();
185 ImagePlus imp2 = null;
186 ImageStack stack2 = null;
187 Roi roi = imp.getRoi();
188 for (int t=1; t<=frames; t++) {
189 for (int c=1; c<=channels; c++) {
190 ImageStack tmp1Stack = new ImageStack(width, height);
191 for (int z=1; z<=slices; z++) {
192 imp.setPositionWithoutUpdate(c, z, t);
193 tmp1Stack.addSlice(null, imp.getProcessor());
194 }
195 ImagePlus tmp1 = new ImagePlus("tmp", tmp1Stack);
196 tmp1.setCalibration(imp.getCalibration());
197 tmp1.setRoi(roi);
198 ImagePlus tmp2 = reslice(tmp1);
199 int slices2 = tmp2.getStackSize();
200 if (imp2==null) {
201 imp2 = tmp2.createHyperStack("Reslice of "+imp.getTitle(), channels, slices2, frames, tmp2.getBitDepth());
202 stack2 = imp2.getStack();
203 }
204 ImageStack tmp2Stack = tmp2.getStack();
205 for (int z=1; z<=slices2; z++) {
206 imp.setPositionWithoutUpdate(c, z, t);
207 int n2 = imp2.getStackIndex(c, z, t);
208 stack2.setPixels(tmp2Stack.getPixels(z), n2);
209 }
210 }
211 }
212 imp.setPosition(c1, z1, t1);
213 if (channels>1 && imp.isComposite()) {
214 imp2 = new CompositeImage(imp2, ((CompositeImage)imp).getMode());
215 ((CompositeImage)imp2).copyLuts(imp);
216 }
217 return imp2;
218 }
219
220 ImagePlus resliceTimeLapseHyperstack(ImagePlus imp) {
221 int channels = imp.getNChannels();

Callers 1

runMethod · 0.95

Calls 15

addSliceMethod · 0.95
setCalibrationMethod · 0.95
setRoiMethod · 0.95
resliceMethod · 0.95
getStackSizeMethod · 0.95
createHyperStackMethod · 0.95
getBitDepthMethod · 0.95
getStackMethod · 0.95
getStackIndexMethod · 0.95
setPixelsMethod · 0.95
getPixelsMethod · 0.95

Tested by

no test coverage detected