Returns an ImageProcessor for the specified slice, where {@literal 1<=n<=nslices}. Returns null if the stack is empty.
(int n)
| 313 | * Returns null if the stack is empty. |
| 314 | */ |
| 315 | public ImageProcessor getProcessor(int n) { |
| 316 | ImageProcessor ip; |
| 317 | if (n<1 || n>nSlices) |
| 318 | throw new IllegalArgumentException(outOfRange+n); |
| 319 | if (nSlices==0) |
| 320 | return null; |
| 321 | if (stack[n-1]==null) |
| 322 | throw new IllegalArgumentException("Pixel array is null"); |
| 323 | if (stack[n-1] instanceof byte[]) |
| 324 | ip = new ByteProcessor(width, height, null, cm); |
| 325 | else if (stack[n-1] instanceof short[]) |
| 326 | ip = new ShortProcessor(width, height, null, cm); |
| 327 | else if (stack[n-1] instanceof int[]) { |
| 328 | if (signedInt) |
| 329 | ip = new IntProcessor(width, height); |
| 330 | else |
| 331 | ip = new ColorProcessor(width, height, null); |
| 332 | } else if (stack[n-1] instanceof float[]) |
| 333 | ip = new FloatProcessor(width, height, null, cm); |
| 334 | else |
| 335 | throw new IllegalArgumentException("Unknown stack type"); |
| 336 | ip.setPixels(stack[n-1]); |
| 337 | if (min!=Double.MAX_VALUE && ip!=null && !(ip instanceof ColorProcessor)) |
| 338 | ip.setMinAndMax(min, max); |
| 339 | if (cTable!=null) |
| 340 | ip.setCalibrationTable(cTable); |
| 341 | ip.setSliceNumber(n); |
| 342 | return ip; |
| 343 | } |
| 344 | |
| 345 | /** Assigns the pixel array of an ImageProcessor to the specified slice, |
| 346 | * where {@literal 1<=n<=nslices}. |
no test coverage detected