Login  Register

Problem converting HSB stack to separate images

Posted by gibberfish on Feb 19, 2011; 3:25pm
URL: http://imagej.273.s1.nabble.com/Problem-converting-HSB-stack-to-separate-images-tp3685613.html

Hello,

I want to threshold an image based on peaks in the HSB histograms. For this I plan using the Color Thresholding plugin, feeding it the threshold values I calculated. To calculate these values, I want to convert the RGB image to an HSB stack, and then read the histogram values from each image in the stack.

I can convert to an HSB, stack fine, but converting the stack to images doesn't seem to work. When executing the command, I always get an error saying "Convert Stack to Images" requires a stack.

Here's my code:

        ImagePlus image = IJ.getImage();
        ImageConverter ic = new ImageConverter(image);
        ic.convertToHSB();
               
        StackEditor se = new StackEditor();
        se.convertStackToImages(image); //<---- problem line
       
        IJ.selectWindow("Hue");
        ImagePlus hue = IJ.getImage();
        int[] hueHist = hue.getStatistics().histogram;

        IJ.selectWindow("Saturation");
        ImagePlus sat = IJ.getImage();
        int[] satHist = sat.getStatistics().histogram;

 So it seems the ImagePlus object isn't the right one. Manually selecting the stack in ImageJ and running the plugin works fine. Any idea how I might fix this?