Program: 149533
Project: 149533
Buggy source:
/** 
 * Get the data from the image as a float array (include cropping to the ROI). Data is duplicated if the input already a float array. <p> Allows reuse of an existing buffer if provided. This will not be truncated if it is larger than the ImageProcessor ROI bounds. If smaller then a new buffer will be created.
 * @param oPixels
 * @param width
 * @param height
 * @param bounds
 * @param buffer
 * @return The float array data
 */
public static float[] getData(final Object oPixels,final int width,final int height,final Rectangle bounds,float[] buffer){
  if (oPixels == null)   return null;
  if (oPixels instanceof float[]) {
    float[] pixels=(float[])oPixels;
    if (bounds != null && (bounds.x != 0 || bounds.y != 0 || bounds.width != width || bounds.height != height)) {
      float[] pixels2=allocate(buffer,bounds.width * bounds.height);
      for (int ys=0, offset1=0; ys < bounds.height; ys++) {
        for (int xs=0, offset2=(ys + bounds.y) * width + bounds.x; xs < bounds.width; xs++)         pixels2[offset1++]=pixels[offset2++];
      }
      return pixels2;
    }
 else {
      float[] pixels2=allocate(buffer,pixels.length);
      System.arraycopy(pixels,0,pixels2,0,pixels.length);
      return pixels2;
    }
  }
 else   if (oPixels instanceof short[]) {
    short[] pixels=(short[])oPixels;
    if (bounds != null && (bounds.x != 0 || bounds.y != 0 || bounds.width != width || bounds.height != height)) {
      float[] pixels2=allocate(buffer,bounds.width * bounds.height);
      for (int ys=0, offset1=0; ys < bounds.height; ys++) {
        for (int xs=0, offset2=(ys + bounds.y) * width + bounds.x; xs < bounds.width; xs++)         pixels2[offset1++]=pixels[offset2++] & 0xffff;
      }
      return pixels2;
    }
 else {
      float[] pixels2=allocate(buffer,pixels.length);
      for (int i=0; i < pixels.length; i++)       pixels2[i]=pixels[i] & 0xffff;
      return pixels2;
    }
  }
 else   if (oPixels instanceof byte[]) {
    byte[] pixels=(byte[])oPixels;
    if (bounds != null && (bounds.x != 0 || bounds.y != 0 || bounds.width != width || bounds.height != height)) {
      float[] pixels2=allocate(buffer,bounds.width * bounds.height);
      for (int ys=0, offset1=0; ys < bounds.height; ys++) {
        for (int xs=0, offset2=(ys + bounds.y) * width + bounds.x; xs < bounds.width; xs++)         pixels2[offset1++]=pixels[offset2++] & 0xff;
      }
      return pixels2;
    }
 else {
      float[] pixels2=allocate(buffer,pixels.length);
      for (int i=0; i < pixels.length; i++)       pixels2[i]=pixels[i] & 0xff;
      return pixels2;
    }
  }
 else   if (oPixels instanceof int[]) {
    ImageProcessor ip=new ColorProcessor(width,height,(int[])oPixels);
    ip.setRoi(bounds);
    FloatProcessor fp=ip.crop().toFloat(0,null);
    return (float[])fp.getPixels();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the data from the image as a float array (include cropping to the ROI). Data is duplicated if the input already a float array. <p> Allows reuse of an existing buffer if provided. This will not be truncated if it is larger than the ImageProcessor ROI bounds. If smaller then a new buffer will be created. <p> If the object pixels array is incorrect size (it should be width*height) then null will be returned. 
 * @param oPixels
 * @param width
 * @param height
 * @param bounds
 * @param buffer
 * @return The float array data
 */
public static float[] getData(final Object oPixels,final int width,final int height,final Rectangle bounds,float[] buffer){
  if (oPixels == null)   return null;
  if (oPixels instanceof float[]) {
    float[] pixels=(float[])oPixels;
    if (incorrectSize(pixels.length,width,height))     return null;
    if (bounds != null && (bounds.x != 0 || bounds.y != 0 || bounds.width != width || bounds.height != height)) {
      float[] pixels2=allocate(buffer,bounds.width * bounds.height);
      for (int ys=0, offset1=0; ys < bounds.height; ys++) {
        for (int xs=0, offset2=(ys + bounds.y) * width + bounds.x; xs < bounds.width; xs++)         pixels2[offset1++]=pixels[offset2++];
      }
      return pixels2;
    }
 else {
      float[] pixels2=allocate(buffer,pixels.length);
      System.arraycopy(pixels,0,pixels2,0,pixels.length);
      return pixels2;
    }
  }
 else   if (oPixels instanceof short[]) {
    short[] pixels=(short[])oPixels;
    if (incorrectSize(pixels.length,width,height))     return null;
    if (bounds != null && (bounds.x != 0 || bounds.y != 0 || bounds.width != width || bounds.height != height)) {
      float[] pixels2=allocate(buffer,bounds.width * bounds.height);
      for (int ys=0, offset1=0; ys < bounds.height; ys++) {
        for (int xs=0, offset2=(ys + bounds.y) * width + bounds.x; xs < bounds.width; xs++)         pixels2[offset1++]=pixels[offset2++] & 0xffff;
      }
      return pixels2;
    }
 else {
      float[] pixels2=allocate(buffer,pixels.length);
      for (int i=0; i < pixels.length; i++)       pixels2[i]=pixels[i] & 0xffff;
      return pixels2;
    }
  }
 else   if (oPixels instanceof byte[]) {
    byte[] pixels=(byte[])oPixels;
    if (incorrectSize(pixels.length,width,height))     return null;
    if (bounds != null && (bounds.x != 0 || bounds.y != 0 || bounds.width != width || bounds.height != height)) {
      float[] pixels2=allocate(buffer,bounds.width * bounds.height);
      for (int ys=0, offset1=0; ys < bounds.height; ys++) {
        for (int xs=0, offset2=(ys + bounds.y) * width + bounds.x; xs < bounds.width; xs++)         pixels2[offset1++]=pixels[offset2++] & 0xff;
      }
      return pixels2;
    }
 else {
      float[] pixels2=allocate(buffer,pixels.length);
      for (int i=0; i < pixels.length; i++)       pixels2[i]=pixels[i] & 0xff;
      return pixels2;
    }
  }
 else   if (oPixels instanceof int[]) {
    int[] pixels=(int[])oPixels;
    if (incorrectSize(pixels.length,width,height))     return null;
    ImageProcessor ip=new ColorProcessor(width,height,pixels);
    ip.setRoi(bounds);
    FloatProcessor fp=ip.crop().toFloat(0,null);
    return (float[])fp.getPixels();
  }
  return null;
}