static int type(final ImagePlus imp) { int type = SINGLEIMAGE; boolean i5dexist = false; try { Class.forName("i5d.Image5D"); i5dexist = true; } catch (Throwable e) { } if (i5dexist && I5DResource.instance(imp)) type = IMAGE5D; else if (imp.isComposite()) type = COMPOSITEIMAGE; else if (imp.isHyperStack()) type = HYPERSTACK; else if (imp.getImageStackSize() > 1) type = IMAGESTACK; return type; }
private static int type(final ImagePlus imp) { int type = SINGLEIMAGE; boolean i5dexist = false; try { Class.forName("i5d.Image5D"); i5dexist = true; } catch (Throwable e) { } if (i5dexist && I5DResource.instance(imp)) type = IMAGE5D; else if (imp.isComposite()) type = COMPOSITEIMAGE; else if (imp.isHyperStack()) type = HYPERSTACK; else if (imp.getImageStackSize() > 1) type = IMAGESTACK; return type; }
/** Create a new Patch and register the associated {@code filepath} * with the project's loader. * * This method is intended for scripting, to avoid having to create a new Patch * and then call {@link Loader#addedPatchFrom(String, Patch)}, which is easy to forget. * * @return the new Patch. * @throws Exception if the image cannot be loaded from the {@code filepath}, or it's an unsupported type such as a composite image or a hyperstack. */ static public final Patch createPatch(final Project project, final String filepath) throws Exception { final ImagePlus imp = project.getLoader().openImagePlus(filepath); if (null == imp) throw new Exception("Cannot create Patch: the image cannot be opened from filepath " + filepath); if (imp.isComposite()) throw new Exception("Cannot create Patch: composite images are not supported. Convert them to RGB first."); if (imp.isHyperStack()) throw new Exception("Cannot create Patch: hyperstacks are not supported."); final Patch p = new Patch(project, new File(filepath).getName(), 0, 0, imp); project.getLoader().addedPatchFrom(filepath, p); return p; }
private void run(ImagePlus imp, int filter, float radX, float radY, float radZ) { if (imp.isHyperStack()) { filterHyperstack(imp, filter, radX, radY, radZ); return; } ImageStack res = filter(imp.getStack(), filter, radX, radY, radZ); imp.setStack(res); }
private void run(ImagePlus imp, int filter, float radX, float radY, float radZ) { if (imp.isHyperStack()) { filterHyperstack(imp, filter, radX, radY, radZ); return; } ImageStack res = filter(imp.getStack(), filter, radX, radY, radZ); imp.setStack(res); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (imp.getStackSize()==1) { IJ.error("Flip Z", "This command requires a stack"); return; } if (imp.isHyperStack()) { IJ.error("Flip Z", "This command does not currently work with hyperstacks."); return; } flipStack(imp); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (imp.getStackSize()==1) { IJ.error("Flip Z", "This command requires a stack"); return; } if (imp.isHyperStack()) { IJ.error("Flip Z", "This command does not currently work with hyperstacks."); return; } flipStack(imp); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (imp.isHyperStack() || imp.isComposite()) { (new SubHyperstackMaker()).run(""); return; } String userInput = showDialog(); if (userInput==null) return; ImagePlus imp2 = makeSubstack(imp, userInput); if (imp2!=null) imp2.show(); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (imp.isHyperStack() || imp.isComposite()) { (new SubHyperstackMaker()).run(""); return; } String userInput = showDialog(); if (userInput==null) return; ImagePlus imp2 = makeSubstack(imp, userInput); if (imp2!=null) imp2.show(); }
void setSlice() { int n = (int)getArg(); ImagePlus imp = getImage(); int nSlices = imp.getStackSize(); if (n==1 && nSlices==1) return; else if (n<1 || n>nSlices) interp.error("Argument must be >=1 and <="+nSlices); else { if (imp.isHyperStack()) imp.setPosition(n); else imp.setSlice(n); } resetImage(); }
void setSlice() { int n = (int)getArg(); ImagePlus imp = getImage(); int nSlices = imp.getStackSize(); if (n==1 && nSlices==1) return; else if (n<1 || n>nSlices) interp.error("Argument must be >=1 and <="+nSlices); else { if (imp.isHyperStack()) imp.setPosition(n); else imp.setSlice(n); } resetImage(); }
private void setDefaultBounds() { int stackSize = imp.getStackSize(); int channels = imp.getNChannels(); int frames = imp.getNFrames(); int slices = imp.getNSlices(); isHyperstack = imp.isHyperStack()||( ij.macro.Interpreter.isBatchMode()&&((frames>1&&frames<stackSize)||(slices>1&&slices<stackSize))); simpleComposite = channels==stackSize; if (simpleComposite) isHyperstack = false; startSlice = 1; if (isHyperstack) { int nSlices = imp.getNSlices(); if (nSlices>1) stopSlice = nSlices; else stopSlice = imp.getNFrames(); } else stopSlice = stackSize; }
/** Sets the position of this ROI based on the stack position of the specified image. */ public void setPosition(ImagePlus imp ) { if (imp==null) return; if (imp.isHyperStack()) { int channel = imp.getDisplayMode()==IJ.COMPOSITE?0:imp.getChannel(); setPosition(channel, imp.getSlice(), imp.getFrame()); } else if (imp.getStackSize()>1) setPosition(imp.getCurrentSlice()); else setPosition(0); }
/** Sets the position of this ROI based on the stack position of the specified image. */ public void setPosition(ImagePlus imp ) { if (imp==null) return; if (imp.isHyperStack()) { int channel = imp.getDisplayMode()==IJ.COMPOSITE?0:imp.getChannel(); setPosition(channel, imp.getSlice(), imp.getFrame()); } else if (imp.getStackSize()>1) setPosition(imp.getCurrentSlice()); else setPosition(0); }
private ImagePlus flatten(ImagePlus imp) { if (imp.getOverlay()!=null && !imp.getHideOverlay() && !imp.isHyperStack()) { ImagePlus imp2 = imp; Roi roi = imp.getRoi(); if (imp.getStackSize()>1) { imp.deleteRoi(); int slice = imp.getCurrentSlice(); imp = new Duplicator().run(imp, slice, slice); } imp = imp.flatten(); imp.setRoi(roi); imp2.setRoi(roi); } return imp; }
private ImagePlus flatten(ImagePlus imp) { if (imp.getOverlay()!=null && !imp.getHideOverlay() && !imp.isHyperStack()) { ImagePlus imp2 = imp; Roi roi = imp.getRoi(); if (imp.getStackSize()>1) { imp.deleteRoi(); int slice = imp.getCurrentSlice(); imp = new Duplicator().run(imp, slice, slice); } imp = imp.flatten(); imp.setRoi(roi); imp2.setRoi(roi); } return imp; }
public void run(String arg) { ImagePlus imp = IJ.getImage(); int size = imp.getStackSize(); if (size==1) { IJ.error("Z Project", "This command requires a stack"); return; } if (imp.isHyperStack()) { new ZProjector().run(""); return; } if (!showDialog(imp)) return; ImagePlus imp2 = groupZProject(imp, method, groupSize); imp2.setCalibration(imp.getCalibration()); Calibration cal = imp2.getCalibration(); cal.pixelDepth *= groupSize; if (imp!=null) imp2.show(); }
public boolean showDialog(ImageStack stack) { hyperstack = imp.isHyperStack(); boolean showCheckbox = false; if (hyperstack && imp.getNSlices()>1 && imp.getNFrames()>1) showCheckbox = true; else if (hyperstack && imp.getNSlices()>1) reduceSlices = true; int n = stack.getSize(); GenericDialog gd = new GenericDialog("Reduce Size"); gd.addNumericField("Reduction Factor:", factor, 0); if (showCheckbox) gd.addCheckbox("Reduce in Z-Dimension", false); gd.showDialog(); if (gd.wasCanceled()) return false; factor = (int) gd.getNextNumber(); if (showCheckbox) reduceSlices = gd.getNextBoolean(); return true; }
private void setPosition(ImagePlus imp, Roi roi) { boolean setPos = defaultRoi.getPosition()!=0; int stackSize = imp.getStackSize(); if (setPos && stackSize>1) { if (imp.isHyperStack()||imp.isComposite()) { boolean compositeMode = imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE; int channel = !compositeMode||imp.getNChannels()==stackSize?imp.getChannel():0; if (imp.getNSlices()>1) roi.setPosition(channel, imp.getSlice(), 0); else if (imp.getNFrames()>1) roi.setPosition(channel, 0, imp.getFrame()); } else roi.setPosition(imp.getCurrentSlice()); } }
private void setPosition(ImagePlus imp, Roi roi) { boolean setPos = defaultRoi.getPosition()!=0; int stackSize = imp.getStackSize(); if (setPos && stackSize>1) { if (imp.isHyperStack()||imp.isComposite()) { boolean compositeMode = imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE; int channel = !compositeMode||imp.getNChannels()==stackSize?imp.getChannel():0; if (imp.getNSlices()>1) roi.setPosition(channel, imp.getSlice(), 0); else if (imp.getNFrames()>1) roi.setPosition(channel, 0, imp.getFrame()); } else roi.setPosition(imp.getCurrentSlice()); } }