From c80f6efc5338bff9ffcc9dae4fd52cc496faa0e0 Mon Sep 17 00:00:00 2001 From: Wayne Rasband Date: Mon, 28 Oct 2024 13:52:23 -0400 Subject: [PATCH] 2024.10.28 (1.54m16; Histogram bin width) --- ij/IJ.java | 1 + ij/ImageJ.java | 2 +- ij/Prefs.java | 8 ++++---- ij/gui/HistogramPlot.java | 5 +---- ij/gui/HistogramWindow.java | 5 +---- ij/macro/Functions.java | 1 + ij/measure/ResultsTable.java | 23 +++++++++++++++++++++++ ij/plugin/SimpleCommands.java | 7 +++---- ij/process/ColorStatistics.java | 2 +- ij/process/FloatStatistics.java | 2 +- ij/process/ShortStatistics.java | 2 +- ij/process/StackStatistics.java | 4 ++-- release-notes.html | 13 +++++++++++-- 13 files changed, 51 insertions(+), 24 deletions(-) diff --git a/ij/IJ.java b/ij/IJ.java index 4880eab96..ed8125eb9 100644 --- a/ij/IJ.java +++ b/ij/IJ.java @@ -2574,6 +2574,7 @@ public static void protectStatusBar(boolean protect) { statusBarThread = null; } + /** Returns 'true' if the Recorder is running and ImageJ is not in headless mode. */ public static boolean recording() { return (!GraphicsEnvironment.isHeadless()&&Recorder.record); } diff --git a/ij/ImageJ.java b/ij/ImageJ.java index cee948903..da0ece90b 100644 --- a/ij/ImageJ.java +++ b/ij/ImageJ.java @@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener, /** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */ public static final String VERSION = "1.54m"; - public static final String BUILD = "12"; + public static final String BUILD = "16"; 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); diff --git a/ij/Prefs.java b/ij/Prefs.java index 79a6eee62..b20f902d8 100644 --- a/ij/Prefs.java +++ b/ij/Prefs.java @@ -381,9 +381,9 @@ public static String getHomeDir() { public static String getImageJDir() { String path = Menus.getImageJPath(); if (path==null) { - String ijPath = getPluginsDirProperty(); - //if (ijPath==null) - // ijPath = ImageJDir; + String ijPath = ImageJDir; + if (ijPath==null) + ijPath = getPluginsDirProperty(); if (ijPath==null) ijPath = System.getProperty("user.dir"); return ijPath + File.separator; @@ -442,7 +442,7 @@ public static String getPrefsDir() { /** Sets the path to the ImageJ directory. */ static void setHomeDir(String path) { - if (path.endsWith(File.separator)) + if (path.endsWith(File.separator) || path.endsWith("/")) path = path.substring(0, path.length()-1); ImageJDir = path; } diff --git a/ij/gui/HistogramPlot.java b/ij/gui/HistogramPlot.java index 1e23a670b..d4003f775 100644 --- a/ij/gui/HistogramPlot.java +++ b/ij/gui/HistogramPlot.java @@ -287,9 +287,6 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) { ip.setAntialiasedText(true); double hmin = cal.getCValue(stats.histMin); double hmax = cal.getCValue(stats.histMax); - double range = hmax-hmin; - if (fixedRange&&!cal.calibrated()&&hmin==0&&hmax==255) - range = 256; ip.drawString(d2s(hmin), x - 4, y); ip.drawString(d2s(hmax), x + HIST_WIDTH - getWidth(hmax, ip) + 10, y); if (rgbMode>=INTENSITY1) { @@ -307,7 +304,7 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) { } ip.setJustification(ImageProcessor.LEFT_JUSTIFY); } - double binWidth = range/stats.nBins; + double binWidth = (hmax-hmin+1)/stats.nBins; binWidth = Math.abs(binWidth); showBins = binWidth!=1.0 || !fixedRange; col1 = XMARGIN + 5; diff --git a/ij/gui/HistogramWindow.java b/ij/gui/HistogramWindow.java index b793de106..d7559b41c 100644 --- a/ij/gui/HistogramWindow.java +++ b/ij/gui/HistogramWindow.java @@ -423,9 +423,6 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) { ip.setAntialiasedText(true); double hmin = cal.getCValue(stats.histMin); double hmax = cal.getCValue(stats.histMax); - double range = hmax-hmin; - if (fixedRange&&!cal.calibrated()&&hmin==0&&hmax==255) - range = 256; ip.drawString(d2s(hmin), x - 4, y); ip.drawString(d2s(hmax), x + HIST_WIDTH - getWidth(hmax, ip) + 10, y); if (rgbMode>=INTENSITY1) { @@ -443,7 +440,7 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) { } ip.setJustification(ImageProcessor.LEFT_JUSTIFY); } - double binWidth = range/stats.nBins; + double binWidth = (hmax-hmin+1)/stats.nBins; binWidth = Math.abs(binWidth); showBins = binWidth!=1.0 || !fixedRange; col1 = XMARGIN + 5; diff --git a/ij/macro/Functions.java b/ij/macro/Functions.java index dab87018f..b7c424f8b 100644 --- a/ij/macro/Functions.java +++ b/ij/macro/Functions.java @@ -2304,6 +2304,7 @@ void makeSelection() { } else if (name.equals("drawShapes")) { return drawShapes(); } else if (name.equals("drawGrid")) { + interp.getParens(); plot.drawShapes("redraw_grid", null); return Double.NaN; } else if (name.startsWith("setLineWidth")) { diff --git a/ij/measure/ResultsTable.java b/ij/measure/ResultsTable.java index df7ecaa20..047e7c49b 100644 --- a/ij/measure/ResultsTable.java +++ b/ij/measure/ResultsTable.java @@ -382,6 +382,29 @@ public ImageProcessor getTableAsImage() { return fp; } + /** Creates a ResultsTable from an image or image selection. */ + public static ResultsTable createTableFromImage(ImagePlus imp) { + if (imp==null) + return null; + Roi roi = imp.getRoi(); + ImageProcessor ip = imp.getProcessor(); + if (roi==null || roi.getType()==Roi.RECTANGLE) + return createTableFromImage(ip); + ResultsTable rt = new ResultsTable(); + Rectangle r = ip.getRoi(); + for (int y=r.y; yhistMax) max = histMax; } - binSize = (histMax-histMin)/nBins; + binSize = (histMax-histMin+1)/nBins; // Generate histogram double scale = nBins/(histMax-histMin); diff --git a/ij/process/ShortStatistics.java b/ij/process/ShortStatistics.java index ab647a92a..f2a32ade3 100644 --- a/ij/process/ShortStatistics.java +++ b/ij/process/ShortStatistics.java @@ -91,7 +91,7 @@ void getStatistics(ImageProcessor ip, int[] hist, int min, int max, float[] cTab if (minhistMax) max = (int)histMax; } - binSize = (histMax-histMin)/nBins; + binSize = (histMax-histMin+1)/nBins; double scale = 1.0/binSize; int hMin = (int)histMin; histogram = new int[nBins]; // 256 bin histogram diff --git a/ij/process/StackStatistics.java b/ij/process/StackStatistics.java index d81804dbe..7692fa2f7 100644 --- a/ij/process/StackStatistics.java +++ b/ij/process/StackStatistics.java @@ -146,7 +146,7 @@ void doCalculations(ImagePlus imp, int bins, double histogramMin, double histog calculateStdDev(longPixelCount, sum, sum2); histMin = cal.getRawValue(histMin); histMax = cal.getRawValue(histMax); - binSize = (histMax-histMin)/nBins; + binSize = (histMax-histMin+1)/nBins; int bits = imp.getBitDepth(); if (histMin==0.0 && histMax==256.0 && (bits==8||bits==24)) histMax = 255.0; @@ -297,7 +297,7 @@ void get16BitStatistics(long[] hist, int min, int max) { nBins = 256; histMin = min; histMax = max; - binSize = (histMax-histMin)/nBins; + binSize = (histMax-histMin+1)/nBins; double scale = 1.0/binSize; int hMin = (int)histMin; longHistogram = new long[nBins]; // 256 bin histogram diff --git a/release-notes.html b/release-notes.html index 514a88241..765759212 100644 --- a/release-notes.html +++ b/release-notes.html @@ -6,8 +6,12 @@ -
  • 1.54m12 17 October 2024 +
  • 1.54m16 28 October 2024
      +
    • Thanks to 'Patricia' and Herbie Gluender, the +Image>Transform>Image to Results command +now shows NaNs when values are outside non-rectangular +selections.
    • Thanks to Kevin Terretaz, CommandFinder (Plugins>Utilities>Find Commands) filtering is more precise and flexible. It now splits the input into individual words @@ -24,7 +28,12 @@ to the image width or vertical lines with a length equal to the image height.
    • Thanks to Peter Dodok, fixed bug with recording in -Fiji headless mode +Fiji headless mode. +
    • Thanks to Jerome Mutterer, fixed bug where the -ijpath +command line option is not respected when using the +-batch option. +
    • Thanks to Guenter Pudmich, fixed bug with the calculation +of 16 and 32 bit histogram bin widths.
  • 1.54k 15 September 2024