Program: 150727
Project: 150727
Buggy source:
/** 
 * Converts the buffered image into an   {@link Planar} image of the specified ype.
 * @param src Input image. Not modified.
 * @param dst Output. The converted image is written to.  If null a new unsigned image is created.
 * @param orderRgb If applicable, should it adjust the ordering of each color band to maintain color consistency.Most of the time you want this to be true.
 * @param type Which type of data structure is each band. (GrayU8 or GrayF32)
 * @return Converted image.
 */
public static <T extends ImageGray<T>>Planar<T> convertFromPlanar(BufferedImage src,Planar<T> dst,boolean orderRgb,Class<T> type){
  if (src == null)   throw new IllegalArgumentException("String_Node_Str");
  if (dst != null) {
    dst.reshape(src.getWidth(),dst.getHeight());
  }
  try {
    WritableRaster raster=src.getRaster();
    int numBands;
    if (src.getType() == BufferedImage.TYPE_BYTE_INDEXED)     numBands=3;
 else     numBands=raster.getNumBands();
    if (dst == null)     dst=new Planar<>(type,src.getWidth(),src.getHeight(),numBands);
 else     if (dst.getNumBands() != numBands)     dst.setNumberOfBands(numBands);
    if (type == GrayU8.class) {
      if (src.getRaster() instanceof ByteInterleavedRaster && src.getType() != BufferedImage.TYPE_BYTE_INDEXED) {
        if (src.getType() == BufferedImage.TYPE_BYTE_GRAY) {
          for (int i=0; i < dst.getNumBands(); i++)           ConvertRaster.bufferedToGray(src,((Planar<GrayU8>)dst).getBand(i));
        }
 else {
          ConvertRaster.bufferedToMulti_U8((ByteInterleavedRaster)src.getRaster(),(Planar<GrayU8>)dst);
        }
      }
 else       if (src.getRaster() instanceof IntegerInterleavedRaster) {
        ConvertRaster.bufferedToMulti_U8((IntegerInterleavedRaster)src.getRaster(),(Planar<GrayU8>)dst);
      }
 else {
        ConvertRaster.bufferedToMulti_U8(src,(Planar<GrayU8>)dst);
      }
    }
 else     if (type == GrayF32.class) {
      if (src.getRaster() instanceof ByteInterleavedRaster && src.getType() != BufferedImage.TYPE_BYTE_INDEXED) {
        if (src.getType() == BufferedImage.TYPE_BYTE_GRAY) {
          for (int i=0; i < dst.getNumBands(); i++)           ConvertRaster.bufferedToGray(src,((Planar<GrayF32>)dst).getBand(i));
        }
 else {
          ConvertRaster.bufferedToMulti_F32((ByteInterleavedRaster)src.getRaster(),(Planar<GrayF32>)dst);
        }
      }
 else       if (src.getRaster() instanceof IntegerInterleavedRaster) {
        ConvertRaster.bufferedToMulti_F32((IntegerInterleavedRaster)src.getRaster(),(Planar<GrayF32>)dst);
      }
 else {
        ConvertRaster.bufferedToMulti_F32(src,(Planar<GrayF32>)dst);
      }
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  java.security.AccessControlException e) {
    if (dst == null)     dst=new Planar<>(type,src.getWidth(),src.getHeight(),3);
 else {
      dst.setNumberOfBands(3);
    }
    if (type == GrayU8.class) {
      ConvertRaster.bufferedToMulti_U8(src,(Planar<GrayU8>)dst);
    }
 else     if (type == GrayF32.class) {
      ConvertRaster.bufferedToMulti_F32(src,(Planar<GrayF32>)dst);
    }
  }
  if (orderRgb) {
    orderBandsIntoRGB(dst,src);
  }
  return dst;
}

Fixed version (ground truth):
/** 
 * Converts the buffered image into an   {@link Planar} image of the specified ype.
 * @param src Input image. Not modified.
 * @param dst Output. The converted image is written to.  If null a new unsigned image is created.
 * @param orderRgb If applicable, should it adjust the ordering of each color band to maintain color consistency.Most of the time you want this to be true.
 * @param type Which type of data structure is each band. (GrayU8 or GrayF32)
 * @return Converted image.
 */
public static <T extends ImageGray<T>>Planar<T> convertFromPlanar(BufferedImage src,Planar<T> dst,boolean orderRgb,Class<T> type){
  if (src == null)   throw new IllegalArgumentException("String_Node_Str");
  if (dst != null) {
    dst.reshape(src.getWidth(),src.getHeight());
  }
  try {
    WritableRaster raster=src.getRaster();
    int numBands;
    if (src.getType() == BufferedImage.TYPE_BYTE_INDEXED)     numBands=3;
 else     numBands=raster.getNumBands();
    if (dst == null)     dst=new Planar<>(type,src.getWidth(),src.getHeight(),numBands);
 else     if (dst.getNumBands() != numBands)     dst.setNumberOfBands(numBands);
    if (type == GrayU8.class) {
      if (src.getRaster() instanceof ByteInterleavedRaster && src.getType() != BufferedImage.TYPE_BYTE_INDEXED) {
        if (src.getType() == BufferedImage.TYPE_BYTE_GRAY) {
          for (int i=0; i < dst.getNumBands(); i++)           ConvertRaster.bufferedToGray(src,((Planar<GrayU8>)dst).getBand(i));
        }
 else {
          ConvertRaster.bufferedToMulti_U8((ByteInterleavedRaster)src.getRaster(),(Planar<GrayU8>)dst);
        }
      }
 else       if (src.getRaster() instanceof IntegerInterleavedRaster) {
        ConvertRaster.bufferedToMulti_U8((IntegerInterleavedRaster)src.getRaster(),(Planar<GrayU8>)dst);
      }
 else {
        ConvertRaster.bufferedToMulti_U8(src,(Planar<GrayU8>)dst);
      }
    }
 else     if (type == GrayF32.class) {
      if (src.getRaster() instanceof ByteInterleavedRaster && src.getType() != BufferedImage.TYPE_BYTE_INDEXED) {
        if (src.getType() == BufferedImage.TYPE_BYTE_GRAY) {
          for (int i=0; i < dst.getNumBands(); i++)           ConvertRaster.bufferedToGray(src,((Planar<GrayF32>)dst).getBand(i));
        }
 else {
          ConvertRaster.bufferedToMulti_F32((ByteInterleavedRaster)src.getRaster(),(Planar<GrayF32>)dst);
        }
      }
 else       if (src.getRaster() instanceof IntegerInterleavedRaster) {
        ConvertRaster.bufferedToMulti_F32((IntegerInterleavedRaster)src.getRaster(),(Planar<GrayF32>)dst);
      }
 else {
        ConvertRaster.bufferedToMulti_F32(src,(Planar<GrayF32>)dst);
      }
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  java.security.AccessControlException e) {
    if (dst == null)     dst=new Planar<>(type,src.getWidth(),src.getHeight(),3);
 else {
      dst.setNumberOfBands(3);
    }
    if (type == GrayU8.class) {
      ConvertRaster.bufferedToMulti_U8(src,(Planar<GrayU8>)dst);
    }
 else     if (type == GrayF32.class) {
      ConvertRaster.bufferedToMulti_F32(src,(Planar<GrayF32>)dst);
    }
  }
  if (orderRgb) {
    orderBandsIntoRGB(dst,src);
  }
  return dst;
}