Hi Melissa,
IJ.openImage returns an ImagePlus object if successful, null otherwise.
You should check for the return value being null, and terminate if null (maybe with an error message "could not open the image").
Before starting the Duplicator, you should also check whether the dimensions of the stack are large enough for z running up to 26, otherwise it will also fail. See ImagePlus.getDimensions().
Hope this helps,
Michael
________________________________________________________________
On Apr 1, 2012, at 09:10, Melissa Goh wrote:
> Hi,
>
> I am trying to create a macro to automate the image processing:
> 1. Open the image
> 2. Duplicate the stack for one channel
> 3. Apply Gaussian blur
> 4. Auto threshold
> 5. Find edges
> 6. Skeletonize
>
> Here is the macro that I have recorded. However, it gives me error (null
> pointer exception and duplicator error) when running the code.
>
> *public void run(String arg) {
> ImagePlus imp = IJ.openImage(".........");
> imp = new Duplicator().run(imp, 1, 1, 1, 26, 1, 1);
> IJ.run(imp, "Gaussian Blur...", "sigma=20 stack");
> IJ.setAutoThreshold(imp, "Default dark stack");
> IJ.run(imp, "Convert to Mask", " black");
> IJ.run(imp, "Find Edges", "stack");
> IJ.run(imp, "Skeletonize", "stack");
> }
> *
>
> Anyone can tell me what's wrong with the code?
>
> Thanks!
> Melissa