import ij.*;
import ij.gui.*;
import ij.process.*;
import ij.plugin.frame.*;
import ij.plugin.filter.*;
import java.awt.*;

public class Cell_Segmentation implements PlugInFilter {

  // External
  public ImagePlus  imp;
  public RoiManager roiMgr;

  public int setup(String arg, ImagePlus imp) {
    this.imp = imp;

    // Open ROI Manager
    roiMgr = RoiManager.getInstance();
    if (roiMgr == null)
      roiMgr = new RoiManager();

    return DOES_ALL;
  }

  public void run(ImageProcessor ip) {
    // Put this line to validate
    ip.invert();
  }

}

@@ -189,16 +189,48 @@
 xternal%0A
+  public RoiManager     roiMgr;%0A
   public
@@ -241,16 +241,20 @@
 gePlus  
+    
 imp;%0A  p
@@ -263,25 +263,25 @@
 lic 
-RoiManager roiMgr
+ImageProcessor ip
 ;%0A%0A 
@@ -331,29 +331,8 @@
 ) %7B%0A
-    this.imp = imp;%0A%0A
     
@@ -414,18 +414,16 @@
 = null)%0A
-  
     roiM
@@ -445,16 +445,16 @@
 ager();%0A
+
 %0A    ret
@@ -522,47 +522,245 @@
  // 
-Put this line to validate%0A    ip.invert
+Create a copy in Gray8 format%0A    create_gray8_copy(ip);%0A  %7D%0A%0A  public void create_gray8_copy(ImageProcessor _ip) %7B%0A    ip = _ip.convertToByte(true);%0A    imp = new ImagePlus(%22Cell Segmentation%22, ip);%0A    imp.show();%0A    imp.updateAndDraw
 ();%0A

Create a copy in Gray8 format