Returns an ImageProcessor for the specified slice of this virtual stack (if it is one) where {@literal 1<=n<=nslices}. Returns null if no virtual stack or no slices or error reading the frame.
(int n)
| 450 | * where {@literal 1<=n<=nslices}. Returns null if no virtual stack or no slices or error reading the frame. |
| 451 | */ |
| 452 | public synchronized ImageProcessor getProcessor(int n) { |
| 453 | if (frameInfos==null || frameInfos.size()==0 || raFilePath==null) |
| 454 | return null; |
| 455 | n = translate(n); // update n for hyperstacks not in default CZT order |
| 456 | if (n<1 || n>frameInfos.size()) |
| 457 | throw new IllegalArgumentException("Argument out of range: "+n); |
| 458 | Object pixels = null; |
| 459 | RandomAccessFile rFile = null; |
| 460 | try { |
| 461 | rFile = new RandomAccessFile(new File(raFilePath), "r"); |
| 462 | long[] frameInfo = (long[])(frameInfos.get(n-1)); |
| 463 | pixels = readFrame(rFile, frameInfo[0], (int)frameInfo[1]); |
| 464 | } catch (Exception e) { |
| 465 | error(exceptionMessage(e)); |
| 466 | return null; |
| 467 | } finally { |
| 468 | closeFile(rFile); |
| 469 | } |
| 470 | if (pixels == null) return null; //failed |
| 471 | ImageProcessor ip = null; |
| 472 | if (pixels instanceof byte[]) |
| 473 | ip = new ByteProcessor(dwWidth, biHeight, (byte[])pixels, cm); |
| 474 | else if (pixels instanceof short[]) |
| 475 | ip = new ShortProcessor(dwWidth, biHeight, (short[])pixels, cm); |
| 476 | else |
| 477 | ip = new ColorProcessor(dwWidth, biHeight, (int[])pixels); |
| 478 | if (ip!=null) |
| 479 | ip.setSliceNumber(n); |
| 480 | return ip; |
| 481 | } |
| 482 | |
| 483 | /** Returns the image width of the virtual stack */ |
| 484 | public int getWidth() { |
no test coverage detected