Skip to content

Commit

Permalink
2023.09.02 (1.54g15; ImageProcessor.getSliceNumber)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Sep 2, 2023
1 parent 2e33121 commit 53b0f93
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
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.54g";
public static final String BUILD = "12";
public static final String BUILD = "15";
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
2 changes: 2 additions & 0 deletions ij/ImagePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,8 @@ public synchronized void setSlice(int n) {
updateAndRepaintWindow();
else
img = null;
if (ip!=null)
ip.setSliceNumber(n);
}
}

Expand Down
1 change: 1 addition & 0 deletions ij/ImageStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ else if (stack[n-1] instanceof int[]) {
ip.setMinAndMax(min, max);
if (cTable!=null)
ip.setCalibrationTable(cTable);
ip.setSliceNumber(n);
return ip;
}

Expand Down
1 change: 1 addition & 0 deletions ij/VirtualStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public ImageProcessor getProcessor(int n) {
}
if (cTable!=null)
ip.setCalibrationTable(cTable);
ip.setSliceNumber(n);
return ip;
}

Expand Down
11 changes: 3 additions & 8 deletions ij/gui/ImageWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class ImageWindow extends Frame implements FocusListener, WindowListener,
private static Point nextLocation;
public static long setMenuBarTime;
private int textGap = centerOnScreen?0:TEXT_GAP;
private Point initialLoc;
private int screenHeight, screenWidth;


Expand Down Expand Up @@ -161,7 +160,7 @@ private void setLocationAndSize(boolean updating) {
int width = imp.getWidth();
int height = imp.getHeight();

// load prefernces file location
// load preferences file location
Point loc = Prefs.getLocation(LOC_KEY);
Rectangle bounds = null;
if (loc!=null) {
Expand Down Expand Up @@ -243,10 +242,8 @@ private void setLocationAndSize(boolean updating) {
validate();
} else
pack();
if (!updating) {
if (!updating)
setLocation(x, y);
initialLoc = new Point(x,y);
}
}

Rectangle getMaxWindow(int xloc, int yloc) {
Expand Down Expand Up @@ -455,7 +452,7 @@ else if (d.yesPressed()) {
if (ij!=null && ij.quitting()) // this may help avoid thread deadlocks
return true;
Rectangle bounds = getBounds();
if (initialLoc!=null && !bounds.equals(initialLoc) && !IJ.isMacro()
if (!IJ.isMacro()
&& bounds.y<screenHeight/3 && (bounds.y+bounds.height)<=screenHeight
&& (bounds.x+bounds.width)<=screenWidth) {
Prefs.saveLocation(LOC_KEY, new Point(bounds.x,bounds.y));
Expand Down Expand Up @@ -730,14 +727,12 @@ public static void setNextLocation(int x, int y) {
public void setLocationAndSize(int x, int y, int width, int height) {
setBounds(x, y, width, height);
getCanvas().fitToWindow();
initialLoc = null;
pack();
}

@Override
public void setLocation(int x, int y) {
super.setLocation(x, y);
initialLoc = null;
}

public void setSliderHeight(int height) {
Expand Down
1 change: 1 addition & 0 deletions ij/gui/PlotVirtualStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public ImageProcessor getProcessor(int n) {
ip = ip.convertToRGB();
else if (bitDepth==8)
ip = ip.convertToByte(false);
ip.setSliceNumber(n);
return ip;
} catch (Exception e) {
IJ.handleException(e);
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/PointRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ public Point[] getContainedPoints() {
FloatPolygon p = getFloatPolygon();
Point[] points = new Point[p.npoints];
for (int i=0; i<p.npoints; i++)
points[i] = new Point((int) Math.round(p.xpoints[i] - 0.5f), (int) Math.round(p.ypoints[i] - 0.5f));
points[i] = new Point((int) Math.round(p.xpoints[i]), (int) Math.round(p.ypoints[i]));
return points;
}

Expand Down
4 changes: 4 additions & 0 deletions ij/io/Opener.java
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,10 @@ public int getFileType(String path) {
int b0=buf[0]&255, b1=buf[1]&255, b2=buf[2]&255, b3=buf[3]&255;
//IJ.log("getFileType: "+ name+" "+b0+" "+b1+" "+b2+" "+b3);

// ImspectorPro MSR
if (name.endsWith(".msr")||name.endsWith(".MSR"))
return UNKNOWN; // Open with Bio-formats plugin

// Combined TIFF and DICOM created by GE Senographe scanners
if (buf[128]==68 && buf[129]==73 && buf[130]==67 && buf[131]==77
&& ((b0==73 && b1==73)||(b0==77 && b1==77)))
Expand Down
10 changes: 7 additions & 3 deletions ij/plugin/AVI_Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,16 @@ public synchronized ImageProcessor getProcessor(int n) {
closeFile(rFile);
}
if (pixels == null) return null; //failed
ImageProcessor ip = null;
if (pixels instanceof byte[])
return new ByteProcessor(dwWidth, biHeight, (byte[])pixels, cm);
ip = new ByteProcessor(dwWidth, biHeight, (byte[])pixels, cm);
else if (pixels instanceof short[])
return new ShortProcessor(dwWidth, biHeight, (short[])pixels, cm);
ip = new ShortProcessor(dwWidth, biHeight, (short[])pixels, cm);
else
return new ColorProcessor(dwWidth, biHeight, (int[])pixels);
ip = new ColorProcessor(dwWidth, biHeight, (int[])pixels);
if (ip!=null)
ip.setSliceNumber(n);
return ip;
}

/** Returns the image width of the virtual stack */
Expand Down
4 changes: 2 additions & 2 deletions ij/plugin/Concatenator.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public static ImagePlus run(ImagePlus img1, ImagePlus img2, ImagePlus img3) {
/** Concatenates four images, stacks or hyperstacks. */
public static ImagePlus run(ImagePlus img1, ImagePlus img2, ImagePlus img3, ImagePlus img4) {
ImagePlus[] images = new ImagePlus[4];
images[0]=img1; images[1]=img2; images[2]=img3; images[2]=img4;
images[0]=img1; images[1]=img2; images[2]=img3; images[3]=img4;
return (new Concatenator()).concatenate(images, false);
}

/** Concatenates five images, stacks or hyperstacks. */
public static ImagePlus run(ImagePlus img1, ImagePlus img2, ImagePlus img3, ImagePlus img4, ImagePlus img5) {
ImagePlus[] images = new ImagePlus[5];
images[0]=img1; images[1]=img2; images[2]=img3; images[2]=img4; images[5]=img5;
images[0]=img1; images[1]=img2; images[2]=img3; images[3]=img4; images[4]=img5;
return (new Concatenator()).concatenate(images, false);
}

Expand Down
1 change: 1 addition & 0 deletions ij/plugin/FileInfoVirtualStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public ImageProcessor getProcessor(int n) {
if (ip!=null) {
if (cTable!=null)
ip.setCalibrationTable(cTable);
ip.setSliceNumber(n);
return ip;
} else {
int w=getWidth(), h=getHeight();
Expand Down
2 changes: 2 additions & 0 deletions ij/plugin/ListVirtualStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public ImageProcessor getProcessor(int n) {
IJ.redirectErrorMessages(false);
if (imp2!=null)
imp2.setFileInfo(imp.getOriginalFileInfo());
ip.setSliceNumber(n);
return ip;
} else {
ImageProcessor ip = null;
Expand All @@ -174,6 +175,7 @@ public ImageProcessor getProcessor(int n) {
case 32: ip=new FloatProcessor(imageWidth,imageHeight); break;
}
IJ.redirectErrorMessages(false);
ip.setSliceNumber(n);
return ip;
}
}
Expand Down
3 changes: 2 additions & 1 deletion ij/plugin/filter/PlugInFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ the image data converted to a FloatProcessor (3 times per
this method and unlock it when the filter is finished.
For PlugInFilters specifying the {@link #NO_IMAGE_REQUIRED} flag
and not the {@link #DONE} flag, run(ip) is called once with the
argument <code>null</code>.
argument <code>null</code>. Use ip.getSliceNumber()
to get the stack position (1-n).
*/
public void run(ImageProcessor ip);

Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/filter/PlugInFilterRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private void announceSliceNumber(int slice) {
public int getSliceNumber() {
synchronized(sliceForThread){
Integer number = (Integer)sliceForThread.get(Thread.currentThread());
return (number == null) ? -1 : number.intValue();
return (number==null) ? -1 : number.intValue();
}
}

Expand Down
10 changes: 6 additions & 4 deletions ij/process/FloatPolygon.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
import java.awt.geom.Rectangle2D;

/** Used by the Roi classes to return float coordinate arrays and to
determine if a point is inside or outside of spline fitted selections. */
determine if a point is inside or outside of spline fitted selections.
Use the public 'xpoints' and 'ypoints' fields to access the coordinates
and the 'npoints' field to determine the number of points. */
public class FloatPolygon {
private Rectangle bounds;
private float minX, minY, maxX, maxY;

/** The number of points. */
/** The number of points in the 'xpoints' and 'ypoints' arrays. */
public int npoints;

/* The array of x coordinates. */
/* An array containing 'npoints' x coordinates. */
public float xpoints[];

/* The array of y coordinates. */
/* An array containing 'npoints' y coordinates. */
public float ypoints[];

/** Constructs an empty FloatPolygon. */
Expand Down
5 changes: 3 additions & 2 deletions ij/process/ImageProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2877,15 +2877,16 @@ public void applyMacro(String macro) {
ij.plugin.filter.ImageMath.applyMacro(this, macro, false);
}

/* Returns the PlugInFilter slice number. */
/** Returns the stack position (1-n) of this image. */
public int getSliceNumber() {
if (sliceNumber<1)
return 1;
else
return sliceNumber;
}

/** PlugInFilterRunner uses this method to set the slice number. */
/** ImagePlus.setStack() and the PlugInFilterRunner
use this method to set the stack position. */
public void setSliceNumber(int slice) {
sliceNumber = slice;
}
Expand Down
8 changes: 7 additions & 1 deletion release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</head>
<body>

<li> <u>1.54g12 12 August 2023</u>
<li> <u>1.54g15 02 September 2023</u>
<ul>
<li> Thanks to Nicolas De Francesco and Curtis Rueden,
the macro language documentation (functions.html) is now included
Expand All @@ -14,6 +14,8 @@
<li> Thanks to Robert Baer, the “Associate ’Show All’ ROIs with slices”
option in the ROI Manager’s More&gt;&gt;Options dialog is now always
enabled when ImageJ starts up.
<li> Thanks to Fred Damen and Michael Schmid, the ImageProcessor.getSliceNumber()
method no long requires a PlugInFilter to return the stack position.
<li> Thanks to 'Phiir42', fixed bug with closed tables reopening after
a macro finishes.
<li> Thanks to 'Ender', fixed headless mode "Scale Bar" and "Show Info" bugs.
Expand All @@ -24,8 +26,12 @@
RotatedRectRoi rounding bug and a bug where the resulting polygon consisted
of 5 points instead of 4.
<li> Thanks to Volker Backer, fixed a Roi group bug with Fiji on Linux.
<li> Thanks to Yuekan Jiao and Michael Schmid, fixed a rounding error with
PointRoi.getContainedPoints().
<li> Thanks to Guenter Pudmich, fixed a 1.54d regression that caused 16-bit
grayscale PNGs to be opened incorrectly.
<li> Thanks to Saleh Altahini, fixed bug with opening ImspectorPro MSR files
using Bio-Formats.
</ul>

<li> <u>1.54f 29 June 2023</u>
Expand Down

0 comments on commit 53b0f93

Please sign in to comment.