public Image isolate(Image im, int width, int height, int color)

    {
        // Color:  0 = red,  1 = green,  2 = blue,  3 = alpha
        int pix[] = JIPTUtilities.getPixelArray(im);
        int size  = pix.length;
        for(int i = 0; i < size; i++)
        {

	        int alpha = (pix[i] >> 24) & 0xff;
	        int red   = (pix[i] >> 16) & 0xff;
	        int green = (pix[i] >>  8) & 0xff;
	        int blue  = (pix[i]      ) & 0xff;

            int new_color = 0;

            switch(color)
            {
                case 0 : new_color = red; break;
                case 1 : new_color = green; break;
                case 2 : new_color = blue; break;
                case 3 : new_color = alpha;
            }

    		pix[i] = 0;
    		pix[i] += (alpha         << 24);   // alpha
    		pix[i] += (new_color     << 16);   // r
    		pix[i] += (new_color     <<  8);   // g
    		pix[i] += (new_color         );    // b
            }

            Image new_im = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width, height, pix, 0, width));
            return new_im;
    }