(ImagePlus imp, int newDepth, int interpolationMethod)
| 220 | } |
| 221 | |
| 222 | public ImagePlus zScale(ImagePlus imp, int newDepth, int interpolationMethod) { |
| 223 | ImagePlus imp2 = null; |
| 224 | if (imp.isHyperStack()) |
| 225 | imp2 = zScaleHyperstack(imp, newDepth, interpolationMethod); |
| 226 | else { |
| 227 | boolean inPlace = (interpolationMethod&IN_PLACE)!=0; |
| 228 | interpolationMethod = interpolationMethod&15; |
| 229 | int stackSize = imp.getStackSize(); |
| 230 | int bitDepth = imp.getBitDepth(); |
| 231 | imp2 = resizeZ(imp, newDepth, interpolationMethod); |
| 232 | if (imp2==null) |
| 233 | return null; |
| 234 | double min = imp.getDisplayRangeMin(); |
| 235 | double max = imp.getDisplayRangeMax(); |
| 236 | imp2.setDisplayRange(min, max); |
| 237 | } |
| 238 | if (imp2==null) |
| 239 | return null; |
| 240 | if (imp2!=imp) { |
| 241 | if (imp.isComposite()) { |
| 242 | imp2 = new CompositeImage(imp2, ((CompositeImage)imp).getMode()); |
| 243 | ((CompositeImage)imp2).copyLuts(imp); |
| 244 | } else |
| 245 | imp2.setLut(imp.getProcessor().getLut()); |
| 246 | } |
| 247 | imp2.setCalibration(imp.getCalibration()); |
| 248 | Calibration cal = imp2.getCalibration(); |
| 249 | if (cal.scaled()) cal.pixelDepth *= (double)imp.getNSlices()/imp2.getNSlices(); |
| 250 | Object info = imp.getProperty("Info"); |
| 251 | if (info!=null) imp2.setProperty("Info", info); |
| 252 | imp2.setProperties(imp.getPropertiesAsArray()); |
| 253 | if (imp.isHyperStack()) |
| 254 | imp2.setOpenAsHyperStack(imp.isHyperStack()); |
| 255 | return imp2; |
| 256 | } |
| 257 | |
| 258 | private ImagePlus zScaleHyperstack(ImagePlus imp, int depth2, int interpolationMethod) { |
| 259 | boolean inPlace = (interpolationMethod&IN_PLACE)!=0; |
no test coverage detected