Skip to content

Commit

Permalink
2024.10.28 (1.54m16; Histogram bin width)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Oct 28, 2024
1 parent 6542086 commit c80f6ef
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 24 deletions.
1 change: 1 addition & 0 deletions ij/IJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -2574,6 +2574,7 @@ public static void protectStatusBar(boolean protect) {
statusBarThread = null;
}

/** Returns 'true' if the Recorder is running and ImageJ is not in headless mode. */
public static boolean recording() {
return (!GraphicsEnvironment.isHeadless()&&Recorder.record);
}
Expand Down
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.54m";
public static final String BUILD = "12";
public static final String BUILD = "16";
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
8 changes: 4 additions & 4 deletions ij/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ public static String getHomeDir() {
public static String getImageJDir() {
String path = Menus.getImageJPath();
if (path==null) {
String ijPath = getPluginsDirProperty();
//if (ijPath==null)
// ijPath = ImageJDir;
String ijPath = ImageJDir;
if (ijPath==null)
ijPath = getPluginsDirProperty();
if (ijPath==null)
ijPath = System.getProperty("user.dir");
return ijPath + File.separator;
Expand Down Expand Up @@ -442,7 +442,7 @@ public static String getPrefsDir() {

/** Sets the path to the ImageJ directory. */
static void setHomeDir(String path) {
if (path.endsWith(File.separator))
if (path.endsWith(File.separator) || path.endsWith("/"))
path = path.substring(0, path.length()-1);
ImageJDir = path;
}
Expand Down
5 changes: 1 addition & 4 deletions ij/gui/HistogramPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,6 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) {
ip.setAntialiasedText(true);
double hmin = cal.getCValue(stats.histMin);
double hmax = cal.getCValue(stats.histMax);
double range = hmax-hmin;
if (fixedRange&&!cal.calibrated()&&hmin==0&&hmax==255)
range = 256;
ip.drawString(d2s(hmin), x - 4, y);
ip.drawString(d2s(hmax), x + HIST_WIDTH - getWidth(hmax, ip) + 10, y);
if (rgbMode>=INTENSITY1) {
Expand All @@ -307,7 +304,7 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) {
}
ip.setJustification(ImageProcessor.LEFT_JUSTIFY);
}
double binWidth = range/stats.nBins;
double binWidth = (hmax-hmin+1)/stats.nBins;
binWidth = Math.abs(binWidth);
showBins = binWidth!=1.0 || !fixedRange;
col1 = XMARGIN + 5;
Expand Down
5 changes: 1 addition & 4 deletions ij/gui/HistogramWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,6 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) {
ip.setAntialiasedText(true);
double hmin = cal.getCValue(stats.histMin);
double hmax = cal.getCValue(stats.histMax);
double range = hmax-hmin;
if (fixedRange&&!cal.calibrated()&&hmin==0&&hmax==255)
range = 256;
ip.drawString(d2s(hmin), x - 4, y);
ip.drawString(d2s(hmax), x + HIST_WIDTH - getWidth(hmax, ip) + 10, y);
if (rgbMode>=INTENSITY1) {
Expand All @@ -443,7 +440,7 @@ void drawText(ImageProcessor ip, int x, int y, boolean fixedRange) {
}
ip.setJustification(ImageProcessor.LEFT_JUSTIFY);
}
double binWidth = range/stats.nBins;
double binWidth = (hmax-hmin+1)/stats.nBins;
binWidth = Math.abs(binWidth);
showBins = binWidth!=1.0 || !fixedRange;
col1 = XMARGIN + 5;
Expand Down
1 change: 1 addition & 0 deletions ij/macro/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,7 @@ void makeSelection() {
} else if (name.equals("drawShapes")) {
return drawShapes();
} else if (name.equals("drawGrid")) {
interp.getParens();
plot.drawShapes("redraw_grid", null);
return Double.NaN;
} else if (name.startsWith("setLineWidth")) {
Expand Down
23 changes: 23 additions & 0 deletions ij/measure/ResultsTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,29 @@ public ImageProcessor getTableAsImage() {
return fp;
}

/** Creates a ResultsTable from an image or image selection. */
public static ResultsTable createTableFromImage(ImagePlus imp) {
if (imp==null)
return null;
Roi roi = imp.getRoi();
ImageProcessor ip = imp.getProcessor();
if (roi==null || roi.getType()==Roi.RECTANGLE)
return createTableFromImage(ip);
ResultsTable rt = new ResultsTable();
Rectangle r = ip.getRoi();
for (int y=r.y; y<r.y+r.height; y++) {
rt.incrementCounter();
rt.addLabel(" ", "Y"+y);
for (int x=r.x; x<r.x+r.width; x++) {
if (roi.contains(x,y))
rt.addValue("X"+x, ip.getPixelValue(x,y));
else
rt.addValue("X"+x, Double.NaN);
}
}
return rt;
}

/** Creates a ResultsTable from an image or image selection. */
public static ResultsTable createTableFromImage(ImageProcessor ip) {
ResultsTable rt = new ResultsTable();
Expand Down
7 changes: 3 additions & 4 deletions ij/plugin/SimpleCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ private void removeStackLabels() {
}

private void imageToResults() {
ImagePlus imp = IJ.getImage();
ImageProcessor ip = imp.getProcessor();
ResultsTable rt = ResultsTable.createTableFromImage(ip);
rt.show("Results");
ResultsTable rt = ResultsTable.createTableFromImage(IJ.getImage());
if (rt!=null)
rt.show("Results");
}

private void resultsToImage() {
Expand Down
2 changes: 1 addition & 1 deletion ij/process/ColorStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void getIntStatistics(ImageProcessor ip) {
}
}
min = roiMin; max = roiMax;
binSize = (max-min)/nBins;
binSize = (max-min+1)/nBins;
histMin = min;
histMax = max;

Expand Down
2 changes: 1 addition & 1 deletion ij/process/FloatStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void getStatistics(ImageProcessor ip, double minThreshold, double maxThreshold)
if (max>histMax)
max = histMax;
}
binSize = (histMax-histMin)/nBins;
binSize = (histMax-histMin+1)/nBins;

// Generate histogram
double scale = nBins/(histMax-histMin);
Expand Down
2 changes: 1 addition & 1 deletion ij/process/ShortStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void getStatistics(ImageProcessor ip, int[] hist, int min, int max, float[] cTab
if (min<histMin) min = (int)histMin;
if (max>histMax) max = (int)histMax;
}
binSize = (histMax-histMin)/nBins;
binSize = (histMax-histMin+1)/nBins;
double scale = 1.0/binSize;
int hMin = (int)histMin;
histogram = new int[nBins]; // 256 bin histogram
Expand Down
4 changes: 2 additions & 2 deletions ij/process/StackStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void doCalculations(ImagePlus imp, int bins, double histogramMin, double histog
calculateStdDev(longPixelCount, sum, sum2);
histMin = cal.getRawValue(histMin);
histMax = cal.getRawValue(histMax);
binSize = (histMax-histMin)/nBins;
binSize = (histMax-histMin+1)/nBins;
int bits = imp.getBitDepth();
if (histMin==0.0 && histMax==256.0 && (bits==8||bits==24))
histMax = 255.0;
Expand Down Expand Up @@ -297,7 +297,7 @@ void get16BitStatistics(long[] hist, int min, int max) {
nBins = 256;
histMin = min;
histMax = max;
binSize = (histMax-histMin)/nBins;
binSize = (histMax-histMin+1)/nBins;
double scale = 1.0/binSize;
int hMin = (int)histMin;
longHistogram = new long[nBins]; // 256 bin histogram
Expand Down
13 changes: 11 additions & 2 deletions release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
<body>


<li> <u>1.54m12 17 October 2024</u>
<li> <u>1.54m16 28 October 2024</u>
<ul>
<li> Thanks to 'Patricia' and Herbie Gluender, the
<i>Image&gt;Transform&gt;Image to Results</i> command
now shows NaNs when values are outside non-rectangular
selections.
<li> Thanks to Kevin Terretaz, CommandFinder
(<i>Plugins&gt;Utilities&gt;Find Commands</i>) filtering is more
precise and flexible. It now splits the input into individual words
Expand All @@ -24,7 +28,12 @@
to the image width or vertical lines with a length equal to
the image height.
<li> Thanks to Peter Dodok, fixed bug with recording in
Fiji headless mode
Fiji headless mode.
<li> Thanks to Jerome Mutterer, fixed bug where the -ijpath
command line option is not respected when using the
-batch option.
<li> Thanks to Guenter Pudmich, fixed bug with the calculation
of 16 and 32 bit histogram bin widths.
</ul>

<li> <u>1.54k 15 September 2024</u>
Expand Down

0 comments on commit c80f6ef

Please sign in to comment.