code: public static <T extends ImageGray<T>>
  	void orderBandsIntoRGB(Planar<T> image , BufferedImage input ) {
  
  		boolean swap = swapBandOrder(input);
  
  		// Output formats are: RGB and RGBA
  
  		if( swap ) {
  			if( image.getNumBands() == 3 ) {
  				int bufferedImageType = input.getType();
  				if( bufferedImageType == BufferedImage.TYPE_3BYTE_BGR ||
  						bufferedImageType == BufferedImage.TYPE_INT_BGR )
  				{
  					T tmp = image.getBand(0);
  					image.bands[0] = image.getBand(2);
  					image.bands[2] = tmp;
  				}
  			} else if( image.getNumBands() == 4 ) {
  				T[] temp = (T[]) Array.newInstance(image.getBandType(),4);
  
  				int bufferedImageType = input.getType();
  				if( bufferedImageType == BufferedImage.TYPE_INT_ARGB ) {
  					temp[0] = image.getBand(1);
  					temp[1] = image.getBand(2);
  					temp[2] = image.getBand(3);
  					temp[3] = image.getBand(0);
  				} else if( bufferedImageType == BufferedImage.TYPE_4BYTE_ABGR ) {
  					temp[0] = image.getBand(3);
  					temp[1] = image.getBand(2);
  					temp[2] = image.getBand(1);
  					temp[3] = image.getBand(0);
  				}
  
  				image.bands[0] = temp[0];
  				image.bands[1] = temp[1];
  				image.bands[2] = temp[2];
  				image.bands[3] = temp[3];
  			}
  		}
  	}
docs: If a Planar was created from a BufferedImage its colors might not be in the expected order.
  Invoking this function ensures that the image will have the expected ordering.  For images with
  3 bands it will be RGB and for 4 bands it will be ARGB.