Program: 22728
Project: 22728
Buggy source:
/** 
 * Get Sobel filter version of the original image (to be called from an ExecutorService)
 * @param originalImage input image
 * @param sigma radius of the Gaussian blur applied previous to the Sobel filtering
 * @return filtered image
 */
public Callable<ImagePlus> getGradient(final ImagePlus originalImage,final float sigma){
  if (Thread.currentThread().isInterrupted())   return null;
  return new Callable<ImagePlus>(){
    public ImagePlus call(){
      ImagePlus[] channels=extractChannels(originalImage);
      ImagePlus[] results=new ImagePlus[channels.length];
      for (int ch=0; ch < channels.length; ch++) {
        GaussianBlur gs=new GaussianBlur();
        ImageProcessor ip_x=channels[ch].getProcessor().convertToFloat();
        gs.blurGaussian(ip_x,0.4 * sigma,0.4 * sigma,0.0002);
        Convolver c=new Convolver();
        float[] sobelFilter_x={1f,2f,1f,0f,0f,0f,-1f,-2f,-1f};
        c.convolveFloat(ip_x,sobelFilter_x,3,3);
        ImageProcessor ip_y=channels[ch].getProcessor().convertToFloat();
        gs.blurGaussian(ip_y,0.4 * sigma,0.4 * sigma,0.0002);
        c=new Convolver();
        float[] sobelFilter_y={1f,0f,-1f,2f,0f,-2f,1f,0f,-1f};
        c.convolveFloat(ip_y,sobelFilter_y,3,3);
        ImageProcessor ip=new FloatProcessor(width,height);
        for (int x=0; x < width; x++) {
          for (int y=0; y < height; y++) {
            float s_x=ip_x.getf(x,y);
            float s_y=ip_y.getf(x,y);
            ip.setf(x,y,(float)Math.sqrt(s_x * s_x + s_y * s_y));
          }
        }
        results[ch]=new ImagePlus(availableFeatures[SOBEL] + "String_Node_Str" + sigma,ip);
      }
      return mergeResultChannels(results);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Get Sobel filter version of the original image (to be called from an ExecutorService)
 * @param originalImage input image
 * @param sigma radius of the Gaussian blur applied previous to the Sobel filtering
 * @return filtered image
 */
public Callable<ImagePlus> getGradient(final ImagePlus originalImage,final float sigma){
  if (Thread.currentThread().isInterrupted())   return null;
  return new Callable<ImagePlus>(){
    public ImagePlus call(){
      ImagePlus[] channels=extractChannels(originalImage);
      ImagePlus[] results=new ImagePlus[channels.length];
      for (int ch=0; ch < channels.length; ch++) {
        GaussianBlur gs=new GaussianBlur();
        ImageProcessor ip_x=channels[ch].getProcessor().duplicate().convertToFloat();
        gs.blurGaussian(ip_x,0.4 * sigma,0.4 * sigma,0.0002);
        Convolver c=new Convolver();
        float[] sobelFilter_x={1f,2f,1f,0f,0f,0f,-1f,-2f,-1f};
        c.convolveFloat(ip_x,sobelFilter_x,3,3);
        ImageProcessor ip_y=channels[ch].getProcessor().duplicate().convertToFloat();
        gs.blurGaussian(ip_y,0.4 * sigma,0.4 * sigma,0.0002);
        c=new Convolver();
        float[] sobelFilter_y={1f,0f,-1f,2f,0f,-2f,1f,0f,-1f};
        c.convolveFloat(ip_y,sobelFilter_y,3,3);
        ImageProcessor ip=new FloatProcessor(width,height);
        for (int x=0; x < width; x++) {
          for (int y=0; y < height; y++) {
            float s_x=ip_x.getf(x,y);
            float s_y=ip_y.getf(x,y);
            ip.setf(x,y,(float)Math.sqrt(s_x * s_x + s_y * s_y));
          }
        }
        results[ch]=new ImagePlus(availableFeatures[SOBEL] + "String_Node_Str" + sigma,ip);
      }
      return mergeResultChannels(results);
    }
  }
;
}