(ImagePlus imp, double x1, double y1, double x2, double y2, String status)
| 472 | } |
| 473 | |
| 474 | ImageProcessor getSlice(ImagePlus imp, double x1, double y1, double x2, double y2, String status) { |
| 475 | Roi roi = imp.getRoi(); |
| 476 | int roiType = roi!=null?roi.getType():0; |
| 477 | ImageStack stack = imp.getStack(); |
| 478 | int stackSize = stack.size(); |
| 479 | ImageProcessor ip,ip2=null; |
| 480 | float[] line = null; |
| 481 | boolean ortho = (int)x1==x1&&(int)y1==y1&&x1==x2||y1==y2; |
| 482 | for (int i=0; i<stackSize; i++) { |
| 483 | ip = stack.getProcessor(flip?stackSize-i:i+1); |
| 484 | if (ip==null) { // work around for Fiji Import>Movie (FFMPEG) bug |
| 485 | imp.setSlice(flip?stackSize-i:i+1); |
| 486 | ip = imp.getProcessor(); |
| 487 | } |
| 488 | if (roiType==Roi.POLYLINE || roiType==Roi.FREELINE) |
| 489 | line = getIrregularProfile(roi, ip); |
| 490 | else if (ortho) |
| 491 | line = getOrthoLine(ip, (int)x1, (int)y1, (int)x2, (int)y2, line); |
| 492 | else |
| 493 | line = getLine(ip, x1, y1, x2, y2, line); |
| 494 | if (rotate) { |
| 495 | if (i==0) ip2 = ip.createProcessor(stackSize, line.length); |
| 496 | putColumn(ip2, i, 0, line, line.length); |
| 497 | } else { |
| 498 | if (i==0) ip2 = ip.createProcessor(line.length, stackSize); |
| 499 | putRow(ip2, 0, i, line, line.length); |
| 500 | } |
| 501 | if (status!=null) IJ.showStatus("Slicing: "+status +i+"/"+stackSize); |
| 502 | } |
| 503 | Calibration cal = imp.getCalibration(); |
| 504 | double zSpacing = inputZSpacing/cal.pixelWidth; |
| 505 | if (zSpacing!=1.0) { |
| 506 | ip2.setInterpolate(true); |
| 507 | if (rotate) |
| 508 | ip2 = ip2.resize((int)(stackSize*zSpacing), line.length); |
| 509 | else |
| 510 | ip2 = ip2.resize(line.length, (int)(stackSize*zSpacing)); |
| 511 | } |
| 512 | return ip2; |
| 513 | } |
| 514 | |
| 515 | public void putRow(ImageProcessor ip, int x, int y, float[] data, int length) { |
| 516 | if (rgb) { |
no test coverage detected