Skip to content

Commit 63544da

Browse files
committed
2024.12.17 (1.54n4; Combine and Straighten)
1 parent 7257bdd commit 63544da

File tree

5 files changed

+80
-7
lines changed

5 files changed

+80
-7
lines changed

ij/ImageJ.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public class ImageJ extends Frame implements ActionListener,
7878
MouseListener, KeyListener, WindowListener, ItemListener, Runnable {
7979

8080
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
81-
public static final String VERSION = "1.54m";
82-
public static final String BUILD = ""; //37
81+
public static final String VERSION = "1.54n";
82+
public static final String BUILD = "4";
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/plugin/StackCombiner.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import ij.*;
33
import ij.process.*;
44
import ij.gui.*;
5+
import ij.io.FileInfo;
56
import java.awt.*;
67

78
/**
@@ -24,14 +25,25 @@ public void run(String arg) {
2425
error();
2526
return;
2627
}
28+
imp1.setDisplayMode(IJ.COLOR);
29+
imp2.setDisplayMode(IJ.COLOR);
30+
if (LUT.LutsDiffer(imp1,imp2)) {
31+
RGBStackConverter.convertToRGB(imp1);
32+
RGBStackConverter.convertToRGB(imp2);
33+
}
2734
int[] dim1 = imp1.getDimensions();
2835
int[] dim2 = imp2.getDimensions();
36+
boolean isHyperStack1 = imp1.isHyperStack() || imp1.isComposite();
37+
boolean isHyperStack2 = imp2.isHyperStack() || imp2.isComposite();
2938
if (imp1.isHyperStack() || imp2.isHyperStack()) {
3039
if (dim1[2]!=dim2[2] || dim1[3]!=dim2[3] || dim1[4]!=dim2[4]) {
3140
IJ.error("StackCombiner", "Hyperstacks must have identical CZT dimensions");
3241
return;
3342
}
3443
}
44+
LUT[] luts = null;
45+
if (imp1.isComposite())
46+
luts = imp1.getLuts();
3547
ImageStack stack1 = imp1.getStack();
3648
ImageStack stack2 = imp2.getStack();
3749
ImageStack stack3 = vertical?combineVertically(stack1, stack2):combineHorizontally(stack1, stack2);
@@ -41,16 +53,19 @@ public void run(String arg) {
4153
imp2.close();
4254
ImagePlus imp3 = imp1.createImagePlus();
4355
imp3.setStack(stack3);
44-
if (imp1.isHyperStack())
56+
if (isHyperStack1)
4557
imp3.setDimensions(dim1[2],dim1[3],dim1[4]);
4658
if (imp1.isComposite()) {
4759
imp3 = new CompositeImage(imp3, imp1.getCompositeMode());
4860
imp3.setDimensions(dim1[2],dim1[3],dim1[4]);
61+
if (luts!=null)
62+
((CompositeImage)imp3).setLuts(luts);
63+
((CompositeImage)imp3).resetDisplayRanges();
4964
}
5065
imp3.setTitle("Combined Stacks");
5166
imp3.show();
5267
}
53-
68+
5469
public ImageStack combineHorizontally(ImageStack stack1, ImageStack stack2) {
5570
int d1 = stack1.getSize();
5671
int d2 = stack2.getSize();

ij/plugin/Straightener.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public void run(String arg) {
2525
int width = (int)Math.round(roi.getStrokeWidth());
2626
boolean isMacro = IJ.macroRunning() && Macro.getOptions()!=null;
2727
int stackSize = imp.getStackSize();
28-
if (stackSize==1) processStack = false;
28+
if (stackSize==1)
29+
processStack = false;
30+
if (imp.isComposite())
31+
processStack = true;
2932
String newTitle = WindowManager.getUniqueName(imp.getTitle());
3033
if (width<=1 || isMacro || stackSize>1) {
3134
if (width<=1) width = 20;
@@ -49,8 +52,21 @@ public void run(String arg) {
4952
ImageProcessor ip2 = null;
5053
ImagePlus imp2 = null;
5154
if (processStack) {
55+
boolean compositeMode = imp.isComposite() && imp.getDisplayMode()==IJ.COMPOSITE;
56+
if (compositeMode)
57+
imp.setDisplayMode(IJ.COLOR);
5258
ImageStack stack2 = straightenStack(imp, roi, width);
5359
imp2 = new ImagePlus(newTitle, stack2);
60+
if (compositeMode)
61+
imp.setDisplayMode(IJ.COMPOSITE);
62+
if (imp.isComposite()) {
63+
ImageConverter.setDoScaling(false);
64+
if (imp.getBitDepth()==8)
65+
new StackConverter(imp2).convertToGray8();
66+
else if (imp.getBitDepth()==16)
67+
new StackConverter(imp2).convertToGray16();
68+
ImageConverter.setDoScaling(true);
69+
}
5470
} else {
5571
ip2 = straighten(imp, roi, width);
5672
imp2 = new ImagePlus(newTitle, ip2);
@@ -61,7 +77,14 @@ public void run(String arg) {
6177
Calibration cal = imp.getCalibration();
6278
if (cal.pixelWidth==cal.pixelHeight)
6379
imp2.setCalibration(cal);
64-
imp2.show();
80+
if (imp.isComposite()) {
81+
LUT[] luts = imp.getLuts();
82+
CompositeImage cImp = new CompositeImage(imp2);
83+
cImp.setLuts(luts);
84+
cImp.setDisplayMode(imp.getDisplayMode());
85+
cImp.show();
86+
} else
87+
imp2.show();
6588
}
6689

6790
public ImageProcessor straighten(ImagePlus imp, Roi roi, int width) {

ij/process/LUT.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package ij.process;
2-
import ij.IJ;
2+
import ij.*;
33
import ij.plugin.Colors;
44
import java.awt.image.*;
55
import java.awt.Color;
@@ -107,5 +107,32 @@ public String toString() {
107107
return "rgb[0]="+Colors.colorToString(new Color(getRGB(0)))+", rgb[255]="
108108
+Colors.colorToString(new Color(getRGB(255)))+", min="+IJ.d2s(min,4)+", max="+IJ.d2s(max,4);
109109
}
110+
111+
/** Returns 'true' if the LUTs of these two images differ. */
112+
public static boolean LutsDiffer(ImagePlus imp1, ImagePlus imp2) {
113+
if (!imp1.isComposite() || !imp2.isComposite())
114+
return false;
115+
LUT[] luts1 = ((CompositeImage)imp1).getLuts();
116+
LUT[] luts2 = ((CompositeImage)imp2).getLuts();
117+
if (luts1==null || luts2==null)
118+
return false;
119+
if (luts1.length!=luts2.length)
120+
return true;
121+
for (int i=0; i<luts1.length; i++) {
122+
if (luts1[i].min!=luts2[i].min)
123+
return true;
124+
if (luts1[i].max!=luts2[i].max)
125+
return true;
126+
byte[] bytes1 = luts1[i].getBytes();
127+
byte[] bytes2 = luts2[i].getBytes();
128+
if (bytes1.length!=bytes2.length)
129+
return true;
130+
for (int j=0; j<bytes1.length; j++) {
131+
if (bytes1[j]!=bytes2[j])
132+
return true;
133+
}
134+
}
135+
return false;
136+
}
110137

111138
}

release-notes.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
<body>
77

88

9+
<li> <u>1.54n4 17 December 2024</u>
10+
<ul>
11+
<li> Thanks to Christophe Leterrier, fixed bugs with how
12+
the <i>Image&gt;Stacks&gt;Tools&gt;Combine</i> and
13+
<i>Edit&gt;Selection&gt;Straighten</i> commands handle
14+
multi-channel images.
15+
</ul>
16+
917
<li> <u>1.54m 5 December 2024</u>
1018
<ul>
1119
<li> Thanks to Michael Cammer, the <i>Orthogonal Views</i> command

0 commit comments

Comments
 (0)