merge channels

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

merge channels

Mohamed Tleis
Dear Members,

I am trying to merge three channels; using java code, but it is not
working, I am getting NullPointerException at the line that calls
mergeHyperstacks method.
the commented part works fine, but I have to show the images then and
call IJ.run method. I would prefer to work with the RGBStackMerge class
instead, but there I fail, Can you assist please?

public class mergeChannels {
     private ImagePlus compositeImage;
     private String imagePath;
     private RGBStackMerge stackMerge;
     private ImageStack[] stack;

     public mergeChannels3()
     {    }

     public void mergeThreeChannels(String grayLocation,
                                      String greenLocation,
                                      String yellowLocation)
     {
         ImagePlus grayChannel = new ImagePlus(grayLocation);
         ImagePlus greenChannel = new ImagePlus(greenLocation);
         ImagePlus yellowChannel = new ImagePlus(yellowLocation);
         ImagePlus[] channels = new ImagePlus[7];
         channels[1] = grayChannel;
         channels[3] = greenChannel;
         channels[6] = yellowChannel;


//        grayChannel.show();
//        greenChannel.show();
//        yellowChannel.show();

//        IJ.run( compositeImage, "Merge Channels...",
//                "c2=[" + greenChannel.getTitle() + "] c4=[" +
grayChannel.getTitle()
//                + "] c7=[" + yellowChannel.getTitle() +"] create" );

             compositeImage = stackMerge.mergeHyperstacks(channels, true);

         grayChannel.close();
         greenChannel.close();
         yellowChannel.close();
         IJ.save(compositeImage, "location");

     }

Best Regards,
Moh. Tleis

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html