ImageStack rotate90Degrees(boolean clockwise) { ImageStack stack2 = new ImageStack(stack.getHeight(), stack.getWidth()); ImageProcessor ip2; if (ip==null) ip = stack.getProcessor(1).duplicate(); for (int i=1; i<=nSlices; i++) { showStatus("Rotate: ",i,nSlices); ip.setPixels(stack.getPixels(1)); String label = stack.getSliceLabel(1); stack.deleteSlice(1); if (clockwise) ip2 = ip.rotateRight(); else ip2 = ip.rotateLeft(); if (ip2!=null) stack2.addSlice(label, ip2); if (!Interpreter.isBatchMode()) IJ.showProgress((double)i/nSlices); } if (!Interpreter.isBatchMode()) IJ.showProgress(1.0); return stack2; }
ImageStack rotate90Degrees(boolean clockwise) { ImageStack stack2 = new ImageStack(stack.getHeight(), stack.getWidth()); ImageProcessor ip2; if (ip==null) ip = stack.getProcessor(1).duplicate(); for (int i=1; i<=nSlices; i++) { showStatus("Rotate: ",i,nSlices); ip.setPixels(stack.getPixels(1)); String label = stack.getSliceLabel(1); stack.deleteSlice(1); if (clockwise) ip2 = ip.rotateRight(); else ip2 = ip.rotateLeft(); if (ip2!=null) stack2.addSlice(label, ip2); if (!Interpreter.isBatchMode()) IJ.showProgress((double)i/nSlices); } if (!Interpreter.isBatchMode()) IJ.showProgress(1.0); return stack2; }
void process(int command) { String s = ""; ImageProcessor ip2 = stack.getProcessor(1); switch (command) { case FLIPH: case FLIPV: s="Flip: "; break; case SCALE: s="Scale: "; break; case SCALE_WITH_FILL: s="Scale: "; ip2.setBackgroundValue(fillValue); break; case INVERT: s="Invert: "; break; case APPLY_TABLE: s="Apply: "; break; } if (ip==null) ip = ip2; ip2.setRoi(this.ip.getRoi()); ip2.setInterpolate(this.ip.getInterpolate()); for (int i=1; i<=nSlices; i++) { showStatus(s,i,nSlices); ip2.setPixels(stack.getPixels(i)); if (nSlices==1 && i==1 && command==SCALE) ip2.snapshot(); switch (command) { case FLIPH: ip2.flipHorizontal(); break; case FLIPV: ip2.flipVertical(); break; case SCALE: case SCALE_WITH_FILL: ip2.scale(xScale, yScale); break; case INVERT: ip2.invert(); break; case APPLY_TABLE: ip2.applyTable(table); break; } IJ.showProgress((double)i/nSlices); } IJ.showProgress(1.0); }
public ImageStack resize(int newWidth, int newHeight, boolean averageWhenDownsizing) { ImageStack stack2 = new ImageStack(newWidth, newHeight); ImageProcessor ip2; Rectangle roi = ip!=null?ip.getRoi():null; if (ip==null) ip = stack.getProcessor(1).duplicate(); try { for (int i=1; i<=nSlices; i++) { showStatus("Resize: ",i,nSlices); ip.setPixels(stack.getPixels(1)); String label = stack.getSliceLabel(1); stack.deleteSlice(1); ip2 = ip.resize(newWidth, newHeight, averageWhenDownsizing); if (ip2!=null) stack2.addSlice(label, ip2); IJ.showProgress((double)i/nSlices); } IJ.showProgress(1.0); } catch(OutOfMemoryError o) { while(stack.getSize()>1) stack.deleteLastSlice(); IJ.outOfMemory("StackProcessor.resize"); IJ.showProgress(1.0); } return stack2; }
public ImageStack resize(int newWidth, int newHeight, boolean averageWhenDownsizing) { ImageStack stack2 = new ImageStack(newWidth, newHeight); ImageProcessor ip2; Rectangle roi = ip!=null?ip.getRoi():null; if (ip==null) ip = stack.getProcessor(1).duplicate(); try { for (int i=1; i<=nSlices; i++) { showStatus("Resize: ",i,nSlices); ip.setPixels(stack.getPixels(1)); String label = stack.getSliceLabel(1); stack.deleteSlice(1); ip2 = ip.resize(newWidth, newHeight, averageWhenDownsizing); if (ip2!=null) stack2.addSlice(label, ip2); IJ.showProgress((double)i/nSlices); } IJ.showProgress(1.0); } catch(OutOfMemoryError o) { while(stack.getSize()>1) stack.deleteLastSlice(); IJ.outOfMemory("StackProcessor.resize"); IJ.showProgress(1.0); } return stack2; }
void process(int command) { String s = ""; ImageProcessor ip2 = stack.getProcessor(1); switch (command) { case FLIPH: case FLIPV: s="Flip: "; break; case SCALE: s="Scale: "; break; case SCALE_WITH_FILL: s="Scale: "; ip2.setBackgroundValue(fillValue); break; case INVERT: s="Invert: "; break; case APPLY_TABLE: s="Apply: "; break; } if (ip==null) ip = ip2; ip2.setRoi(this.ip.getRoi()); ip2.setInterpolate(this.ip.getInterpolate()); for (int i=1; i<=nSlices; i++) { showStatus(s,i,nSlices); ip2.setPixels(stack.getPixels(i)); if (nSlices==1 && i==1 && command==SCALE) ip2.snapshot(); switch (command) { case FLIPH: ip2.flipHorizontal(); break; case FLIPV: ip2.flipVertical(); break; case SCALE: case SCALE_WITH_FILL: ip2.scale(xScale, yScale); break; case INVERT: ip2.invert(); break; case APPLY_TABLE: ip2.applyTable(table); break; } IJ.showProgress((double)i/nSlices); } IJ.showProgress(1.0); }