MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getSlice

Method getSlice

ij/src/main/java/ij/plugin/Slicer.java:474–513  ·  view source on GitHub ↗
(ImagePlus imp, double x1, double y1, double x2, double y2, String status)

Source from the content-addressed store, hash-verified

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) {

Callers 15

resliceMethod · 0.95
resliceRectOrLineMethod · 0.95
getPositionMethod · 0.45
activateSelectionMethod · 0.45
runMethod · 0.45
reduceMethod · 0.45
getInfoMethod · 0.45
addToRoiManagerMethod · 0.45
startAnimationMethod · 0.45
nextSliceMethod · 0.45
previousSliceMethod · 0.45
changeSliceMethod · 0.45

Calls 15

getTypeMethod · 0.95
sizeMethod · 0.95
getProcessorMethod · 0.95
getIrregularProfileMethod · 0.95
getOrthoLineMethod · 0.95
getLineMethod · 0.95
createProcessorMethod · 0.95
putColumnMethod · 0.95
putRowMethod · 0.95
showStatusMethod · 0.95
setInterpolateMethod · 0.95
resizeMethod · 0.95

Tested by

no test coverage detected