/** Deletes the last slice in the stack. */ public void deleteLastSlice() { if (nSlices>0) deleteSlice(nSlices); }
/** Deletes the last slice in the stack. */ public void deleteLastSlice() { if (nSlices>0) deleteSlice(nSlices); }
public void deleteSlice(int index) { File f = new File(dir + "/" + preview.getSliceLabel(index)); f.delete(); preview.deleteSlice(index); }
/** * Remove feature from stack * * @param featureName complete name of the feature to remove */ public void removeFeature(String featureName) { for(int n=1; n<=wholeStack.getSize(); n++) if(featureName.equalsIgnoreCase(wholeStack.getSliceLabel(n))) { this.wholeStack.deleteSlice(n); return; } }
/** * Remove feature from stack * * @param featureName complete name of the feature to remove */ public void removeFeature(String featureName) { for(int n=1; n<=wholeStack.getSize(); n++) if(featureName.equalsIgnoreCase(wholeStack.getSliceLabel(n))) { this.wholeStack.deleteSlice(n); return; } }
public static void deleteFrames(ImagePlus imp, int slice, int num) { ImageStack stack = imp.getStack(); for(int n = 0; n < num; n++) stack.deleteSlice(slice); /* * causes the change from image window to stack window * also: * causes update of current slice. Previously, the * current slice was not updated, so showed the wrong * image. When the user then scrolled, the wrong image * was stored to the corresponding file. */ imp.setStack(null, stack); } }
public void removeSlices(ImageStack stack, int first, int last, int inc) { if (last>stack.getSize()) last = stack.getSize(); int count = 0; for (int i=first; i<=last; i+=inc) { if ((i-count)>stack.getSize()) break; stack.deleteSlice(i-count); count++; } }
void reverse(){ for(int iSlice = 1; iSlice < numSlices; iSlice++){ stack.addSlice(stack.getSliceLabel(1), stack.getProcessor(1),numSlices - iSlice + 1); stack.deleteSlice(1); } imp.setStack(null,stack); imp.updateAndDraw(); } void sortByLabel(){
void last(){ if(slice!=numSlices){ stack.addSlice(stack.getSliceLabel(slice), stack.getProcessor(slice),numSlices); stack.deleteSlice(slice); imp.setStack(null,stack); imp.setSlice(numSlices); imp.updateAndDraw(); } } void dup(){
void sortByLabel(){ boolean swapped = false; for(int pass = 0; pass < numSlices; pass++){ for(int iSlice = 1; iSlice < (numSlices-pass); iSlice++){ int comp = stack.getSliceLabel(iSlice).compareTo(stack.getSliceLabel(iSlice+1)); if(comp > 0){ swapped = true; stack.addSlice(stack.getSliceLabel(iSlice), stack.getProcessor(iSlice),iSlice+1); stack.deleteSlice(iSlice); } } if(!swapped)break; } imp.setStack(null,stack); imp.updateAndDraw(); } void sortByMean(){
void first(){ if(slice!=1){ stack.addSlice(stack.getSliceLabel(slice), stack.getProcessor(slice),0); stack.deleteSlice(slice+1); imp.setStack(null,stack); imp.setSlice(1); imp.updateAndDraw(); } } void bkwd(){
void bkwd(){ if(slice!=numSlices){ stack.addSlice(stack.getSliceLabel(slice), stack.getProcessor(slice),slice+1); stack.deleteSlice(slice); imp.setStack(null,stack); imp.setSlice(slice+1); imp.updateAndDraw(); } } void fwd(){
void fwd(){ if(slice!=1){ stack.addSlice(stack.getSliceLabel(slice), stack.getProcessor(slice),slice-2); stack.deleteSlice(slice+1); imp.setStack(null,stack); imp.setSlice(slice-1); imp.updateAndDraw(); } } void last(){
/** Crops the stack to the specified rectangle. */ public ImageStack crop(int x, int y, int width, int height) { ImageStack stack2 = new ImageStack(width, height); ImageProcessor ip2; for (int i=1; i<=nSlices; i++) { ImageProcessor ip1 = stack.getProcessor(1); ip1.setRoi(x, y, width, height); String label = stack.getSliceLabel(1); stack.deleteSlice(1); ip2 = ip1.crop(); stack2.addSlice(label, ip2); IJ.showProgress((double)i/nSlices); } IJ.showProgress(1.0); return stack2; }
/** Crops the stack to the specified rectangle. */ public ImageStack crop(int x, int y, int width, int height) { ImageStack stack2 = new ImageStack(width, height); ImageProcessor ip2; for (int i=1; i<=nSlices; i++) { ImageProcessor ip1 = stack.getProcessor(1); ip1.setRoi(x, y, width, height); String label = stack.getSliceLabel(1); stack.deleteSlice(1); ip2 = ip1.crop(); stack2.addSlice(label, ip2); IJ.showProgress((double)i/nSlices); } IJ.showProgress(1.0); return stack2; }
private void concat(ImageStack stack3, ImageStack stack1, boolean dup) { int slice = 1; int size = stack1.getSize(); for (int i = 1; i <= size; i++) { ImageProcessor ip = stack1.getProcessor(slice); String label = stack1.getSliceLabel(slice); if (dup) { ip = ip.duplicate(); slice++; } else stack1.deleteSlice(slice); ImageProcessor ip2 = ip; if (ip.getWidth()!=maxWidth || ip.getHeight()!=maxHeight) { ip2 = ip.createProcessor(maxWidth, maxHeight); ip2.insert(ip, (maxWidth-ip.getWidth())/2, (maxHeight-ip.getHeight())/2); } stack3.addSlice(label, ip2); } }
private void concat(ImageStack stack3, ImageStack stack1, boolean dup) { int slice = 1; int size = stack1.getSize(); for (int i = 1; i <= size; i++) { ImageProcessor ip = stack1.getProcessor(slice); String label = stack1.getSliceLabel(slice); if (dup) { ip = ip.duplicate(); slice++; } else stack1.deleteSlice(slice); ImageProcessor ip2 = ip; if (ip.getWidth()!=maxWidth || ip.getHeight()!=maxHeight) { ip2 = ip.createProcessor(maxWidth, maxHeight); ip2.insert(ip, (maxWidth-ip.getWidth())/2, (maxHeight-ip.getHeight())/2); } stack3.addSlice(label, ip2); } }
void del() { if (!imp.lock()) return; ImageStack stack = imp.getStack(); int n = imp.getCurrentSlice(); stack.deleteSlice(n); if (stack.getSize()==1) { imp.setProcessor(null, stack.getProcessor(1)); new ImageWindow(imp); } imp.setStack(null, stack); numSlices--; if (n>numSlices) imp.setSlice(numSlices); else imp.setSlice(n); imp.unlock(); } void delN(){
void deleteSlice() { if (nSlices<2) {IJ.error("\"Delete Slice\" requires a stack"); return;} if (imp.isHyperStack() || (imp.isComposite() && nSlices==imp.getNChannels())) { deleteHyperstackChannelSliceOrFrame(); return; } if (!imp.lock()) return; ImageStack stack = imp.getStack(); int n = imp.getCurrentSlice(); stack.deleteSlice(n); if (stack.getSize()==1) { String label = stack.getSliceLabel(1); if (label!=null) imp.setProperty("Label", label); } imp.setStack(null, stack); if (n--<1) n = 1; imp.setSlice(n); imp.unlock(); imp.changes = true; }
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; }