From dab50bb92a5d56100a681c050743140a84237a88 Mon Sep 17 00:00:00 2001 From: Wayne Rasband Date: Thu, 6 Oct 2022 21:45:06 -0400 Subject: [PATCH] 2022.10.06 (1.53u45; Rotated rectangles) --- ij/ImageJ.java | 2 +- ij/gui/Line.java | 3 ++- ij/gui/ProfilePlot.java | 12 ++---------- ij/gui/Roi.java | 10 ++++------ ij/plugin/NextImageOpener.java | 7 ++++++- ij/plugin/ScaleBar.java | 10 +++++----- ij/util/StringSorter.java | 4 +++- release-notes.html | 6 +++++- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/ij/ImageJ.java b/ij/ImageJ.java index 9692cf31f..f57840244 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.53u"; - public static final String BUILD = "43"; + public static final String BUILD = "45"; 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/gui/Line.java b/ij/gui/Line.java index 7c98bdb5d..343f23347 100644 --- a/ij/gui/Line.java +++ b/ij/gui/Line.java @@ -450,7 +450,7 @@ public double[] getPixels() { profile = ip.getLine(x1d, y1d, x2d, y2d); } else { Straightener s = new Straightener(); - ImageProcessor ip2 = imp.getBitDepth()==24?s.rotateLine(imp,width):s.straightenLine(imp,this,0); + ImageProcessor ip2 = s.straightenLine(imp,this,0); if (ip2==null) return new double[0]; int width = ip2.getWidth(); @@ -509,6 +509,7 @@ public FloatPolygon getFloatPolygon() { return getFloatPolygon(getStrokeWidth()); } + /** Obsolete */ public FloatPolygon getFloatPolygon(double strokeWidth) { FloatPolygon p = new FloatPolygon(); if (strokeWidth <= 1) { diff --git a/ij/gui/ProfilePlot.java b/ij/gui/ProfilePlot.java index 42d2c06b8..fbad3abf0 100644 --- a/ij/gui/ProfilePlot.java +++ b/ij/gui/ProfilePlot.java @@ -47,29 +47,21 @@ public ProfilePlot(ImagePlus imp, boolean averageHorizontally) { IJ.error("Line or rectangular selection required."); return; } - Roi saveRoi = null; if (rotatedRect) { - boolean rgb = imp.getBitDepth()==24; - if (rgb) - saveRoi = roi; double[] p = ((RotatedRectRoi)roi).getParams(); roi = new Line(p[0], p[1], p[2], p[3]); roi.setStrokeWidth(p[4]); roi.setImage(imp); roiType = Roi.LINE; - if (rgb) - imp.setRoi(roi); } Calibration cal = imp.getCalibration(); xInc = cal.pixelWidth; units = cal.getUnits(); yLabel = cal.getValueUnit(); ImageProcessor ip = imp.getProcessor(); - if (roiType==Roi.LINE) { + if (roiType==Roi.LINE) profile = getStraightLineProfile(roi, cal, ip); - if (saveRoi!=null) - imp.setRoi(saveRoi); - } else if (roiType==Roi.POLYLINE || roiType==Roi.FREELINE) { + else if (roiType==Roi.POLYLINE || roiType==Roi.FREELINE) { int lineWidth = (int)Math.round(roi.getStrokeWidth()); if (lineWidth<=1) profile = getIrregularProfile(roi, ip, cal); diff --git a/ij/gui/Roi.java b/ij/gui/Roi.java index 8fe09976d..9913ecf36 100644 --- a/ij/gui/Roi.java +++ b/ij/gui/Roi.java @@ -2702,16 +2702,14 @@ public static Roi convertLineToArea(Roi line) { if (line==null || !line.isLine()) throw new IllegalArgumentException("Line selection required"); double lineWidth = line.getStrokeWidth(); + if (lineWidth<1.0) + lineWidth = 1.0; Roi roi2 = null; if (line.getType()==Roi.LINE) { - if (lineWidth<=1.0) - lineWidth = 1.0000001; - FloatPolygon p = ((Line)line).getFloatPolygon(lineWidth); - roi2 = new PolygonRoi(p, Roi.POLYGON); + FloatPolygon p = ((Line)line).getFloatPoints(); + roi2 = new RotatedRectRoi(p.xpoints[0],p.ypoints[0],p.xpoints[1],p.ypoints[1],lineWidth); line.setStrokeWidth(lineWidth); } else { - if (lineWidth<1) - lineWidth = 1; Rectangle bounds = line.getBounds(); double width = bounds.x+bounds.width + lineWidth; double height = bounds.y+bounds.height + lineWidth; diff --git a/ij/plugin/NextImageOpener.java b/ij/plugin/NextImageOpener.java index fa128e206..6bc411833 100644 --- a/ij/plugin/NextImageOpener.java +++ b/ij/plugin/NextImageOpener.java @@ -112,8 +112,13 @@ else if (d.yesPressed()) { /** gets the next image name in a directory list */ String getNext(String path, String imageName, boolean forward) { File dir = new File(path); - if (!dir.isDirectory()) return null; + if (!dir.isDirectory()) + return null; String[] names = dir.list(); + if (names==null) { + IJ.log("getNext directory empty: "+path); + return null; + } ij.util.StringSorter.sort(names); int thisfile = -1; for (int i=0; i 0) { - p = (int) (p * ((processor.getMax() - processor.getMin()) / 255d) + (float)processor.getMin()); + p = (int)Math.round(p * ((processor.getMax() - processor.getMin()) / 255d) + (float)processor.getMin()); if (processor.getBitDepth() == 32) p = Float.floatToIntBits(p); processor.putPixel(x, y, p); diff --git a/ij/util/StringSorter.java b/ij/util/StringSorter.java index 9b4a62663..9d26edd95 100644 --- a/ij/util/StringSorter.java +++ b/ij/util/StringSorter.java @@ -5,6 +5,8 @@ public class StringSorter { /** Sorts the array. */ public static void sort(String[] a) { + if (a==null) + return; if (!alreadySorted(a)) sort(a, 0, a.length - 1); } @@ -23,7 +25,7 @@ static void sort(String[] a, int from, int to) { } static boolean alreadySorted(String[] a) { - for ( int i=1; i -
  • 1.53u43 4 October 2022 +
  • 1.53u45 6 October 2022
    • Thanks to Dr. Njitram, the Analyze>Plot Profile command works with rotated rectangles. +
    • The Edit>Selection>Line to Area command +converts straight line selections to rotated rectangle +selections.
    • Thanks to Herbie Gluender, improved recording of the Edit>Selection>Properties command and added a comment to the Edit>Options>Line Width Dialog @@ -55,6 +58,7 @@ of the "GUI scale" setting.
    • Thanks to Stein Rorvik, fixed a bug that caused the Roi.Paste macro function to not work as expected. +
    • Thanks to 'bobfRT1', fixed a scale bar width rounding error.
    • Thanks to Mark Hiner, fixed a 1.53t regression that caused the Image>Stacks>Z Project command to ignore the last slice when doing "Average" projection of 32-bit stacks.