Loading IJ_Props.txt +11 −9 Original line number Diff line number Diff line Loading @@ -153,8 +153,8 @@ stacks10="Reslice [/]...",ij.plugin.Slicer stacks11="Orthogonal Views[H]",ij.plugin.Orthogonal_Views stacks12="Z Project...",ij.plugin.ZProjector stacks13="3D Project...",ij.plugin.Projector stacks14="Plot XY Profile",ij.plugin.StackPlotter stacks15="Plot Z-axis Profile",ij.plugin.ZAxisProfiler stacks14="Plot Z-axis Profile",ij.plugin.ZAxisProfiler stacks15="Measure Stack...",ij.plugin.SimpleCommands("measure") stacks16="Label...",ij.plugin.filter.StackLabeler stacks17="Statistics",ij.plugin.Stack_Statistics Loading @@ -166,14 +166,16 @@ animation_03="Animation Options...",ij.plugin.Animator("options") # Plugins installed in the Image/Stacks/Tools submenu tools_01="Combine...",ij.plugin.StackCombiner tools_02="Concatenate...",ij.plugin.Concatenator tools_03="Reduce...",ij.plugin.StackReducer tools_04="Reverse",ij.plugin.StackReverser tools_05="Insert...",ij.plugin.StackInserter tools_06="Montage to Stack...",ij.plugin.StackMaker tools_07="Make Substack...",ij.plugin.SubstackMaker tools_08="Grouped Z Project...",ij.plugin.GroupedZProjector tools_09="Set Label...",ij.plugin.SimpleCommands("set") tools_03="Grouped Z Project...",ij.plugin.GroupedZProjector tools_04="Insert...",ij.plugin.StackInserter tools_05="Magic Montage Tools",ij.plugin.SimpleCommands("magic") tools_06="Make Substack...",ij.plugin.SubstackMaker tools_07="Montage to Stack...",ij.plugin.StackMaker tools_08="Plot XY Profile",ij.plugin.StackPlotter tools_09="Reduce...",ij.plugin.StackReducer tools_10="Remove Slice Labels",ij.plugin.SimpleCommands("remove") tools_11="Reverse",ij.plugin.StackReverser tools_12="Set Label...",ij.plugin.SimpleCommands("set") # Plugins installed in the Image/Hyperstacks submenu hyperstacks01="New Hyperstack...",ij.plugin.HyperStackMaker Loading ij/CompositeImage.java +5 −1 Original line number Diff line number Diff line Loading @@ -315,7 +315,6 @@ public class CompositeImage extends ImagePlus { imageSource.newPixels(); } /** Uses less memory but only works correctly with Java 1.6 and later. */ void createBufferedImage() { if (rgbSampleModel==null) rgbSampleModel = getRGBSampleModel(); Loading Loading @@ -510,6 +509,11 @@ public class CompositeImage extends ImagePlus { setup(nChannels, getImageStack()); } public void completeReset() { cip = null; lut = null; } /* Sets the LUT of the current channel. */ public void setChannelLut(LUT table) { int c = getChannelIndex(); Loading ij/IJ.java +12 −5 Original line number Diff line number Diff line Loading @@ -642,8 +642,8 @@ public class IJ { } /** Displays a message in a dialog box titled "ImageJ". If a macro is running, it is aborted. Writes to the Java console if the ImageJ window is not present.*/ macro or JavaScript is running, it is aborted. Writes to the Java console if the ImageJ window is not present.*/ public static void error(String msg) { error(null, msg); if (Thread.currentThread().getName().endsWith("JavaScript")) Loading @@ -652,9 +652,9 @@ public class IJ { Macro.abort(); } /**Displays a message in a dialog box with the specified title. If a macro is running, it is aborted. Writes to the Java console if ImageJ is not present. */ /** Displays a message in a dialog box with the specified title. If a macro or JavaScript is running, it is aborted. Writes to the Java console if the ImageJ window is not present. */ public static void error(String title, String msg) { if (msg!=null && msg.endsWith(Macro.MACRO_CANCELED)) return; Loading @@ -672,6 +672,13 @@ public class IJ { Macro.abort(); } /** Aborts any currently running JavaScript, or use IJ.error(string) to abort a JavaScript with a message. */ public static void exit() { if (Thread.currentThread().getName().endsWith("JavaScript")) throw new RuntimeException(Macro.MACRO_CANCELED); } /** * Returns the last error message written by IJ.error() or null if there * was no error since the last time this method was called. Loading ij/ImageJ.java +3 −3 Original line number Diff line number Diff line Loading @@ -78,8 +78,8 @@ public class ImageJ extends Frame implements ActionListener, MouseListener, KeyListener, WindowListener, ItemListener, Runnable { /** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */ public static final String VERSION = "1.52g"; public static final String BUILD = ""; //5 public static final String VERSION = "1.52i"; public static final String BUILD = ""; //52 public static Color backgroundColor = new Color(237,237,237); /** SansSerif, 12-point, plain font. */ public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12); Loading Loading @@ -418,7 +418,7 @@ public class ImageJ extends Frame implements ActionListener, ImagePlus imp = WindowManager.getCurrentImage(); boolean isStack = (imp!=null) && (imp.getStackSize()>1); if (imp!=null && ((keyChar>=32 && keyChar<=255) || keyChar=='\b' || keyChar=='\n')) { if (imp!=null && !meta && ((keyChar>=32 && keyChar<=255) || keyChar=='\b' || keyChar=='\n')) { Roi roi = imp.getRoi(); if (roi!=null && roi instanceof TextRoi) { if (imp.getOverlay()!=null && (control || alt || meta) Loading ij/ImagePlus.java +98 −41 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { private boolean noUpdateMode; private ImageCanvas flatteningCanvas; private Overlay overlay; private boolean compositeChanges; private boolean hideOverlay; private static int default16bitDisplayRange; private boolean antialiasRendering = true; Loading Loading @@ -156,7 +157,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { private void setID() { ID = --currentID; //IJ.log("New "+this); } /** Locks the image so other threads can test to see if it Loading Loading @@ -556,28 +556,38 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { if (newProperties!=null) newProperties = (Properties)(newProperties.clone()); if (imp.getWindow()!=null) imp = imp.duplicate(); imp = imp.duplicateAll(); ImageStack stack2 = imp.getStack(); if (imp.isHyperStack()) setOpenAsHyperStack(true); LUT[] luts = null; if (imp.isComposite() && this.isComposite()) { if (imp.isComposite() && (this instanceof CompositeImage)) { if (((CompositeImage)imp).getMode()!=((CompositeImage)this).getMode()) ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); luts = ((CompositeImage)imp).getLuts(); } LUT lut = !imp.isComposite()?imp.getProcessor().getLut():null; setStack(stack2, imp.getNChannels(), imp.getNSlices(), imp.getNFrames()); compositeImage = imp.isComposite(); if (luts!=null) { ((CompositeImage)this).setLuts(luts); updateAndDraw(); ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); updateAndRepaintWindow(); } else if (lut!=null) { getProcessor().setLut(lut); updateAndRepaintWindow(); } setTitle(imp.getTitle()); setCalibration(imp.getCalibration()); setOverlay(imp.getOverlay()); properties = newProperties; if (getProperty(Plot.PROPERTY_KEY)!=null && win instanceof PlotWindow) { Plot plot = (Plot)(getProperty(Plot.PROPERTY_KEY)); ((PlotWindow)win).setPlot(plot); plot.setImagePlus(this); } setFileInfo(imp.getOriginalFileInfo()); setProperty ("Info", imp.getProperty ("Info")); } /** Replaces the ImageProcessor with the one specified and updates the Loading Loading @@ -659,9 +669,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { /** Replaces the image with the specified stack and updates the display. Set 'title' to null to leave the title unchanged. */ public void setStack(String title, ImageStack newStack) { //IJ.log("setStack1: "+nChannels+" "+nSlices+" "+nFrames); int bitDepth1 = getBitDepth(); int previousStackSize = getStackSize(); int newStackSize = newStack.getSize(); //IJ.log("setStack: "+newStackSize+" "+this); if (newStackSize==0) throw new IllegalArgumentException("Stack is empty"); if (!newStack.isVirtual()) { Loading @@ -687,16 +698,25 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { this.stack = newStack; oneSliceStack = false; setProcessor2(title, ip, newStack); if (bitDepth1!=0 && bitDepth1!=getBitDepth()) compositeChanges = true; if (compositeChanges && (this instanceof CompositeImage)) { this.compositeImage = getStackSize()!=getNSlices(); ((CompositeImage)this).completeReset(); if (bitDepth1!=0 && bitDepth1!=getBitDepth()) ((CompositeImage)this).resetDisplayRanges(); } compositeChanges = false; if (win==null) { if (resetCurrentSlice) setSlice(currentSlice); return; } boolean invalidDimensions = (isDisplayedHyperStack()||isComposite()) && (win instanceof StackWindow) && !((StackWindow)win).validDimensions(); boolean invalidDimensions = (isDisplayedHyperStack()||(this instanceof CompositeImage)) && (win instanceof StackWindow) && !((StackWindow)win).validDimensions(); if (newStackSize>1 && !(win instanceof StackWindow)) { if (isDisplayedHyperStack()) setOpenAsHyperStack(true); activated = false; win = new StackWindow(this, getCanvas()); // replaces this window win = new StackWindow(this, dimensionsChanged?null:getCanvas()); // replaces this window if (IJ.isMacro()) { // wait for stack window to be activated long start = System.currentTimeMillis(); while (!activated) { Loading Loading @@ -724,24 +744,16 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { } if (resetCurrentSlice) setSlice(currentSlice); if (isComposite() && previousStackSize!=newStackSize) compositeImage = false; } public void setStack(ImageStack newStack, int channels, int slices, int frames) { if (newStack==null || channels*slices*frames!=newStack.getSize()) throw new IllegalArgumentException("channels*slices*frames!=stackSize"); int channelsBefore = this.nChannels; if (IJ.debugMode) IJ.log("setStack: "+newStack.getSize()+" "+channels+" ("+channelsBefore+") "+slices+" "+frames+" "+isComposite()); if (IJ.debugMode) IJ.log("setStack: "+newStack.getSize()+" "+channels+" "+slices+" "+frames+" "+isComposite()); compositeChanges = channels!=this.nChannels; this.nChannels = channels; this.nSlices = slices; this.nFrames = frames; if (channelsBefore!=channels && isComposite()) { ImageStack stack2 = this.stack; this.stack = newStack; ((CompositeImage)this).reset(); this.stack = stack2; } setStack(null, newStack); } Loading Loading @@ -863,7 +875,9 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { } /** Returns an 8-bit binary (0 and 255) ROI or overlay mask * that has the same dimensions as this image. * that has the same dimensions as this image. Creates an * ROI mask If the image has both an ROI and an overlay. * @see #createThresholdMask * @see ij.gui.Roi#getMask */ public ByteProcessor createRoiMask() { Loading @@ -873,11 +887,23 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { throw new IllegalArgumentException("ROI or overlay required"); ByteProcessor mask = new ByteProcessor(getWidth(),getHeight()); mask.setColor(255); if (overlay2!=null) { if (roi2!=null) mask.fill(roi2); else if (overlay2!=null) { if (overlay2.size()==1 && (overlay2.get(0) instanceof ImageRoi)) { ImageRoi iRoi = (ImageRoi)overlay2.get(0); ImageProcessor ip = iRoi.getProcessor(); if (ip.getWidth()!=mask.getWidth() || ip.getHeight()!=mask.getHeight()) return mask; for (int i=0; i<ip.getPixelCount(); i++) { if (ip.get(i)!=0) mask.set(i, 255); } } else { for (int i=0; i<overlay2.size(); i++) mask.fill(overlay2.get(i)); } else if (roi2!=null) mask.fill(roi2); } } return mask; } Loading Loading @@ -1012,14 +1038,28 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { notifyListeners(UPDATED); } /** Returns the width of this image in pixels. */ public int getWidth() { return width; } /** Returns the height of this image in pixels. */ public int getHeight() { return height; } /** Returns the size of this image in bytes. */ public double getSizeInBytes() { double size = ((double)getWidth()*getHeight()*getStackSize()); int type = getType(); switch (type) { case ImagePlus.GRAY16: size *= 2.0; break; case ImagePlus.GRAY32: size *= 4.0; break; case ImagePlus.COLOR_RGB: size *= 4.0; break; } return size; } /** If this is a stack, returns the number of slices, else returns 1. */ public int getStackSize() { if (stack==null || oneSliceStack) Loading Loading @@ -1074,7 +1114,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { new StackWindow(this); } dimensionsSet = true; //IJ.log("setDimensions: "+ nChannels+" "+nSlices+" "+nFrames); } /** Returns 'true' if this image is a hyperstack. */ Loading Loading @@ -1105,7 +1144,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { /** Returns the image depth (number of z-slices). */ public int getNSlices() { //IJ.log("getNSlices: "+ nChannels+" "+nSlices+" "+nFrames); verifyDimensions(); return nSlices; } Loading Loading @@ -1268,6 +1306,8 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { index1 = findKey(info, key+": "); // standard 'key: value' pair? if (index1<0) // Bio-Formats metadata? index1 = findKey(info, key+" = "); if (index1<0) // '=' with no spaces index1 = findKey(info, key+"="); if (index1<0) // otherwise not found return null; if (index1==info.length()) Loading Loading @@ -1519,7 +1559,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { boolean channelChanged = channel!=getChannel(); setSlice((frame-1)*nChannels*nSlices + (slice-1)*nChannels + channel); updatePosition(channel, slice, frame); if (channelChanged && isComposite()) if (channelChanged && isComposite() && !noUpdateMode) updateImage(); } } Loading Loading @@ -1724,8 +1764,14 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { ip.resetRoi(); } roi.setImage(this); if ((roi instanceof PointRoi) && ((PointRoi)roi).addToOverlay()) { IJ.run(this, "Add Selection...", ""); roi = null; return; } if (updateDisplay) draw(); if (roi!=null) roi.notifyListeners(RoiListener.CREATED); } Loading @@ -1743,6 +1789,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { starting screen coordinates. The selection type is determined by which tool in the tool bar is active. The user interactively sets the selection size and shape. */ public void createNewRoi(int sx, int sy) { Roi previousRoi = roi; deleteRoi(); switch (Toolbar.getToolId()) { case Toolbar.RECTANGLE: Loading Loading @@ -1774,6 +1821,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { break; case Toolbar.TEXT: roi = new TextRoi(sx, sy, this); ((TextRoi)roi).setPreviousRoi(previousRoi); break; case Toolbar.POINT: roi = new PointRoi(sx, sy, this); Loading Loading @@ -1924,7 +1972,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { url2 = fi.url; } else return; //IJ.log("revert: "+path+" "+fi); IJ.showStatus("Loading: " + path); ImagePlus imp = IJ.openImage(path); if (imp!=null) { Loading Loading @@ -2096,6 +2143,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { /** Returns a copy of this image or stack, cropped if there is an ROI. * @see #duplicateAll * @see #crop * @see ij.plugin.Duplicator#run */ Loading @@ -2103,8 +2151,21 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { return (new Duplicator()).run(this); } /** Returns a copy of this image or stack. * @see #duplicate * @see #crop */ public ImagePlus duplicateAll() { Roi roi = getRoi(); deleteRoi(); ImagePlus imp2 =(new Duplicator()).run(this); setRoi(roi); return imp2; } /** Returns a copy this image or stack slice, cropped if there is an ROI. * @see #duplicate * @see #duplicateAll * @see ij.plugin.Duplicator#crop */ public ImagePlus crop() { Loading Loading @@ -2381,8 +2442,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { case ImagePlus.GRAY16: bytesPerPixel = 2; break; case ImagePlus.GRAY32: case ImagePlus.COLOR_RGB: bytesPerPixel = 4; } //Roi roi3 = clipboard.getRoi(); //IJ.log("copy: "+clipboard +" "+ "roi3="+(roi3!=null?""+roi3:"")); if (!batchMode) { msg = (cut)?"Cut":"Copy"; IJ.showStatus(msg + ": " + (clipboard.getWidth()*clipboard.getHeight()*bytesPerPixel)/1024 + "k"); Loading Loading @@ -2411,13 +2470,11 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { if (cr==null) cr = new Rectangle(0, 0, w, h); if (r==null || (cr.width!=r.width || cr.height!=r.height)) { // create a new roi centered on visible part of image ImageCanvas ic = null; if (win!=null) ic = win.getCanvas(); // Create a new roi centered on visible part of image, or centered on image if clipboard is >= image ImageCanvas ic = win!=null?ic = win.getCanvas():null; Rectangle srcRect = ic!=null?ic.getSrcRect():new Rectangle(0,0,width,height); int xCenter = srcRect.x + srcRect.width/2; int yCenter = srcRect.y + srcRect.height/2; int xCenter = w>=width ? width/2 : srcRect.x + srcRect.width/2; int yCenter = h>=height ? height/2 : srcRect.y + srcRect.height/2; if (cRoi!=null && cRoi.getType()!=Roi.RECTANGLE) { cRoi.setImage(this); cRoi.setLocation(xCenter-w/2, yCenter-h/2); Loading Loading
IJ_Props.txt +11 −9 Original line number Diff line number Diff line Loading @@ -153,8 +153,8 @@ stacks10="Reslice [/]...",ij.plugin.Slicer stacks11="Orthogonal Views[H]",ij.plugin.Orthogonal_Views stacks12="Z Project...",ij.plugin.ZProjector stacks13="3D Project...",ij.plugin.Projector stacks14="Plot XY Profile",ij.plugin.StackPlotter stacks15="Plot Z-axis Profile",ij.plugin.ZAxisProfiler stacks14="Plot Z-axis Profile",ij.plugin.ZAxisProfiler stacks15="Measure Stack...",ij.plugin.SimpleCommands("measure") stacks16="Label...",ij.plugin.filter.StackLabeler stacks17="Statistics",ij.plugin.Stack_Statistics Loading @@ -166,14 +166,16 @@ animation_03="Animation Options...",ij.plugin.Animator("options") # Plugins installed in the Image/Stacks/Tools submenu tools_01="Combine...",ij.plugin.StackCombiner tools_02="Concatenate...",ij.plugin.Concatenator tools_03="Reduce...",ij.plugin.StackReducer tools_04="Reverse",ij.plugin.StackReverser tools_05="Insert...",ij.plugin.StackInserter tools_06="Montage to Stack...",ij.plugin.StackMaker tools_07="Make Substack...",ij.plugin.SubstackMaker tools_08="Grouped Z Project...",ij.plugin.GroupedZProjector tools_09="Set Label...",ij.plugin.SimpleCommands("set") tools_03="Grouped Z Project...",ij.plugin.GroupedZProjector tools_04="Insert...",ij.plugin.StackInserter tools_05="Magic Montage Tools",ij.plugin.SimpleCommands("magic") tools_06="Make Substack...",ij.plugin.SubstackMaker tools_07="Montage to Stack...",ij.plugin.StackMaker tools_08="Plot XY Profile",ij.plugin.StackPlotter tools_09="Reduce...",ij.plugin.StackReducer tools_10="Remove Slice Labels",ij.plugin.SimpleCommands("remove") tools_11="Reverse",ij.plugin.StackReverser tools_12="Set Label...",ij.plugin.SimpleCommands("set") # Plugins installed in the Image/Hyperstacks submenu hyperstacks01="New Hyperstack...",ij.plugin.HyperStackMaker Loading
ij/CompositeImage.java +5 −1 Original line number Diff line number Diff line Loading @@ -315,7 +315,6 @@ public class CompositeImage extends ImagePlus { imageSource.newPixels(); } /** Uses less memory but only works correctly with Java 1.6 and later. */ void createBufferedImage() { if (rgbSampleModel==null) rgbSampleModel = getRGBSampleModel(); Loading Loading @@ -510,6 +509,11 @@ public class CompositeImage extends ImagePlus { setup(nChannels, getImageStack()); } public void completeReset() { cip = null; lut = null; } /* Sets the LUT of the current channel. */ public void setChannelLut(LUT table) { int c = getChannelIndex(); Loading
ij/IJ.java +12 −5 Original line number Diff line number Diff line Loading @@ -642,8 +642,8 @@ public class IJ { } /** Displays a message in a dialog box titled "ImageJ". If a macro is running, it is aborted. Writes to the Java console if the ImageJ window is not present.*/ macro or JavaScript is running, it is aborted. Writes to the Java console if the ImageJ window is not present.*/ public static void error(String msg) { error(null, msg); if (Thread.currentThread().getName().endsWith("JavaScript")) Loading @@ -652,9 +652,9 @@ public class IJ { Macro.abort(); } /**Displays a message in a dialog box with the specified title. If a macro is running, it is aborted. Writes to the Java console if ImageJ is not present. */ /** Displays a message in a dialog box with the specified title. If a macro or JavaScript is running, it is aborted. Writes to the Java console if the ImageJ window is not present. */ public static void error(String title, String msg) { if (msg!=null && msg.endsWith(Macro.MACRO_CANCELED)) return; Loading @@ -672,6 +672,13 @@ public class IJ { Macro.abort(); } /** Aborts any currently running JavaScript, or use IJ.error(string) to abort a JavaScript with a message. */ public static void exit() { if (Thread.currentThread().getName().endsWith("JavaScript")) throw new RuntimeException(Macro.MACRO_CANCELED); } /** * Returns the last error message written by IJ.error() or null if there * was no error since the last time this method was called. Loading
ij/ImageJ.java +3 −3 Original line number Diff line number Diff line Loading @@ -78,8 +78,8 @@ public class ImageJ extends Frame implements ActionListener, MouseListener, KeyListener, WindowListener, ItemListener, Runnable { /** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */ public static final String VERSION = "1.52g"; public static final String BUILD = ""; //5 public static final String VERSION = "1.52i"; public static final String BUILD = ""; //52 public static Color backgroundColor = new Color(237,237,237); /** SansSerif, 12-point, plain font. */ public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12); Loading Loading @@ -418,7 +418,7 @@ public class ImageJ extends Frame implements ActionListener, ImagePlus imp = WindowManager.getCurrentImage(); boolean isStack = (imp!=null) && (imp.getStackSize()>1); if (imp!=null && ((keyChar>=32 && keyChar<=255) || keyChar=='\b' || keyChar=='\n')) { if (imp!=null && !meta && ((keyChar>=32 && keyChar<=255) || keyChar=='\b' || keyChar=='\n')) { Roi roi = imp.getRoi(); if (roi!=null && roi instanceof TextRoi) { if (imp.getOverlay()!=null && (control || alt || meta) Loading
ij/ImagePlus.java +98 −41 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { private boolean noUpdateMode; private ImageCanvas flatteningCanvas; private Overlay overlay; private boolean compositeChanges; private boolean hideOverlay; private static int default16bitDisplayRange; private boolean antialiasRendering = true; Loading Loading @@ -156,7 +157,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { private void setID() { ID = --currentID; //IJ.log("New "+this); } /** Locks the image so other threads can test to see if it Loading Loading @@ -556,28 +556,38 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { if (newProperties!=null) newProperties = (Properties)(newProperties.clone()); if (imp.getWindow()!=null) imp = imp.duplicate(); imp = imp.duplicateAll(); ImageStack stack2 = imp.getStack(); if (imp.isHyperStack()) setOpenAsHyperStack(true); LUT[] luts = null; if (imp.isComposite() && this.isComposite()) { if (imp.isComposite() && (this instanceof CompositeImage)) { if (((CompositeImage)imp).getMode()!=((CompositeImage)this).getMode()) ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); luts = ((CompositeImage)imp).getLuts(); } LUT lut = !imp.isComposite()?imp.getProcessor().getLut():null; setStack(stack2, imp.getNChannels(), imp.getNSlices(), imp.getNFrames()); compositeImage = imp.isComposite(); if (luts!=null) { ((CompositeImage)this).setLuts(luts); updateAndDraw(); ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); updateAndRepaintWindow(); } else if (lut!=null) { getProcessor().setLut(lut); updateAndRepaintWindow(); } setTitle(imp.getTitle()); setCalibration(imp.getCalibration()); setOverlay(imp.getOverlay()); properties = newProperties; if (getProperty(Plot.PROPERTY_KEY)!=null && win instanceof PlotWindow) { Plot plot = (Plot)(getProperty(Plot.PROPERTY_KEY)); ((PlotWindow)win).setPlot(plot); plot.setImagePlus(this); } setFileInfo(imp.getOriginalFileInfo()); setProperty ("Info", imp.getProperty ("Info")); } /** Replaces the ImageProcessor with the one specified and updates the Loading Loading @@ -659,9 +669,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { /** Replaces the image with the specified stack and updates the display. Set 'title' to null to leave the title unchanged. */ public void setStack(String title, ImageStack newStack) { //IJ.log("setStack1: "+nChannels+" "+nSlices+" "+nFrames); int bitDepth1 = getBitDepth(); int previousStackSize = getStackSize(); int newStackSize = newStack.getSize(); //IJ.log("setStack: "+newStackSize+" "+this); if (newStackSize==0) throw new IllegalArgumentException("Stack is empty"); if (!newStack.isVirtual()) { Loading @@ -687,16 +698,25 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { this.stack = newStack; oneSliceStack = false; setProcessor2(title, ip, newStack); if (bitDepth1!=0 && bitDepth1!=getBitDepth()) compositeChanges = true; if (compositeChanges && (this instanceof CompositeImage)) { this.compositeImage = getStackSize()!=getNSlices(); ((CompositeImage)this).completeReset(); if (bitDepth1!=0 && bitDepth1!=getBitDepth()) ((CompositeImage)this).resetDisplayRanges(); } compositeChanges = false; if (win==null) { if (resetCurrentSlice) setSlice(currentSlice); return; } boolean invalidDimensions = (isDisplayedHyperStack()||isComposite()) && (win instanceof StackWindow) && !((StackWindow)win).validDimensions(); boolean invalidDimensions = (isDisplayedHyperStack()||(this instanceof CompositeImage)) && (win instanceof StackWindow) && !((StackWindow)win).validDimensions(); if (newStackSize>1 && !(win instanceof StackWindow)) { if (isDisplayedHyperStack()) setOpenAsHyperStack(true); activated = false; win = new StackWindow(this, getCanvas()); // replaces this window win = new StackWindow(this, dimensionsChanged?null:getCanvas()); // replaces this window if (IJ.isMacro()) { // wait for stack window to be activated long start = System.currentTimeMillis(); while (!activated) { Loading Loading @@ -724,24 +744,16 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { } if (resetCurrentSlice) setSlice(currentSlice); if (isComposite() && previousStackSize!=newStackSize) compositeImage = false; } public void setStack(ImageStack newStack, int channels, int slices, int frames) { if (newStack==null || channels*slices*frames!=newStack.getSize()) throw new IllegalArgumentException("channels*slices*frames!=stackSize"); int channelsBefore = this.nChannels; if (IJ.debugMode) IJ.log("setStack: "+newStack.getSize()+" "+channels+" ("+channelsBefore+") "+slices+" "+frames+" "+isComposite()); if (IJ.debugMode) IJ.log("setStack: "+newStack.getSize()+" "+channels+" "+slices+" "+frames+" "+isComposite()); compositeChanges = channels!=this.nChannels; this.nChannels = channels; this.nSlices = slices; this.nFrames = frames; if (channelsBefore!=channels && isComposite()) { ImageStack stack2 = this.stack; this.stack = newStack; ((CompositeImage)this).reset(); this.stack = stack2; } setStack(null, newStack); } Loading Loading @@ -863,7 +875,9 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { } /** Returns an 8-bit binary (0 and 255) ROI or overlay mask * that has the same dimensions as this image. * that has the same dimensions as this image. Creates an * ROI mask If the image has both an ROI and an overlay. * @see #createThresholdMask * @see ij.gui.Roi#getMask */ public ByteProcessor createRoiMask() { Loading @@ -873,11 +887,23 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { throw new IllegalArgumentException("ROI or overlay required"); ByteProcessor mask = new ByteProcessor(getWidth(),getHeight()); mask.setColor(255); if (overlay2!=null) { if (roi2!=null) mask.fill(roi2); else if (overlay2!=null) { if (overlay2.size()==1 && (overlay2.get(0) instanceof ImageRoi)) { ImageRoi iRoi = (ImageRoi)overlay2.get(0); ImageProcessor ip = iRoi.getProcessor(); if (ip.getWidth()!=mask.getWidth() || ip.getHeight()!=mask.getHeight()) return mask; for (int i=0; i<ip.getPixelCount(); i++) { if (ip.get(i)!=0) mask.set(i, 255); } } else { for (int i=0; i<overlay2.size(); i++) mask.fill(overlay2.get(i)); } else if (roi2!=null) mask.fill(roi2); } } return mask; } Loading Loading @@ -1012,14 +1038,28 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { notifyListeners(UPDATED); } /** Returns the width of this image in pixels. */ public int getWidth() { return width; } /** Returns the height of this image in pixels. */ public int getHeight() { return height; } /** Returns the size of this image in bytes. */ public double getSizeInBytes() { double size = ((double)getWidth()*getHeight()*getStackSize()); int type = getType(); switch (type) { case ImagePlus.GRAY16: size *= 2.0; break; case ImagePlus.GRAY32: size *= 4.0; break; case ImagePlus.COLOR_RGB: size *= 4.0; break; } return size; } /** If this is a stack, returns the number of slices, else returns 1. */ public int getStackSize() { if (stack==null || oneSliceStack) Loading Loading @@ -1074,7 +1114,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { new StackWindow(this); } dimensionsSet = true; //IJ.log("setDimensions: "+ nChannels+" "+nSlices+" "+nFrames); } /** Returns 'true' if this image is a hyperstack. */ Loading Loading @@ -1105,7 +1144,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { /** Returns the image depth (number of z-slices). */ public int getNSlices() { //IJ.log("getNSlices: "+ nChannels+" "+nSlices+" "+nFrames); verifyDimensions(); return nSlices; } Loading Loading @@ -1268,6 +1306,8 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { index1 = findKey(info, key+": "); // standard 'key: value' pair? if (index1<0) // Bio-Formats metadata? index1 = findKey(info, key+" = "); if (index1<0) // '=' with no spaces index1 = findKey(info, key+"="); if (index1<0) // otherwise not found return null; if (index1==info.length()) Loading Loading @@ -1519,7 +1559,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { boolean channelChanged = channel!=getChannel(); setSlice((frame-1)*nChannels*nSlices + (slice-1)*nChannels + channel); updatePosition(channel, slice, frame); if (channelChanged && isComposite()) if (channelChanged && isComposite() && !noUpdateMode) updateImage(); } } Loading Loading @@ -1724,8 +1764,14 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { ip.resetRoi(); } roi.setImage(this); if ((roi instanceof PointRoi) && ((PointRoi)roi).addToOverlay()) { IJ.run(this, "Add Selection...", ""); roi = null; return; } if (updateDisplay) draw(); if (roi!=null) roi.notifyListeners(RoiListener.CREATED); } Loading @@ -1743,6 +1789,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { starting screen coordinates. The selection type is determined by which tool in the tool bar is active. The user interactively sets the selection size and shape. */ public void createNewRoi(int sx, int sy) { Roi previousRoi = roi; deleteRoi(); switch (Toolbar.getToolId()) { case Toolbar.RECTANGLE: Loading Loading @@ -1774,6 +1821,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { break; case Toolbar.TEXT: roi = new TextRoi(sx, sy, this); ((TextRoi)roi).setPreviousRoi(previousRoi); break; case Toolbar.POINT: roi = new PointRoi(sx, sy, this); Loading Loading @@ -1924,7 +1972,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { url2 = fi.url; } else return; //IJ.log("revert: "+path+" "+fi); IJ.showStatus("Loading: " + path); ImagePlus imp = IJ.openImage(path); if (imp!=null) { Loading Loading @@ -2096,6 +2143,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { /** Returns a copy of this image or stack, cropped if there is an ROI. * @see #duplicateAll * @see #crop * @see ij.plugin.Duplicator#run */ Loading @@ -2103,8 +2151,21 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { return (new Duplicator()).run(this); } /** Returns a copy of this image or stack. * @see #duplicate * @see #crop */ public ImagePlus duplicateAll() { Roi roi = getRoi(); deleteRoi(); ImagePlus imp2 =(new Duplicator()).run(this); setRoi(roi); return imp2; } /** Returns a copy this image or stack slice, cropped if there is an ROI. * @see #duplicate * @see #duplicateAll * @see ij.plugin.Duplicator#crop */ public ImagePlus crop() { Loading Loading @@ -2381,8 +2442,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { case ImagePlus.GRAY16: bytesPerPixel = 2; break; case ImagePlus.GRAY32: case ImagePlus.COLOR_RGB: bytesPerPixel = 4; } //Roi roi3 = clipboard.getRoi(); //IJ.log("copy: "+clipboard +" "+ "roi3="+(roi3!=null?""+roi3:"")); if (!batchMode) { msg = (cut)?"Cut":"Copy"; IJ.showStatus(msg + ": " + (clipboard.getWidth()*clipboard.getHeight()*bytesPerPixel)/1024 + "k"); Loading Loading @@ -2411,13 +2470,11 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable { if (cr==null) cr = new Rectangle(0, 0, w, h); if (r==null || (cr.width!=r.width || cr.height!=r.height)) { // create a new roi centered on visible part of image ImageCanvas ic = null; if (win!=null) ic = win.getCanvas(); // Create a new roi centered on visible part of image, or centered on image if clipboard is >= image ImageCanvas ic = win!=null?ic = win.getCanvas():null; Rectangle srcRect = ic!=null?ic.getSrcRect():new Rectangle(0,0,width,height); int xCenter = srcRect.x + srcRect.width/2; int yCenter = srcRect.y + srcRect.height/2; int xCenter = w>=width ? width/2 : srcRect.x + srcRect.width/2; int yCenter = h>=height ? height/2 : srcRect.y + srcRect.height/2; if (cRoi!=null && cRoi.getType()!=Roi.RECTANGLE) { cRoi.setImage(this); cRoi.setLocation(xCenter-w/2, yCenter-h/2); Loading