private void removeStackLabels() { ImagePlus imp = IJ.getImage(); int size = imp.getStackSize(); if (size==1) IJ.error("Stack required"); else { ImageStack stack = imp.getStack(); for (int i=1; i<=size; i++) stack.setSliceLabel(null, i); imp.repaintWindow(); } }
private boolean checkImage() { if (IJ.debugMode) IJ.log("ColorThresholder.checkImage"); ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getBitDepth()!=24) { IJ.beep(); IJ.showStatus("No RGB image"); return false; } imp.deleteRoi(); boolean ok = setup(imp); return ok; }
public void calculateSizes(){ if(showStatus) IJ.showStatus("calculate class sizes..."); ImageStack resStack = result.getStack(); sizes = new int[classes.length]; for(int d=1;d<=z;d++){ int[] classPixels = (int[])resStack .getProcessor(d).getPixels(); for(int i=0;i<w*h;i++){ if(classPixels[i] != -1) sizes[classPixels[i]]++; } if(showStatus) IJ.showProgress(d,z); } }
void note(final String message) { if (image != null) new MTJMessage((Frame)image.getWindow(),MTJ_NOTE,message+"."); else if (IJ.getInstance() != null) new MTJMessage(IJ.getInstance(),MTJ_NOTE,message+"."); else IJ.showMessage(MTJ_NOTE,message+"."); }
private void unlock() { ImagePlus imp = IJ.getImage(); boolean wasUnlocked = imp.lockSilently(); if (wasUnlocked) IJ.showStatus("\""+imp.getTitle()+"\" is not locked"); else { IJ.showStatus("\""+imp.getTitle()+"\" is now unlocked"); IJ.beep(); } imp.unlock(); }
public int setup(String arg, ImagePlus imp) { this.imp = imp; if (imp==null) {IJ.noImage(); return DONE;} stackSize = imp.getStackSize(); if (imp.getProperty("FHT")!=null) { IJ.error("FFT Custom Filter", "Spatial domain (non-FFT) image required"); return DONE; } else return processStack?DOES_ALL+DOES_STACKS:DOES_ALL; }
/** * bag class for getting the result of the loaded classifier */ private static class LoadedClassifier { private AbstractClassifier newClassifier = null; private Instances newHeader = null; }
void showInternalClipboard() { ImagePlus clipboard = ImagePlus.getClipboard(); if (clipboard!=null) { ImageProcessor ip = clipboard.getProcessor(); ImagePlus imp2 = new ImagePlus("Clipboard", ip.duplicate()); Roi roi = clipboard.getRoi(); imp2.deleteRoi(); if (roi!=null && roi.isArea() && roi.getType()!=Roi.RECTANGLE) { roi = (Roi)roi.clone(); roi.setLocation(0, 0); imp2.setRoi(roi); IJ.run(imp2, "Clear Outside", null); imp2.deleteRoi(); } WindowManager.checkForDuplicateName = true; imp2.show(); } else IJ.error("The internal clipboard is empty."); }
private void rename() { ImagePlus imp = IJ.getImage(); GenericDialog gd = new GenericDialog("Rename"); gd.addStringField("Title:", imp.getTitle(), 30); gd.showDialog(); if (!gd.wasCanceled()) imp.setTitle(gd.getNextString()); }
ImageStack createOutputStack(ImagePlus imp, ImageProcessor ip) { int bitDepth = imp.getBitDepth(); int w2=ip.getWidth(), h2=ip.getHeight(), d2=outputSlices; int flags = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY; ImagePlus imp2 = NewImage.createImage("temp", w2, h2, d2, bitDepth, flags); if (imp2!=null && imp2.getStackSize()==d2) IJ.showStatus("Reslice... (press 'Esc' to abort)"); if (imp2==null) return null; else { ImageStack stack2 = imp2.getStack(); stack2.setColorModel(ip.getColorModel()); return stack2; } }
public ImageStack straightenStack(ImagePlus imp, Roi roi, int width) { int current = imp.getCurrentSlice(); int n = imp.getStackSize(); ImageStack stack2 = null; for (int i=1; i<=n; i++) { IJ.showProgress(i, n); imp.setSlice(i); ImageProcessor ip2 = straighten(imp, roi, width); if (stack2==null) stack2 = new ImageStack(ip2.getWidth(), ip2.getHeight()); stack2.addSlice(null, ip2); } imp.setSlice(current); return stack2; }
ImageStack convertToRealStack(ImagePlus imp) { ImageStack stack2 = new ImageStack(imageWidth, imageHeight, imp.getProcessor().getColorModel()); int n = this.getSize(); for (int i=1; i<=this.getSize(); i++) { IJ.showProgress(i, n); IJ.showStatus("Opening: "+i+"/"+n); ImageProcessor ip2 = this.getProcessor(i); if (ip2!=null) stack2.addSlice(this.getSliceLabel(i), ip2); } return stack2; }
public void setFrame() { int index = preview.getCurrentSlice(); if(!IJ.getImage().getTitle().equals( stack.getPreview().getSliceLabel(index))) return; ImageProcessor ip = IJ.getImage().getProcessor(); stack.setSlice(index, ip); IJ.getImage().changes = false; IJ.getImage().close(); preview.setStack(null, stack.getPreview()); preview.setSlice(index); }
void createMaskFromThreshold(ImagePlus imp) { ImageProcessor ip = imp.getProcessor(); if (ip.getMinThreshold()==ImageProcessor.NO_THRESHOLD) { IJ.error("Create Mask", "Area selection, overlay or thresholded image required"); return; } ByteProcessor mask = imp.createThresholdMask(); if (!Prefs.blackBackground) mask.invertLut(); new ImagePlus("mask",mask).show(); Recorder.recordCall("mask = imp.createThresholdMask();"); }
private void renameMaterial() { GenericDialog gd = new GenericDialog("Rename"); gd.addStringField("name", getSelectedItem()); gd.showDialog(); if (gd.wasCanceled()) return; String newName = gd.getNextString(); if (newName.indexOf(' ') >= 0) { newName = newName.replace(' ', '_'); IJ.showMessage("Names cannot contain spaces; using '" + newName + "' instead!"); } renameMaterial(newName); }
public void run(String arg) { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} ImageStack stack = imp.getStack(); if (stack.getSize()==1) {IJ.error("Stack Required"); return;} if (!showDialog(stack)) return; removeSlices(stack, first, last, inc); imp.setStack(null, stack); IJ.register(Slice_Remover.class); }
void invert(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi==null || !roi.isArea()) {IJ.error("Inverse", "Area selection required"); return;} ShapeRoi s1, s2; if (roi instanceof ShapeRoi) s1 = (ShapeRoi)roi; else s1 = new ShapeRoi(roi); s2 = new ShapeRoi(new Roi(0,0, imp.getWidth(), imp.getHeight())); Undo.setup(Undo.ROI, imp); imp.setRoi(s1.xor(s2)); }
public void run(ImageProcessor ip) { SegmentatorModel model = new SegmentatorModel(IJ.getImage()); int currentSlice = model.data.getCurrentSlice(); ImageProcessor labelData = model.getLabelImagePlus().getStack().getProcessor(currentSlice); if(model.getCurrentMaterial() == null){ IJ.showMessage("please select a label first"); return; } close(labelData, IJ.getImage().getRoi(), (byte)model.getCurrentMaterial().id); model.updateSlice(currentSlice); }
private FloatProcessor getRoiProcessor(ImagePlus imp, Roi roi, int index) { ImageProcessor ip = imp.getStack().getProcessor(index); ip.setRoi(roi.getBounds()); FloatProcessor fp = subtract(ip.crop().convertToFloatProcessor(), (float) CameraSetupPlugIn.getOffset()); float minVal = VectorMath.min((float[]) fp.getPixels()); if(minVal < 0) { IJ.log("\\Update:Camera base level is set higher than values in the image!"); fp = add(-minVal, fp); } fp.setMask(roi.getMask()); return fp; }