@@ -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 ) {
0 commit comments