[med-svn] [Git][med-team/imagej][upstream] New upstream version 1.53k

Nilesh Patra (@nilesh) gitlab at salsa.debian.org
Fri Jul 9 21:39:22 BST 2021



Nilesh Patra pushed to branch upstream at Debian Med / imagej


Commits:
e0f2422c by Nilesh Patra at 2021-07-10T01:55:46+05:30
New upstream version 1.53k
- - - - -


27 changed files:

- build.xml
- ij/IJ.java
- ij/ImageJ.java
- ij/ImagePlus.java
- ij/Prefs.java
- ij/VirtualStack.java
- ij/WindowManager.java
- ij/gui/GenericDialog.java
- ij/gui/StackWindow.java
- ij/gui/Toolbar.java
- ij/io/ImageReader.java
- ij/macro/Functions.java
- ij/measure/ResultsTable.java
- ij/plugin/Animator.java
- ij/plugin/Benchmark.java
- ij/plugin/Options.java
- ij/plugin/Orthogonal_Views.java
- ij/plugin/Thresholder.java
- ij/plugin/filter/Filters.java
- ij/plugin/filter/ParticleAnalyzer.java
- ij/plugin/filter/PlugInFilterRunner.java
- ij/plugin/frame/Recorder.java
- ij/process/ImageProcessor.java
- ij/process/ShortProcessor.java
- + plugins/MacAdapter9.class
- + plugins/MacAdapter9.source
- release-notes.html


Changes:

=====================================
build.xml
=====================================
@@ -16,7 +16,8 @@
     <copy file="IJ_Props.txt" todir="build" />
     <copy file="images/microscope.gif" tofile="build/microscope.gif" />
     <copy file="images/about.jpg" tofile="build/about.jpg" />
-	<copy file="plugins/MacAdapter.class" tofile="build/ij/plugin/MacAdapter.class" /> 
+	<copy file="plugins/MacAdapter.class" tofile="build/ij/plugin/MacAdapter.class" />
+	<copy file="plugins/MacAdapter9.class" tofile="build/ij/plugin/MacAdapter9.class" /> 
     <copy todir="build/macros"><fileset dir="macros"/></copy>
     <!-- Build ij.jar. -->
     <jar jarfile="ij.jar" basedir="build"


=====================================
ij/IJ.java
=====================================
@@ -211,10 +211,12 @@ public class IJ {
  			else
 				new PlugInFilterRunner(thePlugIn, commandName, arg);
 		} catch (ClassNotFoundException e) {
-			log("Plugin or class not found: \"" + className + "\"\n(" + e+")");
-			String path = Prefs.getCustomPropsPath();
-			if (path!=null);
-				log("Error may be due to custom properties at " + path);
+			if (!(className!=null && className.startsWith("ij.plugin.MacAdapter"))) {
+				log("Plugin or class not found: \"" + className + "\"\n(" + e+")");
+				String path = Prefs.getCustomPropsPath();
+				if (path!=null);
+					log("Error may be due to custom properties at " + path);
+			}
 		}
 		catch (InstantiationException e) {log("Unable to load plugin (ins)");}
 		catch (IllegalAccessException e) {log("Unable to load plugin, possibly \nbecause it is not public.");}


=====================================
ij/ImageJ.java
=====================================
@@ -77,8 +77,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.53j";
-	public static final String BUILD = "";  //46
+	public static final String VERSION = "1.53k";
+	public static final String BUILD = "";  //19
 	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);
@@ -216,7 +216,10 @@ public class ImageJ extends Frame implements ActionListener,
 		}
 		if (IJ.isMacintosh()&&applet==null) {
 			try {
-				IJ.runPlugIn("ij.plugin.MacAdapter", ""); 
+				if (IJ.javaVersion()>8) // newer JREs use different drag-drop, about mechanism
+					IJ.runPlugIn("ij.plugin.MacAdapter9", "");
+				else
+					IJ.runPlugIn("ij.plugin.MacAdapter", "");
 			} catch(Throwable e) {}
 		} 
 		if (applet==null)


=====================================
ij/ImagePlus.java
=====================================
@@ -2074,7 +2074,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
 					}
 				}
 				if (Prefs.pointAutoNextSlice && getStackSize()>1) {
+					boolean order = Prefs.reverseNextPreviousOrder;
+					Prefs.reverseNextPreviousOrder = true;
 					IJ.run(this, "Next Slice [>]", "");
+					Prefs.reverseNextPreviousOrder = order;
 					deleteRoi();
 				}
 				break;
@@ -2838,7 +2841,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
 			cr = cRoi.getBounds();
 		if (cr==null)
 			cr = new Rectangle(0, 0, w, h);
-		if (r==null || Math.abs(cr.width-r.width)>10 || Math.abs(cr.height-r.height)>10) {
+		if (r==null || (cr.width!=r.width || cr.height!=r.height)) {
 			// 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);


=====================================
ij/Prefs.java
=====================================
@@ -58,7 +58,7 @@ public class Prefs {
 		REVERSE_NEXT_PREVIOUS_ORDER=1<<5, AUTO_RUN_EXAMPLES=1<<6, SHOW_ALL_POINTS=1<<7,
 		DO_NOT_SAVE_WINDOW_LOCS=1<<8, JFILE_CHOOSER_CHANGED=1<<9,
 		CANCEL_BUTTON_ON_RIGHT=1<<10, IGNORE_RESCALE_SLOPE=1<<11,
-		NON_BLOCKING_DIALOGS=1<<12;
+		NON_BLOCKING_DIALOGS=1<<12, MODERN_MODE=1<<13;
 	public static final String OPTIONS2 = "prefs.options2";
     
 	/** file.separator system property */
@@ -100,7 +100,7 @@ public class Prefs {
 	/** Do not draw black border around image. */
 	public static boolean noBorder;
 	/** Only show ROIs associated with current slice in Roi Manager "Show All" mode. */
-	public static boolean showAllSliceOnly;
+	public static boolean showAllSliceOnly = true;
 	/** Include column headers when copying tables to clipboard. */
 	public static boolean copyColumnHeaders;
 	/** Do not include row numbers when copying tables to clipboard. */
@@ -186,6 +186,8 @@ public class Prefs {
 	public static boolean supportMacroUndo;
 	/** Use NonBlockingGenericDialogs in filters */	
 	public static boolean nonBlockingFilterDialogs;
+	/** Currently not used */	
+	public static boolean modernMode;
 	//Save location of moved image windows */	
 	//public static boolean saveImageLocation = true;
 
@@ -551,6 +553,7 @@ public class Prefs {
 		dialogCancelButtonOnRight = (options2&CANCEL_BUTTON_ON_RIGHT)!=0;
 		ignoreRescaleSlope = (options2&IGNORE_RESCALE_SLOPE)!=0;
 		nonBlockingFilterDialogs = (options2&NON_BLOCKING_DIALOGS)!=0;
+		modernMode = (options2&MODERN_MODE)!=0;
 	}
 
 	static void saveOptions(Properties prefs) {
@@ -581,7 +584,8 @@ public class Prefs {
 			+ (jFileChooserSettingChanged?JFILE_CHOOSER_CHANGED:0)
 			+ (dialogCancelButtonOnRight?CANCEL_BUTTON_ON_RIGHT:0)
 			+ (ignoreRescaleSlope?IGNORE_RESCALE_SLOPE:0)
-			+ (nonBlockingFilterDialogs?NON_BLOCKING_DIALOGS:0);
+			+ (nonBlockingFilterDialogs?NON_BLOCKING_DIALOGS:0)
+			+ (modernMode?MODERN_MODE:0);
 		prefs.put(OPTIONS2, Integer.toString(options2));
 	}
 


=====================================
ij/VirtualStack.java
=====================================
@@ -17,6 +17,7 @@ public class VirtualStack extends ImageStack {
 	private String[] names;
 	private String[] labels;
 	private int bitDepth;
+	private int delay;
 	private Properties  properties;
 	private boolean generateData;
 	private int[] indexes;  // used to translate non-CZT hyperstack slice numbers
@@ -62,6 +63,7 @@ public class VirtualStack extends ImageStack {
   		if (options.contains("16-bit")) depth=16;
  	    if (options.contains("RGB")) depth=24;
         if (options.contains("32-bit")) depth=32;
+        if (options.contains("delay")) delay=250;
         this.generateData = options.contains("fill");
 		this.bitDepth = depth;
 	}
@@ -149,6 +151,7 @@ public class VirtualStack extends ImageStack {
 				case 24: ip = new ColorProcessor(w,h); break;
 				case 32: ip = new FloatProcessor(w,h); break;
 			}
+			String hlabel = null;
 			if (generateData) {
 				int value = 0;
 				ImagePlus img = WindowManager.getCurrentImage();
@@ -160,8 +163,14 @@ public class VirtualStack extends ImageStack {
 					for (int i=0; i<ip.getPixelCount(); i++)
 						ip.set(i,value++);
 				}
+				if (img!=null && img.isHyperStack()) {
+					int[] pos = img.convertIndexToPosition(n);
+					hlabel = pos[0]+" "+pos[1]+" "+pos[2]+" "+n;
+				}
 			}
-			label(ip, ""+n, Color.white);
+			label(ip, hlabel!=null?hlabel:""+n, Color.white);
+			if (delay>0)
+				IJ.wait(delay);
 			return ip;
 		}
 		n = translate(n);  // update n for hyperstacks not in the default CZT order


=====================================
ij/WindowManager.java
=====================================
@@ -394,7 +394,9 @@ public class WindowManager {
 		if (index==-1)
 			return;  // not on the window list
 		try {
-			imageList.remove(win);
+			synchronized(WindowManager.class) {
+				imageList.remove(win);
+			}
 			activations.remove(win);
 			if (imageList.size()>1 && !Prefs.closingAll) {
 				ImageWindow win2 = activations.size()>0?(ImageWindow)activations.get(activations.size()-1):null;


=====================================
ij/gui/GenericDialog.java
=====================================
@@ -372,6 +372,26 @@ FocusListener, ItemListener, KeyListener, AdjustmentListener, WindowListener {
 			saveLabel(panel, label);
 	}
 
+	/**
+	 * Add button to the dialog
+	 * @param label button label
+	 * @param listener listener to handle the action when pressing the button
+	*/
+	public void addButton(String label, ActionListener listener) {
+		if (GraphicsEnvironment.isHeadless())
+			return;
+		Button button = new Button(label);
+		button.addActionListener(listener);
+		button.addKeyListener(this);		
+		GridBagLayout layout = (GridBagLayout)getLayout();
+		Panel panel = new Panel();
+		addPanel(panel);
+		GridBagConstraints constraints = layout.getConstraints(panel);
+		remove(panel);
+		layout.setConstraints(button, constraints);
+		add(button);
+	}
+
 	/** Adds a popup menu that lists the currently open images.
 	 * Call getNextImage() to retrieve the selected
 	 * image. Based on the addImageChoice()
@@ -735,11 +755,11 @@ FocusListener, ItemListener, KeyListener, AdjustmentListener, WindowListener {
 		if (textArea1!=null) return;
 		Panel panel = new Panel();
 		int scrollbars = TextArea.SCROLLBARS_NONE;
-		if (text1.endsWith("SCROLLBARS_BOTH")) {
+		if (text1!=null && text1.endsWith("SCROLLBARS_BOTH")) {
 			scrollbars = TextArea.SCROLLBARS_BOTH;
 			text1 = text1.substring(0, text1.length()-15);
 		}
-		if (text1.endsWith("SCROLLBARS_VERTICAL_ONLY")) {
+		if (text1!=null && text1.endsWith("SCROLLBARS_VERTICAL_ONLY")) {
 			scrollbars = TextArea.SCROLLBARS_VERTICAL_ONLY;
 			text1 = text1.substring(0, text1.length()-24);
 		}


=====================================
ij/gui/StackWindow.java
=====================================
@@ -134,7 +134,7 @@ public class StackWindow extends ImageWindow implements Runnable, AdjustmentList
 				t = tSelector.getValue();
 				if (t==imp.getFrame()&&e.getAdjustmentType()==AdjustmentEvent.TRACK) return;
 			}
-			updatePosition();
+			slice = (t-1)*nChannels*nSlices + (z-1)*nChannels + c;
 			notify();
 		}
 		if (!running)
@@ -160,11 +160,6 @@ public class StackWindow extends ImageWindow implements Runnable, AdjustmentList
 			throw new RuntimeException("Unknownsource:"+source);
 	}
 
-	void updatePosition() {
-		slice = (t-1)*nChannels*nSlices + (z-1)*nChannels + c;
-		imp.updatePosition(c, z, t);
-	}
-
 	public void actionPerformed(ActionEvent e) {
 	}
 
@@ -244,8 +239,10 @@ public class StackWindow extends ImageWindow implements Runnable, AdjustmentList
 			if (slice>0) {
 				int s = slice;
 				slice = 0;
-				if (s!=imp.getCurrentSlice())
+				if (s!=imp.getCurrentSlice()) {
+					imp.updatePosition(c, z, t);
 					setSlice(imp,s);
+				}
 			}
 		}
 	}
@@ -301,7 +298,8 @@ public class StackWindow extends ImageWindow implements Runnable, AdjustmentList
 			tSelector.setValue(frame);
 			SyncWindows.setT(this, frame);
 		}
-    	updatePosition();
+		this.slice = (t-1)*nChannels*nSlices + (z-1)*nChannels + c;
+		imp.updatePosition(c, z, t);
 		if (this.slice>0) {
 			int s = this.slice;
 			this.slice = 0;


=====================================
ij/gui/Toolbar.java
=====================================
@@ -5,7 +5,11 @@ import java.awt.event.*;
 import java.awt.image.BufferedImage;
 import javax.imageio.ImageIO;
 import java.io.File;
-import java.util.*;
+import java.util.Timer;
+import java.util.Hashtable;
+import java.util.TimerTask;
+import java.util.Arrays;
+import java.util.Locale;
 import ij.*;
 import ij.plugin.frame.*;
 import ij.plugin.MacroInstaller;
@@ -1271,7 +1275,7 @@ public class Toolbar extends Canvas implements MouseListener, MouseMotionListene
 
 		if (!isRightClick && longClickDelay>0) {
 			if (pressTimer==null)
-				pressTimer = new java.util.Timer();			
+				pressTimer = new Timer();			
 			pressTimer.schedule(new TimerTask() {
 				public void run() {
 					if (pressTimer != null) {


=====================================
ij/io/ImageReader.java
=====================================
@@ -154,7 +154,7 @@ public class ImageReader {
 		int base = 0;
 		short last = 0;
 		for (int k=0; k<fi.stripOffsets.length; k++) {
-			//IJ.log("seek: "+fi.stripOffsets[k]+" "+fi.stripLengths[k]+"  "+(in instanceof RandomAccessStream));
+			//IJ.log("seek: "+k+" "+fi.stripOffsets[k]+" "+fi.stripLengths[k]+"  "+(in instanceof RandomAccessStream));
 			if (in instanceof RandomAccessStream)
 				((RandomAccessStream)in).seek(fi.stripOffsets[k]);
 			else if (k > 0) {


=====================================
ij/macro/Functions.java
=====================================
@@ -5220,6 +5220,18 @@ public class Functions implements MacroConstants, Measurements {
 			setPosition(imp);
 			return Double.NaN;
 		}
+		if (name.equals("setChannel")) {
+			imp.setPosition((int)getArg(),imp.getSlice(),imp.getFrame());
+			return Double.NaN;
+		}
+		if (name.equals("setSlice")) {
+			imp.setPosition(imp.getChannel(), (int)getArg(), imp.getFrame());
+			return Double.NaN;
+		}
+		if (name.equals("setFrame")) {
+			imp.setPosition(imp.getChannel(), imp.getSlice(), (int)getArg());
+			return Double.NaN;
+		}
 		if (name.equals("getPosition")) {
 			getPosition(imp);
 			return Double.NaN;
@@ -5245,16 +5257,12 @@ public class Functions implements MacroConstants, Measurements {
 			{getStackUnits(cal); return Double.NaN;}
 		if (name.equals("setUnits"))
 			{setStackUnits(imp); return Double.NaN;}
-		if (imp.getStackSize()==1)
+		if (imp.getStackSize()==1) {
 			interp.error("Stack required");
+			return Double.NaN;			
+		}
 		if (name.equals("setDimensions"))
 			setDimensions(imp);
-		else if (name.equals("setChannel"))
-			imp.setPosition((int)getArg(), imp.getSlice(), imp.getFrame());
-		else if (name.equals("setSlice"))
-			imp.setPosition(imp.getChannel(), (int)getArg(), imp.getFrame());
-		else if (name.equals("setFrame"))
-			imp.setPosition(imp.getChannel(), imp.getSlice(), (int)getArg());
 		else if (name.equals("setDisplayMode"))
 			setDisplayMode(imp, getStringArg());
 		else if (name.equals("getDisplayMode"))
@@ -8010,7 +8018,11 @@ public class Functions implements MacroConstants, Measurements {
 			return v;
 		} else if (name.equals("setSliceLabel")) {
 			String label = getFirstString();
-			int slice = (int)getLastArg();
+			int slice = imp.getCurrentSlice();
+			if (interp.nextToken()==',')
+				slice = (int)getLastArg();
+			else
+				interp.getRightParen();
 			if (slice<1 || slice>imp.getStackSize())
 				interp.error("Argument must be >=1 and <="+imp.getStackSize());
 			imp.getStack().setSliceLabel(label, slice);


=====================================
ij/measure/ResultsTable.java
=====================================
@@ -1235,8 +1235,9 @@ public class ResultsTable implements Cloneable {
 				if (j==labelsIndex&&labels)
 					rt.addLabel(headings[labelsIndex], items[labelsIndex]);
 				else {
-					double value = j<items.length?Tools.parseDouble(items[j]):Double.NaN;
-					if (Double.isNaN(value)) {
+					double defaultValue = -Double.MAX_VALUE;
+					double value = j<items.length?Tools.parseDouble(items[j], defaultValue):Double.NaN;
+					if (value==defaultValue) {
 						String item = j<items.length?items[j]:"";
 						if (commasReplaced) {
 							item = item.replaceAll(commaSubstitute2, ",");


=====================================
ij/plugin/Animator.java
=====================================
@@ -3,6 +3,7 @@ import ij.*;
 import ij.gui.*;
 import ij.process.*;
 import ij.measure.Calibration;
+import ij.plugin.frame.Recorder;
 import java.awt.Point;
 
 /** This plugin animates stacks. */
@@ -356,18 +357,37 @@ public class Animator implements PlugIn {
 		}
 		imp.updateStatusbarValue();
 	}
-
+	
 	void setSlice() {
-        GenericDialog gd = new GenericDialog("Set Slice");
-        gd.addNumericField("Slice Number (1-"+nSlices+"):", slice, 0);
-        gd.showDialog();
-        if (!gd.wasCanceled()) {
-        	int n = (int)gd.getNextNumber();
-        	if (imp.isDisplayedHyperStack())
-        		imp.setPosition(n);
-        	else
-        		imp.setSlice(n);
-        }
+		if (imp.isDisplayedHyperStack()) {
+			GenericDialog gd = new GenericDialog("Set Position");
+			int c = imp.getChannel();
+			int z = imp.getSlice();
+			int t = imp.getFrame();			
+			gd.addNumericField("Channel:", c);
+			gd.addNumericField("Slice:", z);
+			gd.addNumericField("Frame:", t);
+			gd.showDialog();
+			if (!gd.wasCanceled()) {
+				c = (int) gd.getNextNumber();
+				z = (int) gd.getNextNumber();
+				t = (int) gd.getNextNumber();
+				imp.setPosition(c, z, t);
+			}
+			if (Recorder.record) {
+				String method = Recorder.scriptMode()?"imp":"Stack";
+				Recorder.recordString(method+".setPosition("+c+","+z+","+t+");\n");
+				Recorder.disableCommandRecording();
+			}
+		} else {
+			GenericDialog gd = new GenericDialog("Set Slice");
+			gd.addNumericField("Slice (1-"+nSlices+"):", slice, 0);
+			gd.showDialog();
+			if (!gd.wasCanceled()) {
+				int slice = (int)gd.getNextNumber();
+				imp.setSlice(slice);
+			}
+		}
 	}
 
 	/** Returns the current animation speed in frames per second. */


=====================================
ij/plugin/Benchmark.java
=====================================
@@ -20,7 +20,7 @@ public class Benchmark implements PlugIn {
 		"24.7|27\" iMac (Early 2015)",
     	"29.7|13\" MacBook Pro (Late 2015)",
     	"29.7|15\" MacBook Pro (Early 2013)",
-    	"62.3|Acer Aspire laptop (Core i5, 2014)"
+     	"62.3|Acer Aspire laptop (Core i5, 2014)"
 	};
     private int size = 5000;
     private int ops = 62;
@@ -80,7 +80,9 @@ public class Benchmark implements PlugIn {
 		String t = IJ.d2s(time,1);
 		if (t.length()<4) t=" "+t;
 		rt.addValue("Time", t);
-		rt.addValue("Computer", "<<THIS MACHINE ("+Prefs.getThreads()+" THREADS)>>");
+		int threads = Prefs.getThreads();
+		String suffix = " THREAD"+(threads>1?"S":"")+")>>";
+		rt.addValue("Computer", "<<THIS MACHINE ("+threads+suffix);
 		rt.sort("Time");
         rt.show("Benchmark Results");
         IJ.showStatus("!"+IJ.d2s(time,1)+" seconds to perform "+counter+" operations on a "+size+"x"+size+" 16-bit image");
@@ -118,7 +120,7 @@ public class Benchmark implements PlugIn {
     }
 
     void error(String msg) {
-        IJ.log("Benchmark: "+msg+" regression");
+        IJ.log("Benchmark: "+msg+" error");
     }
 }
 


=====================================
ij/plugin/Options.java
=====================================
@@ -48,6 +48,7 @@ public class Options implements PlugIn {
 			gd.addCheckbox("Save window locations", !Prefs.doNotSaveWindowLocations);
 		gd.addCheckbox("Non-blocking filter dialogs", Prefs.nonBlockingFilterDialogs);
 		gd.addCheckbox("Debug mode", IJ.debugMode);
+		//gd.addCheckbox("Modern mode", Prefs.modernMode);
 		gd.addHelp(IJ.URL+"/docs/menus/edit.html#misc");
 		gd.showDialog();
 		if (gd.wasCanceled())
@@ -83,6 +84,7 @@ public class Options implements PlugIn {
 			Prefs.doNotSaveWindowLocations = !gd.getNextBoolean();
 		Prefs.nonBlockingFilterDialogs = gd.getNextBoolean();
 		IJ.setDebugMode(gd.getNextBoolean());
+		//Prefs.modernMode = gd.getNextBoolean();
 	}
 
 	void lineWidth() {


=====================================
ij/plugin/Orthogonal_Views.java
=====================================
@@ -581,10 +581,12 @@ public class Orthogonal_Views implements PlugIn, MouseListener, MouseMotionListe
 			notify();
 		}
 		imp.setOverlay(null);
-		canvas.removeMouseListener(this);
-		canvas.removeMouseMotionListener(this);
-		canvas.removeKeyListener(this);
-		canvas.setCustomRoi(false);
+		if (canvas!=null) {
+			canvas.removeMouseListener(this);
+			canvas.removeMouseMotionListener(this);
+			canvas.removeKeyListener(this);
+			canvas.setCustomRoi(false);
+		}
 		xz_image.setOverlay(null);
 		ImageWindow win1 = xz_image.getWindow();
 		if (win1!=null) {


=====================================
ij/plugin/Thresholder.java
=====================================
@@ -40,25 +40,13 @@ public class Thresholder implements PlugIn, Measurements, ItemListener {
 			showLegacyDialog = false;
 		ImagePlus imp = IJ.getImage();
 		if (imp.getStackSize()==1) {
-			if (!convertToMask && imp.getProcessor().isBinary())
-				setThreshold(imp);
-			else {
-				Undo.setup(Undo.TRANSFORM, imp);
-				applyThreshold(imp, false);
-			}
+			Undo.setup(Undo.TRANSFORM, imp);
+			applyThreshold(imp, false);
 		} else
 			convertStack(imp);
 		IJ.showProgress(1.0);
 	}
 	
-	private void setThreshold(ImagePlus imp) {
-		ImageProcessor ip = imp.getProcessor();
-		int threshold = ip.isInvertedLut()?255:0;
-		if (Prefs.blackBackground)
-			threshold = ip.isInvertedLut()?0:255;		
-		ip.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE);
-	}
-	
 	void convertStack(ImagePlus imp) {
 		if (imp.getStack().isVirtual()) {
 			IJ.error("Thresholder", "This command does not work with virtual stacks.\nUse Image>Duplicate to convert to a normal stack.");


=====================================
ij/plugin/filter/Filters.java
=====================================
@@ -20,14 +20,14 @@ public class Filters implements PlugInFilter {
 		this.imp = imp;
 		if (imp!=null) {
 			Roi roi = imp.getRoi();
+			if (imp.getType()==ImagePlus.GRAY16 && arg.equals("invert")) {
+				imp.resetRoi();
+				roi = null;
+			}
 			if (roi!=null && !roi.isArea())
 				noRoi = true;
 		}
 		int flags = IJ.setupDialog(imp, DOES_ALL-DOES_8C+SUPPORTS_MASKING);
-		if ((flags&PlugInFilter.DOES_STACKS)!=0 && imp.getType()==ImagePlus.GRAY16 && imp.getStackSize()>1 && arg.equals("invert")) {
-				invert16BitStack(imp);
-				return DONE;
-		}
 		return flags;
 	}
 
@@ -38,6 +38,9 @@ public class Filters implements PlugInFilter {
 	
 		if (arg.equals("invert")) {
 	 		ip.invert();
+	 		slice++;
+	 		if (imp.getBitDepth()==16 && imp.getStackSize()>1 && slice==imp.getStackSize())
+	 			imp.resetDisplayRange();
 	 		return;
 	 	}
 	 	
@@ -87,28 +90,7 @@ public class Filters implements PlugInFilter {
 	 	}
         	 	
 	}
-	
-	void invert16BitStack(ImagePlus imp) {
-		imp.deleteRoi();
-		imp.getCalibration().disableDensityCalibration();
-		ImageStatistics stats = new StackStatistics(imp);
-		ImageStack stack = imp.getStack();
-		int nslices = stack.size();
-		int min=(int)stats.min, range=(int)(stats.max-stats.min);
-		int n = imp.getWidth()*imp.getHeight();
-		for (int slice=1; slice<=nslices; slice++) {
-			ImageProcessor ip = stack.getProcessor(slice);
-			short[] pixels = (short[])ip.getPixels();
-			for (int i=0; i<n; i++) {
-				int before = pixels[i]&0xffff;
-				pixels[i] = (short)(range-((pixels[i]&0xffff)-min));
-			}
-		}
-		imp.setStack(null, stack);
-		imp.setDisplayRange(0, range);
-		imp.updateAndDraw();
-	}
-	
+		
 	/** Returns the default standard deviation used by Process/Noise/Add Specified Noise. */
 	public static double getSD() {
 		return sd;


=====================================
ij/plugin/filter/ParticleAnalyzer.java
=====================================
@@ -798,7 +798,7 @@ public class ParticleAnalyzer implements PlugInFilter, Measurements {
 			imageType = BYTE;
 		if (t1==ImageProcessor.NO_THRESHOLD) {
 			noThreshold = true;
-			ImageStatistics stats = imp.getStatistics();
+			ImageStatistics stats = imp.getRawStatistics();
 			if (imageType!=BYTE || (stats.histogram[0]+stats.histogram[255]!=stats.pixelCount)) {
 				IJ.error("Particle Analyzer",
 					"A threshold has not been set using the\n"
@@ -807,14 +807,10 @@ public class ParticleAnalyzer implements PlugInFilter, Measurements {
 				canceled = true;
 				return false;
 			}
-			boolean threshold255 = invertedLut;
-			if (Prefs.blackBackground)
-				threshold255 = !threshold255;
-			if (threshold255) {
-				level1 = 255;
-				level2 = 255;
-				fillColor = 64;
-			} else {
+			level1 = 255;
+			level2 = 255;
+			fillColor = 64;
+			if (!Prefs.blackBackground && !imp.isInvertedLut() && stats.histogram[0]<(imp.getWidth()*imp.getHeight())/2) {
 				level1 = 0;
 				level2 = 0;
 				fillColor = 192;


=====================================
ij/plugin/filter/PlugInFilterRunner.java
=====================================
@@ -195,6 +195,7 @@ public class PlugInFilterRunner implements Runnable, DialogListener {
 				announceSliceNumber(i);
 				ip.setPixels(stack.getPixels(i));
 				ip.setSliceNumber(i);
+				ip.setSnapshotPixels(null);
 				processOneImage(ip, fp, null);
 				if (IJ.escapePressed()) {IJ.beep(); break;}
 			}


=====================================
ij/plugin/frame/Recorder.java
=====================================
@@ -298,10 +298,14 @@ public class Recorder extends PlugInFrame implements PlugIn, ActionListener, Ima
 			textArea.append(str);
 	}
 	
+	public static void disableCommandRecording() {
+		commandName = null;
+	}
+	
 	public static void recordCall(String call) {
 		recordCall(call, false);
 	}
-
+	
 	public static void recordCall(String call, boolean recordCommand) {
 		if (IJ.debugMode) IJ.log("recordCall: "+call+"  "+commandName);
 		boolean isMacro = Thread.currentThread().getName().endsWith("Macro$") && !recordInMacros;


=====================================
ij/process/ImageProcessor.java
=====================================
@@ -478,6 +478,11 @@ public abstract class ImageProcessor implements Cloneable {
 		ByteProcessors, resets the LUT. */
 	public void resetMinAndMax() {}
 
+	/** Sets the lower and upper threshold levels using NO_LUT_UPDATE. */
+	public void setThreshold(double minThreshold, double maxThreshold) {
+		setThreshold(minThreshold, maxThreshold, NO_LUT_UPDATE);
+	}
+
 	/** Sets the lower and upper threshold levels. The 'lutUpdate' argument
 		can be RED_LUT, BLACK_AND_WHITE_LUT, OVER_UNDER_LUT or NO_LUT_UPDATE.
 		Thresholding of RGB images is not supported. */


=====================================
ij/process/ShortProcessor.java
=====================================
@@ -567,12 +567,17 @@ public class ShortProcessor extends ImageProcessor {
 			}
 		}
     }
-
+    
 	public void invert() {
-		resetMinAndMax();
+		int range = 65536;
+		int defaultRange = ij.ImagePlus.getDefault16bitRange();
+		if (defaultRange>0 && !isSigned16Bit())
+			range = (int)Math.pow(2,defaultRange);
+		setMinAndMax(0, range-1);
 		process(INVERT, 0.0);
+		resetMinAndMax();
 	}
-	
+
 	public void add(int value) {process(ADD, value);}
 	public void add(double value) {process(ADD, value);}
 	public void set(double value) {process(SET, value);}


=====================================
plugins/MacAdapter9.class
=====================================
Binary files /dev/null and b/plugins/MacAdapter9.class differ


=====================================
plugins/MacAdapter9.source
=====================================
@@ -0,0 +1,58 @@
+package ij.plugin;
+import ij.*;
+import ij.io.*;
+import java.awt.Desktop;
+import java.awt.desktop.*;
+import java.io.File;
+import java.util.Vector;
+
+/** This Mac-specific plugin is designed to handle the "About ImageJ" 
+ * command in the ImageJ menu, to open files dropped on ImageJ.app 
+ * and to open double-clicked files with creator code "imgJ". 
+ * With Java 9 or newer, we use java.awt.desktop instead of the
+ * previous com.apple.eawt.* classes.
+ * @author Alan Brooks
+*/
+public class MacAdapter9 implements PlugIn, AboutHandler, OpenFilesHandler, QuitHandler, Runnable {
+   static Vector<String> paths = new Vector<String>();
+
+   public void run(String arg) {
+      Desktop dtop = Desktop.getDesktop();
+      dtop.setOpenFileHandler(this);
+      dtop.setAboutHandler(this);
+      dtop.setQuitHandler(this);
+   }
+
+   @Override
+   public void handleAbout(AboutEvent e) {
+      IJ.doCommand("About ImageJ...");
+   }
+
+   @Override
+   public void openFiles(OpenFilesEvent e) {
+      for (File file: e.getFiles()) {
+         paths.add(file.getPath());
+         Thread thread = new Thread(this, "Open");
+         thread.setPriority(thread.getPriority()-1);
+         thread.start();
+      }
+   }
+
+   @Override
+   public void handleQuitRequestWith(QuitEvent e, QuitResponse response) {
+      new Executer("Quit", null); // works with the CommandListener
+   }
+ 
+   // Not adding preference handling
+   // because we don't have the equivalent of app.setEnabledPreferencesMenu(true);
+   // @Override
+   // public void handlePreferences(PreferencesEvent e) {
+   //    IJ.error("The ImageJ preferences are in the Edit>Options menu.");
+   // }
+  
+    public void run() {
+      if (paths.size() > 0) {
+         (new Opener()).openAndAddToRecent(paths.remove(0));
+      }
+    }
+}


=====================================
release-notes.html
=====================================
@@ -5,6 +5,47 @@
 </head>
 <body>
 
+<li> <u>1.53k 6 July 2021</u>
+<ul>
+<li> Thanks Mike Nelson, 16-bit images are
+inverted using the full pixel value range (0-65535) or, if set,
+using the "Unsigned 16-bit range" in the "Set" option of the
+<i>Image>Adjust>Brightness/Contrast</i> dialog.
+<li> Thanks to Alan Brooks, added the macOS-specific
+MacAdapter9 plugin, which, on Java 9 or later,
+supports drag and drop on the ImageJ.app and the
+"About ImageJ" command.
+<li> Thanks to Romain Guiet, the ROI Manager's
+"Associate 'Show All' ROIs with slices" option is
+now enabled by default.
+<li> Thanks to Gilles Carpentier, the particle analyzer now assumes
+the threshold is 255 unless "Black background" is not set,
+the image does not have an inverted LUT and fewer than
+half the pixels have a value of zero, in which case
+the threshold is set to zero.
+<li> Thanks to 'pdd2110', added the Property.setSliceLabel(label)
+macro function.
+<li> Thanks to 'John D.', added the GenericDialog.addButton() method
+(<a href="http://wsr.imagej.net/plugins/Button_Example.java">example</a>).
+<li> Thanks to 'Oodegard', fixed a bug that caused the
+"Auto-next slice" option of the point tool to not
+work as expected with hyperstacks.
+<li> Thanks to Michael Schmid, fixed a bug that caused
+NaN values in tables read from a file to be
+strings instead of numbers.
+<li> Thanks to Gabriel Landini and Michael Schmid, fixed a bug
+that caused the "Top Hat" filter to fail when applying it to a
+stack one slice at a time.
+<li> Thanks to Laurent Thomas, fixed a bug that caused the
+<i>Image>Stacks>Set Slice</i> command to not
+work as expected with hyperstacks.
+<li> Thanks to Laurent Thomas, fixed a bug that caused hyperstacks
+to be displayed incorrectly if the Z or T sliders where 
+moved quickly and the images were slow to load.
+<li> Thanks to Michael Schmid, fixed a bug that sometimes caused
+the WindowManager.getIDList() method to throw an exception.
+</ul>
+
 <li> <u>1.53j 13 May 2021</u>
 <ul>
 <li> Thanks to 'VolkerH', the table created by



View it on GitLab: https://salsa.debian.org/med-team/imagej/-/commit/e0f2422cddc742f8ca260f61f16aac586bb51400

-- 
View it on GitLab: https://salsa.debian.org/med-team/imagej/-/commit/e0f2422cddc742f8ca260f61f16aac586bb51400
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210709/c3ac863d/attachment-0001.htm>


More information about the debian-med-commit mailing list