Skip to content

Commit 7330e84

Browse files
committed
2025.09.18 (1.54r6; Fit Spline)
1 parent 5a3ef4a commit 7330e84

File tree

7 files changed

+17
-38
lines changed

7 files changed

+17
-38
lines changed

ij/ImageJ.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener,
7979

8080
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
8181
public static final String VERSION = "1.54r";
82-
public static final String BUILD = "2";
82+
public static final String BUILD = "6";
8383
public static Color backgroundColor = new Color(237,237,237);
8484
/** SansSerif, 12-point, plain font. */
8585
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);

ij/gui/ImageCanvas.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ public void update(Graphics g) {
210210
}
211211

212212
public void paint(Graphics g) {
213-
// if (IJ.debugMode) IJ.log("paint: "+imp);
214213
painted = true;
215214
Roi roi = imp.getRoi();
216215
Overlay overlay = imp.getOverlay();
@@ -301,7 +300,6 @@ private void drawOverlay(Overlay overlay, Graphics g) {
301300
if (labelColor==null) labelColor = Color.white;
302301
initGraphics(overlay, g, labelColor, Roi.getColor());
303302
int n = overlay.size();
304-
//if (IJ.debugMode) IJ.log("drawOverlay: "+n);
305303
int currentImage = imp!=null?imp.getCurrentSlice():-1;
306304
int stackSize = imp.getStackSize();
307305
if (stackSize==1)
@@ -338,14 +336,13 @@ private void drawOverlay(Overlay overlay, Graphics g) {
338336
int t = roi.getTPosition();
339337
if (hyperstack) {
340338
int position = roi.getPosition();
341-
//IJ.log(c+" "+z+" "+t+" "+channel+" "+position+" "+roiManagerShowAllMode);
342339
if (position>0) {
343340
if (z==0 && imp.getNSlices()>1)
344341
z = position;
345342
else if (t==0)
346343
t = position;
347344
}
348-
//IJ.log("drawOverlay: i="+i+", pos="+roi.getPosition());
345+
//IJ.log("drawOverlay: i="+i+", pos="+roi.getPosition()+" "+c+" "+z+" "+t);
349346
if (((c==0||c==channel) && (z==0||z==slice) && (t==0||t==frame)) || roiManagerShowAllMode || position == PointRoi.POINTWISE_POSITION)
350347
drawRoi(g, roi, drawLabels?i+LIST_OFFSET:-1);
351348
} else {
@@ -364,7 +361,6 @@ else if (t==1)
364361
position = 0;
365362
if ((roi instanceof PointRoi) && Prefs.showAllPoints)
366363
position = 0;
367-
//IJ.log("drawOverlay: i="+i+", pos="+roi.getPosition()+", pos2="+position);
368364
if (position==0 || position==currentImage || roiManagerShowAllMode)
369365
drawRoi(g, roi, drawLabels?i+LIST_OFFSET:-1);
370366
}
@@ -496,7 +492,6 @@ void drawRoiLabel(Graphics g, int index, Roi roi) {
496492
} else
497493
labelRects[index] = new Rectangle(x-3, y-h+1, w+4, h);
498494
}
499-
//IJ.log("drawRoiLabel: "+" "+label+" "+x+" "+y+" "+flattening);
500495
g.setColor(labelColor);
501496
g.drawString(label, x+xoffset, y-2+yoffset);
502497
g.setColor(defaultColor);
@@ -743,7 +738,6 @@ void setMagnification2(double magnification) {
743738
/** Resizes the canvas when the user resizes the window. */
744739
void resizeCanvas(int width, int height) {
745740
ImageWindow win = imp.getWindow();
746-
//IJ.log("resizeCanvas: "+srcRect+" "+imageWidth+" "+imageHeight+" "+width+" "+height+" "+dstWidth+" "+dstHeight+" "+win.maxBounds);
747741
if (!maxBoundsReset&& (width>dstWidth||height>dstHeight)&&win!=null&&win.maxBounds!=null&&width!=win.maxBounds.width-10) {
748742
if (resetMaxBoundsCount!=0)
749743
resetMaxBounds(); // Works around problem that prevented window from being larger than maximized size
@@ -768,7 +762,6 @@ void resizeCanvas(int width, int height) {
768762
srcRect.y = imageHeight-srcRect.height;
769763
repaint();
770764
}
771-
//IJ.log("resizeCanvas2: "+srcRect+" "+dstWidth+" "+dstHeight+" "+width+" "+height);
772765
}
773766

774767
public void fitToWindow() {
@@ -870,7 +863,6 @@ public void zoomIn(int sx, int sy) {
870863

871864
/** Centers the viewable area on offscreen (image) coordinates x, y */
872865
void adjustSourceRect(double newMag, int x, int y) {
873-
//IJ.log("adjustSourceRect1: "+newMag+" "+dstWidth+" "+dstHeight);
874866
int w = (int)Math.round(dstWidth/newMag);
875867
if (w*newMag<dstWidth) w++;
876868
int h = (int)Math.round(dstHeight/newMag);
@@ -882,7 +874,6 @@ void adjustSourceRect(double newMag, int x, int y) {
882874
if (r.y+h>imageHeight) r.y = imageHeight-h;
883875
srcRect = r;
884876
setMagnification(newMag);
885-
//IJ.log("adjustSourceRect2: "+srcRect+" "+dstWidth+" "+dstHeight);
886877
}
887878

888879
/** Returns the size to which the window can be enlarged, or null if it can't be enlarged.
@@ -949,12 +940,10 @@ public void zoomOut(int sx, int sy) {
949940
if (newSrcX<0) newSrcX = 0;
950941
if (newSrcY<0) newSrcY = 0;
951942
srcRect = new Rectangle(newSrcX, newSrcY, newSrcWidth, newSrcHeight);
952-
//IJ.log(newMag+" "+srcRect+" "+dstWidth+" "+dstHeight);
953-
int newDstWidth = (int)(srcRect.width*newMag);
943+
int newDstWidth = (int)(srcRect.width*newMag);
954944
int newDstHeight = (int)(srcRect.height*newMag);
955945
setMagnification(newMag);
956946
setMaxBounds();
957-
//IJ.log(newDstWidth+" "+dstWidth+" "+newDstHeight+" "+dstHeight);
958947
if (newDstWidth<dstWidth || newDstHeight<dstHeight) {
959948
setSize(newDstWidth, newDstHeight);
960949
imp.getWindow().pack();
@@ -1034,7 +1023,6 @@ public void zoom100Percent() {
10341023
protected void scroll(int sx, int sy) {
10351024
int ox = xSrcStart + (int)(sx/magnification); //convert to offscreen coordinates
10361025
int oy = ySrcStart + (int)(sy/magnification);
1037-
//IJ.log("scroll: "+ox+" "+oy+" "+xMouseStart+" "+yMouseStart);
10381026
int newx = xSrcStart + (xMouseStart-ox);
10391027
int newy = ySrcStart + (yMouseStart-oy);
10401028
if (newx<0) newx = 0;
@@ -1043,7 +1031,6 @@ protected void scroll(int sx, int sy) {
10431031
if ((newy+srcRect.height)>imageHeight) newy = imageHeight-srcRect.height;
10441032
srcRect.x = newx;
10451033
srcRect.y = newy;
1046-
//IJ.log(sx+" "+sy+" "+newx+" "+newy+" "+srcRect);
10471034
imp.draw();
10481035
Thread.yield();
10491036
}
@@ -1056,7 +1043,6 @@ Color getColor(int index){
10561043
/** Sets the foreground drawing color (or background color if
10571044
'setBackground' is true) to the color of the pixel at (ox,oy). */
10581045
public void setDrawingColor(int ox, int oy, boolean setBackground) {
1059-
//IJ.log("setDrawingColor: "+setBackground+this);
10601046
int type = imp.getType();
10611047
int[] v = imp.getPixel(ox, oy);
10621048
switch (type) {
@@ -1260,7 +1246,6 @@ public void run() {
12601246
&& r2.y==r1.y && r2.width==r1.width && r2.height==r1.height && size2==size1
12611247
&& !(size2>1&&state==Roi.CONSTRUCTING);
12621248
boolean cursorMoved = !getCursorLoc().equals(cursorLoc);
1263-
//IJ.log(size2+" "+empty+" "+unchanged+" "+state+" "+roi1+" "+roi2);
12641249
if ((roi1==null && (size2<=1||empty)) || unchanged) {
12651250
if (roi1==null) imp.deleteRoi();
12661251
if (!cursorMoved && Toolbar.getToolId()!=Toolbar.HAND)
@@ -1355,7 +1340,6 @@ public void mouseDragged(MouseEvent e) {
13551340
yMouse = offScreenY(y);
13561341
flags = e.getModifiers();
13571342
mousePressedX = mousePressedY = -1;
1358-
//IJ.log("mouseDragged: "+flags);
13591343
if (flags==0) // workaround for Mac OS 9 bug
13601344
flags = InputEvent.BUTTON1_MASK;
13611345
if (Toolbar.getToolId()==Toolbar.HAND || IJ.spaceBarDown())
@@ -1465,7 +1449,6 @@ else if (e.isAltDown())
14651449
roi.modState = Roi.SUBTRACT_FROM_ROI;
14661450
else
14671451
roi.modState = Roi.NO_MODS;
1468-
//IJ.log("setRoiModState: "+roi.modState+" "+ roi.state);
14691452
}
14701453

14711454
/** Disable/enable popup menu. */
@@ -1670,7 +1653,6 @@ private boolean activateOverlayRoi(int ox, int oy) {
16701653
Roi roi = o.get(i);
16711654
if (roi==null)
16721655
continue;
1673-
//IJ.log(".isAltDown: "+roi.contains(ox, oy));
16741656
boolean containsMousePoint = false;
16751657
if (roi instanceof Line) { //grab line roi near its center
16761658
double grabLineWidth = 1.1 + 5./magnification;

ij/gui/PointRoi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ private synchronized void incrementCounter(ImagePlus imp) {
421421
}
422422
counters[nPoints-1] = (short)counter;
423423
if (imp!=null)
424-
positions[nPoints-1] = imp.getStackSize()>1 ? imp.getCurrentSlice() : 0;
424+
positions[nPoints-1] = imp.getStackSize()>1 ? imp.getCurrentSlice() : 0;
425425
}
426426
if (rt!=null && WindowManager.getFrame(getCountsTitle())!=null)
427427
displayCounts();
@@ -725,9 +725,9 @@ public void setPosition(int n) {
725725
if (n != POINTWISE_POSITION)
726726
Arrays.fill(positions, n);
727727
}
728-
super.setPosition(0);
728+
super.setPosition(nPoints>1?0:n);
729729
}
730-
730+
731731
/** Returns the stack position (image number) of the points in this Roi, if
732732
* all points have the same position. Returns 0 if none of the points is
733733
* associated with a particular stack image, and PointRoi.POINTWISE_POSITION = -2
@@ -738,7 +738,7 @@ public int getPosition() {
738738
if (positions==null || nPoints<1)
739739
position = 0;
740740
else if (nPoints==1)
741-
position = super.getPosition();
741+
return super.getPosition();
742742
else {
743743
position = positions[0];
744744
for (int i=1; i<nPoints; i++) {

ij/gui/PolygonRoi.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,6 @@ void updateClipRectAndDraw() {
690690
}
691691

692692
protected void resetBoundingRect() {
693-
//IJ.log("resetBoundingRect");
694693
if (xpf!=null) {
695694
resetSubPixelBoundingRect();
696695
xp = toInt(xpf, xp, nPoints);
@@ -715,7 +714,6 @@ protected void resetBoundingRect() {
715714
for (int i=0; i<nPoints; i++)
716715
yp[i] -= ymin;
717716
}
718-
//IJ.log("reset: "+ymin+" "+before+" "+yp[0]);
719717
x+=xmin; y+=ymin;
720718
width=xmax-xmin; height=ymax-ymin;
721719
if (useLineSubpixelConvention()) {
@@ -725,7 +723,6 @@ protected void resetBoundingRect() {
725723
}
726724

727725
private void resetSubPixelBoundingRect() {
728-
//IJ.log("resetSubPixelBoundingRect: "+state+" "+bounds);
729726
if (xSpline!=null) {
730727
resetSplineFitBoundingRect();
731728
return;
@@ -946,11 +943,8 @@ void setSpline(float[] xSpline, float[] ySpline) {
946943
* points remains unchanged.
947944
* @return Arrays of x coordinates and y coordinates */
948945
float[][] getSpline(int evaluationPoints, float[] xSpline, float[] ySpline) {
949-
if (xpf==null) {
950-
xpf = toFloat(xp);
951-
ypf = toFloat(yp);
946+
if (xpf==null)
952947
enableSubPixelResolution();
953-
}
954948
if (xSpline==null || xSpline.length!=evaluationPoints)
955949
xSpline = new float[evaluationPoints];
956950
if (ySpline==null || ySpline.length!=evaluationPoints)
@@ -1065,7 +1059,6 @@ static float[][] getEquidistantPoints(float[] xpoints, float[] ypoints, int npoi
10651059
while ((distanceOverNextWrite >= 0.0 || i==npoints-1) && pointsWritten < npOut) { // we have to write a new point
10661060
double fractionOverNextWrite = distanceOverNextWrite/distance;
10671061
if (distance==0) fractionOverNextWrite = 0;
1068-
//IJ.log("i="+i+" n="+pointsWritten+"/"+npOut+" leng="+IJ.d2s(lengthRead)+"/"+IJ.d2s(length)+" done="+IJ.d2s(pointsWritten*step)+" over="+IJ.d2s(fractionOverNextWrite)+" x,y="+IJ.d2s(x2 - fractionOverNextWrite*dx)+","+IJ.d2s(y2 - fractionOverNextWrite*dy));
10691062
xpOut[pointsWritten] = (float)(x2 - fractionOverNextWrite*dx);
10701063
ypOut[pointsWritten] = (float)(y2 - fractionOverNextWrite*dy);
10711064
distanceOverNextWrite -= step;

ij/plugin/OverlayCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void addImage(boolean createImageRoi) {
251251
}
252252

253253
private void setPosition(ImagePlus imp, Roi roi) {
254-
//IJ.log("Overlay.setPosition: "+roi.size());
254+
//IJ.log("Overlay.setPosition: "+roi+" "+roi.getPositionAsString()+" "+roi.hasHyperStackPosition());
255255
if (roi instanceof PointRoi && roi.size()>1)
256256
return;
257257
int stackSize = imp.getStackSize();

ij/plugin/Selection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ void fitSpline() {
245245
if (roi instanceof EllipseRoi)
246246
return;
247247
PolygonRoi p = (PolygonRoi)roi;
248+
p = (PolygonRoi)p.clone();
248249
Undo.setup(Undo.ROI, imp);
249250
if (!segmentedSelection && p.getNCoordinates()>3) {
250251
if (p.subPixelResolution())
@@ -259,6 +260,7 @@ else if (options!=null && options.indexOf("remove")!=-1)
259260
p.removeSplineFit();
260261
else
261262
p.fitSpline();
263+
imp.setRoi(p);
262264
imp.draw();
263265
LineWidthAdjuster.update();
264266
}
@@ -344,7 +346,6 @@ PolygonRoi trimPolygon(PolygonRoi roi, double length) {
344346
float[] curvature = getCurvature(x, y, n);
345347
Rectangle r = roi.getBounds();
346348
double threshold = rodbard(length);
347-
//IJ.log("trim: "+length+" "+threshold);
348349
double distance = Math.sqrt((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]));
349350
x[0] += r.x; y[0]+=r.y;
350351
int i2 = 1;
@@ -465,7 +466,6 @@ PolygonRoi trimFloatPolygon(PolygonRoi roi, double length) {
465466
y = smooth(y, n);
466467
float[] curvature = getCurvature(x, y, n);
467468
double threshold = rodbard(length);
468-
//IJ.log("trim: "+length+" "+threshold);
469469
double distance = Math.sqrt((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]));
470470
int i2 = 1;
471471
double x1,y1,x2=0,y2=0;

release-notes.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
</head>
66
<body>
77

8-
<li> <u>1.54r2 5 September 2025</u>
9-
<ul> Fixed several bugs with displaying and positioning
8+
<li> <u>1.54r6 18 September 2025</u>
9+
<ul>
10+
<li>Fixed several bugs with displaying and positioning
1011
point selections in the ROI Manager and in overlays.
12+
<li> Thanks to Matthieu Vermeren, fixed bug where Fit Spline
13+
fails with ROIs in ROI Manager or overlays
14+
(<a href="http://wsr.imagej.net/macros/bugs/FitSpline.ijm">example</a>).
1115
</ul>
1216

1317
<li> <u>1.54q 2 September 2025</u>

0 commit comments

Comments
 (0)