Skip to content

Commit

Permalink
2022.10.06 (1.53u45; Rotated rectangles)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Oct 7, 2022
1 parent 870c9f0 commit dab50bb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ij/gui/Line.java
Expand Up @@ -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();
Expand Down Expand Up @@ -509,6 +509,7 @@ public FloatPolygon getFloatPolygon() {
return getFloatPolygon(getStrokeWidth());
}

/** Obsolete */
public FloatPolygon getFloatPolygon(double strokeWidth) {
FloatPolygon p = new FloatPolygon();
if (strokeWidth <= 1) {
Expand Down
12 changes: 2 additions & 10 deletions ij/gui/ProfilePlot.java
Expand Up @@ -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);
Expand Down
10 changes: 4 additions & 6 deletions ij/gui/Roi.java
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion ij/plugin/NextImageOpener.java
Expand Up @@ -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<names.length; i++) {
Expand Down
10 changes: 5 additions & 5 deletions ij/plugin/ScaleBar.java
Expand Up @@ -372,8 +372,8 @@ void updateFont() {
*/
void setBackgroundBoxesPositions(ImageProcessor ip) throws MissingRoiException {
Calibration cal = imp.getCalibration();
hBarWidthInPixels = (int)(config.hBarWidth/cal.pixelWidth);
vBarHeightInPixels = (int)(config.vBarHeight/cal.pixelHeight);
hBarWidthInPixels = (int)Math.round(config.hBarWidth/cal.pixelWidth);
vBarHeightInPixels = (int)Math.round(config.vBarHeight/cal.pixelHeight);

boolean hTextTop = config.showVertical && (config.location.equals(locations[UPPER_LEFT]) || config.location.equals(locations[UPPER_RIGHT]));

Expand Down Expand Up @@ -463,7 +463,7 @@ void setElementsPositions(ImageProcessor ip) throws MissingRoiException {
hText.height = config.hideText ? 0 : config.fontSize;
hText.width = config.hideText ? 0 : ip.getStringWidth(getHLabel());
hText.x = hBackground.x + innerMargin + (hBoxWidth - hText.width)/2 + (config.showVertical && !right && upper ? vBoxWidth - config.barThicknessInPixels : 0);
hText.y = hTextTop ? (hBackground.y + innerMargin - (int)(config.fontSize*0.25)) : (hBar.y + hBar.height);
hText.y = hTextTop ? (hBackground.y + innerMargin - (int)Math.round(config.fontSize*0.25)) : (hBar.y + hBar.height);

vBar.width = config.barThicknessInPixels;
vBar.height = vBarHeightInPixels;
Expand All @@ -472,7 +472,7 @@ void setElementsPositions(ImageProcessor ip) throws MissingRoiException {

vText.height = config.hideText ? 0 : ip.getStringWidth(getVLabel());
vText.width = config.hideText ? 0 : config.fontSize;
vText.x = right ? (vBar.x + vBar.width) : (vBar.x - vBoxWidth + config.barThicknessInPixels - (int)(config.fontSize*0.25));
vText.x = right ? (vBar.x + vBar.width) : (vBar.x - vBoxWidth + config.barThicknessInPixels - (int)Math.round(config.fontSize*0.25));
vText.y = vBackground.y + innerMargin + (vBoxHeight - vText.height)/2;
}

Expand Down Expand Up @@ -585,7 +585,7 @@ void drawOverlayOnProcessor(Overlay overlay, ImageProcessor processor) {
for (int x = 0; x < ip.getWidth(); x++) {
int p = ip.get(x, y);
if (p > 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);
Expand Down
4 changes: 3 additions & 1 deletion ij/util/StringSorter.java
Expand Up @@ -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);
}
Expand All @@ -23,7 +25,7 @@ static void sort(String[] a, int from, int to) {
}

static boolean alreadySorted(String[] a) {
for ( int i=1; i<a.length; i++ ) {
for (int i=1; i<a.length; i++ ) {
if (a[i].compareTo(a[i-1]) < 0 )
return false;
}
Expand Down
6 changes: 5 additions & 1 deletion release-notes.html
Expand Up @@ -5,10 +5,13 @@
</head>
<body>

<li> <u>1.53u43 4 October 2022</u>
<li> <u>1.53u45 6 October 2022</u>
<ul>
<li> Thanks to Dr. Njitram, the <i>Analyze&gt;Plot Profile</i>
command works with rotated rectangles.
<li> The <i>Edit&gt;Selection&gt;Line to Area</i> command
converts straight line selections to rotated rectangle
selections.
<li> Thanks to Herbie Gluender, improved recording of the
<i>Edit&gt;Selection&gt;Properties</i> command and added a
comment to the <i>Edit&gt;Options&gt;Line Width</i> Dialog
Expand Down Expand Up @@ -55,6 +58,7 @@
of the "GUI scale" setting.
<li> Thanks to Stein Rorvik, fixed a bug that caused the Roi.Paste
macro function to not work as expected.
<li> Thanks to 'bobfRT1', fixed a scale bar width rounding error.
<li> Thanks to Mark Hiner, fixed a 1.53t regression that caused
the <i>Image&gt;Stacks&gt;Z Project</i> command to ignore the last
slice when doing "Average" projection of 32-bit stacks.
Expand Down

0 comments on commit dab50bb

Please sign in to comment.