(ImagePlus imp, int depth2, int interpolationMethod)
| 256 | } |
| 257 | |
| 258 | private ImagePlus zScaleHyperstack(ImagePlus imp, int depth2, int interpolationMethod) { |
| 259 | boolean inPlace = (interpolationMethod&IN_PLACE)!=0; |
| 260 | boolean scaleT = (interpolationMethod&SCALE_T)!=0; |
| 261 | interpolationMethod = interpolationMethod&15; |
| 262 | int channels = imp.getNChannels(); |
| 263 | int slices = imp.getNSlices(); |
| 264 | int frames = imp.getNFrames(); |
| 265 | int slices2 = slices; |
| 266 | int frames2 = frames; |
| 267 | int bitDepth = imp.getBitDepth(); |
| 268 | if (slices==1 && frames>1) |
| 269 | scaleT = true; |
| 270 | if (scaleT) |
| 271 | frames2 = depth2; |
| 272 | else |
| 273 | slices2 = depth2; |
| 274 | double scale = (double)(depth2-1)/slices; |
| 275 | if (scaleT) scale = (double)(depth2-1)/frames; |
| 276 | ImageStack stack1 = imp.getStack(); |
| 277 | int width = stack1.getWidth(); |
| 278 | int height = stack1.getHeight(); |
| 279 | ImagePlus imp2 = IJ.createImage(imp.getTitle(), bitDepth+"-bit", width, height, channels*slices2*frames2); |
| 280 | if (imp2==null) return null; |
| 281 | imp2.setDimensions(channels, slices2, frames2); |
| 282 | ImageStack stack2 = imp2.getStack(); |
| 283 | ImageProcessor ip = imp.getProcessor(); |
| 284 | int count = 0; |
| 285 | if (scaleT) { |
| 286 | IJ.showStatus("T Scaling..."); |
| 287 | ImageProcessor xtPlane1 = ip.createProcessor(width, frames); |
| 288 | xtPlane1.setInterpolationMethod(interpolationMethod); |
| 289 | ImageProcessor xtPlane2; |
| 290 | Object xtpixels1 = xtPlane1.getPixels(); |
| 291 | int last = slices*channels*height-1; |
| 292 | for (int z=1; z<=slices; z++) { |
| 293 | for (int c=1; c<=channels; c++) { |
| 294 | for (int y=0; y<height; y++) { |
| 295 | IJ.showProgress(count++, last); |
| 296 | for (int t=1; t<=frames; t++) { |
| 297 | int index = imp.getStackIndex(c, z, t); |
| 298 | //IJ.log("1: "+c+" "+z+" "+t+" "+index+" "+xzPlane1); |
| 299 | Object pixels1 = stack1.getPixels(index); |
| 300 | System.arraycopy(pixels1, y*width, xtpixels1, (t-1)*width, width); |
| 301 | } |
| 302 | xtPlane2 = xtPlane1.resize(width, depth2, averageWhenDownsizing); |
| 303 | Object xtpixels2 = xtPlane2.getPixels(); |
| 304 | for (int t=1; t<=frames2; t++) { |
| 305 | int index = imp2.getStackIndex(c, z, t); |
| 306 | //IJ.log("2: "+c+" "+z+" "+t+" "+index+" "+xzPlane2); |
| 307 | Object pixels2 = stack2.getPixels(index); |
| 308 | System.arraycopy(xtpixels2, (t-1)*width, pixels2, y*width, width); |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | } else { |
| 314 | IJ.showStatus("Z Scaling..."); |
| 315 | ImageProcessor xzPlane1 = ip.createProcessor(width, slices); |
no test coverage detected