Skip to content

Commit

Permalink
2024.02.24 (1.54i21; Clear Outside)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Feb 24, 2024
1 parent 5910a5b commit efe000b
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 55 deletions.
8 changes: 4 additions & 4 deletions functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ <h1>Built-in Macro Functions</h1>

<a name="ext"></a>
<a name="Ext"></a>
<b>Ext (Macro Extension) Functions</b><br>
<b>Ext (Macro Extension) Functions</b><br>
These are functions that have been added to the macro language by plugins using
the MacroExtension interface. The
<a href="https://imagej.net/ij/plugins/5d-extensions.html">Image5D_Extensions</a>
Expand Down Expand Up @@ -2901,7 +2901,7 @@ <h1>Built-in Macro Functions</h1>

</blockquote>

<b> P </b><a name="P"><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<b> P </b><a name="P"><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name="parseFloat"></a>
<b>parseFloat(string)</b><br>
Converts the string argument to a number and returns it. Returns NaN (Not a Number) if the
Expand Down Expand Up @@ -3748,7 +3748,7 @@ <h1>Built-in Macro Functions</h1>

</blockquote>

<b>ROI Manager Functions</b><br>
<b>ROI Manager Functions</b><br>
These function run ROI Manager commands.
The ROI Manager is opened if it is not already open.
Use <i>roiManager("reset")</i> to delete all ROIs on the list.
Expand Down Expand Up @@ -5429,7 +5429,7 @@ <h1>Built-in Macro Functions</h1>

<p class=navbar> <a href="#Top">top</a> | <a href="https://imagej.nih.gov/ij/index.html">home</a></p>

<small>Last updated 2023/10/29</small>
<small>Last updated 2024/02/22</small>

</body>
</html>
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.54i";
public static final String BUILD = "12";
public static final String BUILD = "21";
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
10 changes: 10 additions & 0 deletions ij/gui/GenericDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,8 @@ public double getNextNumber() {
if (theText.equals(originalText)) {
value = defaultValue;
if (smartRecording) skipRecording=true;
} else if (theText.startsWith("0x")) {
value = parseHex(theText.substring(2));
} else {
Double d = getValue(theText);
if (d!=null)
Expand Down Expand Up @@ -1230,6 +1232,14 @@ public double getNextNumber() {
nfIndex++;
return value;
}

int parseHex(String hexString) {
int n = 0;;
try {
n = Integer.parseInt(hexString, 16);
} catch (NumberFormatException e) {}
return n;
}

private String trim(String value) {
if (value.endsWith(".0"))
Expand Down
4 changes: 3 additions & 1 deletion ij/gui/StackWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,15 @@ public void mouseWheelMoved(MouseWheelEvent e) {
synchronized(this) {
int rotation = e.getWheelRotation();
boolean ctrl = (e.getModifiers()&Event.CTRL_MASK)!=0;
if (hyperStack) // ctrl+scroll wheel adjusts hyperstack slice positions
ctrl = false;
if ((ctrl||IJ.shiftKeyDown()) && ic!=null) {
Point loc = ic.getCursorLoc();
int x = ic.screenX(loc.x);
int y = ic.screenY(loc.y);
if (rotation<0)
ic.zoomIn(x,y);
else
else if (rotation>0)
ic.zoomOut(x,y);
return;
}
Expand Down
3 changes: 3 additions & 0 deletions ij/gui/Toolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,9 @@ public static void setForegroundColor(Color c) {
}
ColorPicker.update();
if (!IJ.isMacro()) setRoiColor(c);
ImagePlus imp = WindowManager.getCurrentImage();
if (imp!=null)
imp.getProcessor().setFillValueSet(false);
}

public static Color getBackgroundColor() {
Expand Down
11 changes: 6 additions & 5 deletions ij/macro/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ void setColor() {
if (overlayPath!=null)
addDrawingToOverlay(imp);
getProcessor().setColor(globalColor);
getProcessor().setFillValueSet(true);
}
interp.getRightParen();
return;
Expand All @@ -785,8 +786,10 @@ void setColor() {
if (red>255) red=255; if (green>255) green=255; if (blue>255) blue=255;
globalColor = new Color(red, green, blue);
globalValue = Double.NaN;
if (WindowManager.getCurrentImage()!=null)
if (WindowManager.getCurrentImage()!=null) {
getProcessor().setColor(globalColor);
getProcessor().setFillValueSet(true);
}
}

void setColor(double value) {
Expand Down Expand Up @@ -4261,11 +4264,9 @@ String getMetadata() {
type = imp.getStackSize()>1?"label":"info";
}
String metadata = null;
if (type.contains("info")) {
if (type.contains("info"))
metadata = (String)imp.getProperty("Info");
if (metadata==null && imp.getStackSize()>1)
metadata = imp.getStack().getSliceLabel(imp.getCurrentSlice());
} else
else
metadata = imp.getStack().getSliceLabel(imp.getCurrentSlice());
if (metadata==null)
metadata = "";
Expand Down
2 changes: 2 additions & 0 deletions ij/plugin/MontageMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public void run(String arg) {
return;
}
hyperstack = imp.isHyperStack();
if (imp.getNChannels()==1)
hyperstack = false;
if (hyperstack && imp.getNSlices()>1 && imp.getNFrames()>1) {
error("5D hyperstacks are not supported");
return;
Expand Down
32 changes: 4 additions & 28 deletions ij/plugin/filter/Filler.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,34 +212,10 @@ public synchronized void clearOutside(ImageProcessor ip) {
IJ.error("\"Clear Outside\" does not work with line selections.");
return;
}
sliceCount++;
Rectangle r = ip.getRoi();
if (mask==null)
makeMask(ip, r);
ip.setGlobalBackgroundColor();
int stackSize = imp.getStackSize();
if (stackSize>1)
ip.snapshot();
ip.fill();
ip.reset(mask);
int width = ip.getWidth();
int height = ip.getHeight();
ip.setRoi(0, 0, r.x, height);
ip.fill();
ip.setRoi(r.x, 0, r.width, r.y);
ip.fill();
ip.setRoi(r.x, r.y+r.height, r.width, height-(r.y+r.height));
ip.fill();
ip.setRoi(r.x+r.width, 0, width-(r.x+r.width), height);
ip.fill();
ip.setRoi(r); // restore original ROI
if (sliceCount==stackSize) {
ip.setGlobalForegroundColor();
Roi roi = imp.getRoi();
imp.deleteRoi();
imp.updateAndDraw();
imp.setRoi(roi);
}
double fgValue = ip.getForegroundValue();
ip.setGlobalBackgroundColor();
ip.fillOutside(imp.getRoi());
ip.setValue(fgValue);
}

public void makeMask(ImageProcessor ip, Rectangle r) {
Expand Down
1 change: 0 additions & 1 deletion ij/plugin/frame/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ else if (getTitle().endsWith(".py"))
text2 = text2.replaceAll("\u201D", "\"");
ta.setText(text2);
}
changes = true;
checkForCurlyQuotes = false;
}
currentMacroEditor = this;
Expand Down
2 changes: 0 additions & 2 deletions ij/process/ByteProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ public float getPixelValue(int x, int y) {
public void setColor(Color color) {
drawingColor = color;
fgColor = getBestIndex(color);
fillValueSet = true;
}

/** Sets the background fill/draw color. */
Expand All @@ -337,7 +336,6 @@ public void setValue(double value) {
fgColor = (int)value;
if (fgColor<0) fgColor = 0;
if (fgColor>255) fgColor = 255;
fillValueSet = true;
}

/** Returns the foreground fill/draw value. */
Expand Down
10 changes: 7 additions & 3 deletions ij/process/ColorProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public Color getColor(int x, int y) {
public void setColor(Color color) {
fgColor = color.getRGB();
drawingColor = color;
fillValueSet = true;
}

/** Sets the background fill/draw color. */
Expand All @@ -124,13 +123,11 @@ public void setBackgroundColor(Color color) {
/** Sets the fill/draw color, where <code>color</code> is an RGB int. */
public void setColor(int color) {
fgColor = color;
fillValueSet = true;
}

/** Sets the default fill/draw value, where <code>value</code> is interpreted as an RGB int. */
public void setValue(double value) {
fgColor = (int)value;
fillValueSet = true;
}

/** Returns the foreground fill/draw value. */
Expand Down Expand Up @@ -316,6 +313,13 @@ public final int get(int index) {
public final void set(int index, int value) {
pixels[index] = value;
}

public void set(double value) {
int saveColor = fgColor;
fgColor = (int)value;
fill();
fgColor = saveColor;
}

public final float getf(int x, int y) {
return pixels[y*width+x];
Expand Down
2 changes: 0 additions & 2 deletions ij/process/FloatProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,6 @@ public void setColor(Color color) {
fillColor = 0f;
else
fillColor = (float)(getMin() + (getMax()-getMin())*(bestIndex/255.0));
fillValueSet = true;
}

/** Sets the background fill/draw color. */
Expand All @@ -1040,7 +1039,6 @@ public void setBackgroundColor(Color color) {
/** Sets the default fill/draw value. */
public void setValue(double value) {
fillColor = (float)value;
fillValueSet = true;
}

/** Returns the foreground fill/draw value. */
Expand Down
7 changes: 6 additions & 1 deletion ij/process/ImageProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public void setColor(double value) {
/** Returns the default fill/draw value. */
public abstract double getForegroundValue();

/** Returns 'true' if the fill/draw value has been set. */
/** Returns 'true' if the fill/draw value has been set in a macro. */
public boolean fillValueSet() {
return fillValueSet;
}
Expand Down Expand Up @@ -2972,4 +2972,9 @@ protected static IndexColorModel getThresholdColorModel(byte[]reds, byte[] green
return new IndexColorModel(8, 256, r, g, b);
}

/** For internal use */
public void setFillValueSet(boolean set) {
fillValueSet = set;
}

}
8 changes: 3 additions & 5 deletions ij/process/ShortProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,6 @@ public void setColor(Color color) {
setValue(0.0);
} else
fgColor = (int)(getMin() + (getMax()-getMin())*(bestIndex/255.0));
fillValueSet = true;
}

/** Sets the background fill/draw color. */
Expand All @@ -1009,10 +1008,9 @@ public void setBackgroundColor(Color color) {

/** Sets the default fill/draw value, where 0<=value<=65535). */
public void setValue(double value) {
fgColor = (int)value;
if (fgColor<0) fgColor = 0;
if (fgColor>65535) fgColor = 65535;
fillValueSet = true;
fgColor = (int)value;
if (fgColor<0) fgColor = 0;
if (fgColor>65535) fgColor = 65535;
}

/** Returns the foreground fill/draw value. */
Expand Down
20 changes: 18 additions & 2 deletions release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
</head>
<body>

<li> <u>1.54i12 05 February 2024</u>
<li> <u>1.54i21 24 February 2024</u>
<ul>
<li> Thanks to Fred Damen, hex notation (e.g., "0xff00ff") can be
used in GenericDialog numeric fields.
<li> Thanks to Christian Tischer, added an “Open grayscale JPEGs as RGB”
option to the <i>Edit&gt;Options&gt;Input/Output</i> dialog and a related
setOption(“OpenGrayscaleJpegsAsRGB”) macro function. DOCUMENT
Expand All @@ -28,9 +30,23 @@
<li> Thanks to Michael Schmid, fixed bug with handling of infinite values
plots.
<li> Thanks to Michael Schmid, fixed bug where recording was silently
turned off when running a multi-threaded plugin.
turned off when running a multi-threaded plugin.
<li> Thanks to Gabriel Landini, fixed bug with <i>Make Montage</i> not working
with one channel hyperstacks.
<li> Thanks to Norbert Vischer, fixed bug (feature?) where the getMetadata("info")
macro function would unexpectedly return the current stack slice label when the
image's "Info" property was null.
<li> Thanks to Philippe Carl, fixed bug with zooming in/out using (ctrl or shift)+scroll wheel
and, with hyperstacks, removed the option to zoom in/out using ctrl+scroll wheel,
allowing this option to be used to set slice positions.
<li> Thanks to Stein Rorvik, fixed bug where calling run("Clear Outside","slice")
set the foreground color to the background color.
<li> Thanks to Fred Damen, fixed bug where the <i>Process&gt;Math&gt;Set</i>
command did not work as expected with RGB images.
<li> Thanks to Norbert Vischer, fixed a v1.54h regression that caused an unexpected
"No particles detected. The threshold may not be correct." message.
<li> Fixed v1.49r regression that caused invalid "Save changes..." dialog after
running macro in the Editor.
</ul>

<li> <u>1.54h 15 December 2023</u>
Expand Down

0 comments on commit efe000b

Please sign in to comment.