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

Method crop

ij/src/main/java/ij/ImageStack.java:697–708  ·  view source on GitHub ↗

Creates a new stack by cropping this one.

(int x, int y, int z, int width, int height, int depth)

Source from the content-addressed store, hash-verified

695
696 /** Creates a new stack by cropping this one. */
697 public ImageStack crop(int x, int y, int z, int width, int height, int depth) {
698 if (x<0||y<0||z<0||x+width>this.width||y+height>this.height||z+depth>size())
699 throw new IllegalArgumentException("Argument out of range");
700 ImageStack stack2 = new ImageStack(width, height, getColorModel());
701 for (int i=z; i<z+depth; i++) {
702 ImageProcessor ip2 = this.getProcessor(i+1);
703 ip2.setRoi(x, y, width, height);
704 ip2 = ip2.crop();
705 stack2.addSlice(this.getSliceLabel(i+1), ip2);
706 }
707 return stack2;
708 }
709
710 /** Creates a float version of this stack. */
711 public ImageStack convertToFloat() {

Callers 1

duplicateMethod · 0.95

Calls 7

sizeMethod · 0.95
getColorModelMethod · 0.95
getProcessorMethod · 0.95
setRoiMethod · 0.95
cropMethod · 0.95
addSliceMethod · 0.95
getSliceLabelMethod · 0.95

Tested by

no test coverage detected