Program: 22761
Project: 22761
Buggy source:
/** 
 * Get Hessian features from original image (to be submitted in an ExecutorService). The features include a scalar representing the Hessian, the trace, determinant,  1st eigenvalue and 2nd eigenvalue.
 * @param originalImage input image
 * @param sigma radius of the Gaussian filter to use
 * @return filtered image (stack: hessian, trace, determinant, 1st eigenvalue and 2nd eigenvalue) 
 */
public Callable<ImagePlus> getHessian(final ImagePlus originalImage,final float sigma){
  if (Thread.currentThread().isInterrupted())   return null;
  return new Callable<ImagePlus>(){
    public ImagePlus call(){
      final int width=originalImage.getWidth();
      final int height=originalImage.getHeight();
      float[] sobelFilter_x={1f,2f,1f,0f,0f,0f,-1f,-2f,-1f};
      float[] sobelFilter_y={1f,0f,-1f,2f,0f,-2f,1f,0f,-1f};
      Convolver c=new Convolver();
      GaussianBlur gs=new GaussianBlur();
      ImageProcessor ip_x=originalImage.getProcessor().duplicate();
      gs.blur(ip_x,sigma);
      c.convolveFloat(ip_x,sobelFilter_x,3,3);
      ImageProcessor ip_y=originalImage.getProcessor().duplicate();
      gs.blur(ip_y,sigma);
      c=new Convolver();
      c.convolveFloat(ip_y,sobelFilter_y,3,3);
      ImageProcessor ip_xx=ip_x.duplicate();
      c.convolveFloat(ip_xx,sobelFilter_x,3,3);
      ImageProcessor ip_xy=ip_x.duplicate();
      c.convolveFloat(ip_xy,sobelFilter_y,3,3);
      ImageProcessor ip_yy=ip_y.duplicate();
      c.convolveFloat(ip_yy,sobelFilter_y,3,3);
      ImageProcessor ip=new FloatProcessor(width,height);
      ImageProcessor ipTr=new FloatProcessor(width,height);
      ImageProcessor ipDet=new FloatProcessor(width,height);
      ImageProcessor ipEig1=new FloatProcessor(width,height);
      ImageProcessor ipEig2=new FloatProcessor(width,height);
      ImageProcessor ipOri=new FloatProcessor(width,height);
      ImageProcessor ipSed=new FloatProcessor(width,height);
      ImageProcessor ipNed=new FloatProcessor(width,height);
      final double t=Math.pow(1,0.75);
      for (int x=0; x < width; x++) {
        for (int y=0; y < height; y++) {
          float s_xx=ip_xx.getf(x,y);
          float s_xy=ip_xy.getf(x,y);
          float s_yy=ip_yy.getf(x,y);
          ip.setf(x,y,(float)Math.sqrt(s_xx * s_xx + s_xy * s_xy + s_yy * s_yy));
          final float trace=(float)s_xx + s_yy;
          ipTr.setf(x,y,trace);
          final float determinant=(float)s_xx * s_yy - s_xy * s_xy;
          ipDet.setf(x,y,determinant);
          ipEig1.setf(x,y,(float)(trace / 2.0 + Math.sqrt((4 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy)) / 2.0)));
          ipEig2.setf(x,y,(float)(trace / 2.0 - Math.sqrt((4 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy)) / 2.0)));
          if (s_xy < 0.0) {
            float orientation=(float)(-0.5 * Math.acos((s_xx - s_yy) / Math.sqrt(4.0 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy))));
            if (Float.isNaN(orientation))             orientation=0;
            ipOri.setf(x,y,orientation);
          }
 else {
            float orientation=(float)(0.5 * Math.acos((s_xx - s_yy) / Math.sqrt(4.0 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy))));
            if (Float.isNaN(orientation))             orientation=0;
            ipOri.setf(x,y,orientation);
          }
          ipSed.setf(x,y,(float)(Math.pow(t,4) * trace * trace* ((s_xx - s_yy) * (s_xx - s_yy) + 4 * s_xy * s_xy)));
          ipNed.setf(x,y,(float)(Math.pow(t,2) * ((s_xx - s_yy) * (s_xx - s_yy) + 4 * s_xy * s_xy)));
        }
      }
      ImageStack hessianStack=new ImageStack(width,height);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ip);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipTr);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipDet);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipEig1);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipEig2);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipOri);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipSed);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipNed);
      return new ImagePlus("String_Node_Str",hessianStack);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Get Hessian features from original image (to be submitted in an ExecutorService). The features include a scalar representing the Hessian, the trace, determinant,  1st eigenvalue, 2nd eigenvalue, orientation, gamma-normalized square eigenvalue difference and the square of Gamma-normalized eigenvalue difference
 * @param originalImage input image
 * @param sigma radius of the Gaussian filter to use
 * @return filtered image (stack: hessian, trace, determinant, 1st eigenvalue and 2nd eigenvalue) 
 */
public Callable<ImagePlus> getHessian(final ImagePlus originalImage,final float sigma){
  if (Thread.currentThread().isInterrupted())   return null;
  return new Callable<ImagePlus>(){
    public ImagePlus call(){
      final int width=originalImage.getWidth();
      final int height=originalImage.getHeight();
      float[] sobelFilter_x={1f,2f,1f,0f,0f,0f,-1f,-2f,-1f};
      float[] sobelFilter_y={1f,0f,-1f,2f,0f,-2f,1f,0f,-1f};
      Convolver c=new Convolver();
      GaussianBlur gs=new GaussianBlur();
      ImageProcessor ip_x=originalImage.getProcessor().duplicate();
      gs.blur(ip_x,sigma);
      c.convolveFloat(ip_x,sobelFilter_x,3,3);
      ImageProcessor ip_y=originalImage.getProcessor().duplicate();
      gs.blur(ip_y,sigma);
      c=new Convolver();
      c.convolveFloat(ip_y,sobelFilter_y,3,3);
      ImageProcessor ip_xx=ip_x.duplicate();
      c.convolveFloat(ip_xx,sobelFilter_x,3,3);
      ImageProcessor ip_xy=ip_x.duplicate();
      c.convolveFloat(ip_xy,sobelFilter_y,3,3);
      ImageProcessor ip_yy=ip_y.duplicate();
      c.convolveFloat(ip_yy,sobelFilter_y,3,3);
      ImageProcessor ip=new FloatProcessor(width,height);
      ImageProcessor ipTr=new FloatProcessor(width,height);
      ImageProcessor ipDet=new FloatProcessor(width,height);
      ImageProcessor ipEig1=new FloatProcessor(width,height);
      ImageProcessor ipEig2=new FloatProcessor(width,height);
      ImageProcessor ipOri=new FloatProcessor(width,height);
      ImageProcessor ipSed=new FloatProcessor(width,height);
      ImageProcessor ipNed=new FloatProcessor(width,height);
      final double t=Math.pow(1,0.75);
      for (int x=0; x < width; x++) {
        for (int y=0; y < height; y++) {
          float s_xx=ip_xx.getf(x,y);
          float s_xy=ip_xy.getf(x,y);
          float s_yy=ip_yy.getf(x,y);
          ip.setf(x,y,(float)Math.sqrt(s_xx * s_xx + s_xy * s_xy + s_yy * s_yy));
          final float trace=(float)s_xx + s_yy;
          ipTr.setf(x,y,trace);
          final float determinant=(float)s_xx * s_yy - s_xy * s_xy;
          ipDet.setf(x,y,determinant);
          ipEig1.setf(x,y,(float)(trace / 2.0 + Math.sqrt((4 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy)) / 2.0)));
          ipEig2.setf(x,y,(float)(trace / 2.0 - Math.sqrt((4 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy)) / 2.0)));
          if (s_xy < 0.0) {
            float orientation=(float)(-0.5 * Math.acos((s_xx - s_yy) / Math.sqrt(4.0 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy))));
            if (Float.isNaN(orientation))             orientation=0;
            ipOri.setf(x,y,orientation);
          }
 else {
            float orientation=(float)(0.5 * Math.acos((s_xx - s_yy) / Math.sqrt(4.0 * s_xy * s_xy + (s_xx - s_yy) * (s_xx - s_yy))));
            if (Float.isNaN(orientation))             orientation=0;
            ipOri.setf(x,y,orientation);
          }
          ipSed.setf(x,y,(float)(Math.pow(t,4) * trace * trace* ((s_xx - s_yy) * (s_xx - s_yy) + 4 * s_xy * s_xy)));
          ipNed.setf(x,y,(float)(Math.pow(t,2) * ((s_xx - s_yy) * (s_xx - s_yy) + 4 * s_xy * s_xy)));
        }
      }
      ImageStack hessianStack=new ImageStack(width,height);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ip);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipTr);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipDet);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipEig1);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipEig2);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipOri);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipSed);
      hessianStack.addSlice(availableFeatures[HESSIAN] + "String_Node_Str" + sigma,ipNed);
      return new ImagePlus("String_Node_Str",hessianStack);
    }
  }
;
}