Skip to content

Commit

Permalink
2019.01.25 (1.52k70; Float to 8-bit conversion)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Jan 26, 2019
1 parent a3918aa commit e6c527c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Expand Up @@ -78,7 +78,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.52k";
public static final String BUILD = "66";
public static final String BUILD = "70";
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
6 changes: 5 additions & 1 deletion ij/gui/HistogramWindow.java
Expand Up @@ -96,12 +96,16 @@ public void showHistogram(ImagePlus imp, int bins) {
the same as the image range expect for 32 bit images. */
public void showHistogram(ImagePlus imp, int bins, double histMin, double histMax) {
boolean limitToThreshold = (Analyzer.getMeasurements()&LIMIT)!=0;
ImageProcessor ip = imp.getProcessor();
if (ip.getMinThreshold()!=ImageProcessor.NO_THRESHOLD
&& ip.getLutUpdateMode()==ImageProcessor.NO_LUT_UPDATE)
limitToThreshold = false; // ignore invisible thresholds
if (imp.getBitDepth()==24 && rgbMode<INTENSITY1)
rgbMode=INTENSITY1;
if (rgbMode==RED||rgbMode==GREEN||rgbMode==BLUE) {
int channel = rgbMode - 2;
ColorProcessor cp = (ColorProcessor)imp.getProcessor();
ImageProcessor ip = cp.getChannel(channel, null);
ip = cp.getChannel(channel, null);
ImagePlus imp2 = new ImagePlus("", ip);
imp2.setRoi(imp.getRoi());
stats = imp2.getStatistics(AREA+MEAN+MODE+MIN_MAX, bins, histMin, histMax);
Expand Down
5 changes: 3 additions & 2 deletions ij/plugin/Duplicator.java
Expand Up @@ -193,7 +193,7 @@ public ImagePlus run(ImagePlus imp) {
double max = imp.getDisplayRangeMax();
ImageStack stack2 = null;
int n = stack.getSize();
boolean showProgress = virtualStack || (n*stack.getWidth()*stack.getHeight()>=209715200);
boolean showProgress = virtualStack || ((double)n*stack.getWidth()*stack.getHeight()>=209715200.0);
for (int i=1; i<=n; i++) {
if (showProgress) {
IJ.showStatus("Duplicating: "+i+"/"+n);
Expand Down Expand Up @@ -287,7 +287,7 @@ public ImagePlus run(ImagePlus imp, int firstSlice, int lastSlice) {
double max = imp.getDisplayRangeMax();
ImageStack stack2 = null;
int n = lastSlice-firstSlice+1;
boolean showProgress = virtualStack || (n*stack.getWidth()*stack.getHeight()>=209715200);
boolean showProgress = virtualStack || ((double)n*stack.getWidth()*stack.getHeight()>=209715200.0);
for (int i=firstSlice; i<=lastSlice; i++) {
if (showProgress) {
IJ.showStatus("Duplicating: "+i+"/"+lastSlice);
Expand All @@ -300,6 +300,7 @@ public ImagePlus run(ImagePlus imp, int firstSlice, int lastSlice) {
stack2 = new ImageStack(ip2.getWidth(), ip2.getHeight(), imp.getProcessor().getColorModel());
stack2.addSlice(stack.getSliceLabel(i), ip2);
}
IJ.showProgress(1.0);
ImagePlus imp2 = imp.createImagePlus();
imp2.setStack("DUP_"+imp.getTitle(), stack2);
String info = (String)imp.getProperty("Info");
Expand Down
9 changes: 8 additions & 1 deletion ij/plugin/ImageInfo.java
Expand Up @@ -271,7 +271,14 @@ private String getInfo(ImagePlus imp, ImageProcessor ip) {
lower = cal.getCValue((int)lower);
upper = cal.getCValue((int)upper);
}
s += "Threshold: "+d2s(lower)+"-"+d2s(upper)+uncalibrated+"\n";
int lutMode = ip.getLutUpdateMode();
String mode = "red";
switch (lutMode) {
case ImageProcessor.BLACK_AND_WHITE_LUT: mode="B&W"; break;
case ImageProcessor.NO_LUT_UPDATE: mode="invisible"; break;
case ImageProcessor.OVER_UNDER_LUT: mode="over/under"; break;
}
s += "Threshold: "+d2s(lower)+"-"+d2s(upper)+uncalibrated+" ("+mode+")\n";
}
ImageCanvas ic = imp.getCanvas();
double mag = ic!=null?ic.getMagnification():1.0;
Expand Down
11 changes: 4 additions & 7 deletions ij/process/FloatProcessor.java
Expand Up @@ -178,22 +178,19 @@ public Image createImage() {

// creates 8-bit image by linearly scaling from float to 8-bits
private byte[] create8BitImage(boolean thresholding) {
//ij.IJ.log("create8BitImage: "+thresholding);
int size = width*height;
if (pixels8==null)
pixels8 = new byte[size];
double value;
int ivalue;
double min2 = getMin(), max2=getMax();
int maxValue = 255;
double scale = 256.0/(max2-min2);
if (thresholding) {
maxValue = 254;
scale = 255.0/(max2-min2);
}
double scale = 255.0/(max2-min2);
int maxValue = thresholding?254:255;
for (int i=0; i<size; i++) {
value = pixels[i]-min2;
if (value<0.0) value=0.0;
ivalue = (int)((value*scale)+0.5f);
ivalue = (int)(value*scale);
if (ivalue>maxValue) ivalue = maxValue;
pixels8[i] = (byte)ivalue;
}
Expand Down
9 changes: 8 additions & 1 deletion release-notes.html
Expand Up @@ -5,7 +5,7 @@
</head>
<body>

<li> <u>1.52k66 23 January 2019</u>
<li> <u>1.52k70 25 January 2019</u>
<ul>
<li> Thanks to Albert Cardona and Gabriel Landini, added the "GUI scale (0.5-3.0)"
option to the <i>Edit&gt;Options&gt;Appearance</i> dialog, which enables
Expand Down Expand Up @@ -51,6 +51,10 @@
<li> Thanks to 'Bio7', worked around a bug that caused
toolbar popup menus to not work with OpenJDK 11 and
OpenJDK 12 on Windows.
<li> Thanks to Ved Sharma, fixed a bug that caused the Histogram
command to not behave as expected when "Limit to Threshold" was
enabled in <i>Analyze&gt;Set Measurements</i> and there
was an invisble threshold.
<li> Thanks to J Xiong, fixed a 1.52j regression that caused the
<i>Image&gt;Overlay&gt;From ROI Manager</i> command
to throw an exception.
Expand All @@ -60,6 +64,9 @@
<li> Thanks to Stein Rorvik, fixed 1.52j regression that
sometimes caused macro errors to be ignored
(<a href="http://wsr.imagej.net/macros/MacroErrorsIgnored.txt">examples</a>).
<li> Thanks to 'yorgodillo', 'mountain_man' and Jan Eglinger, fixed a
1.52e regression that caused float to 8-bit conversions to be
done incorrectly.
</ul>

<li> <u>1.52j 29 December 2018</u>
Expand Down

0 comments on commit e6c527c

Please sign in to comment.