nus-yam/ex-repair huggingface dataset:
Program: 151101
Project: 151101
Buggy source:
public void runAll(){
  System.out.println("String_Node_Str" + NUM_POINTS);
  System.out.println();
  double tol=1e-16;
  int MAX_ITER=100;
  init(NUM_POINTS,PIXELS,true);
  EpipolarMatrixEstimator computeAlg=FactoryEpipolar.computeHomography(true);
  computeAlg.process(pairs);
  initialF=computeAlg.getEpipolarMatrix();
  ProfileOperation.printOpsPerSec(new Refine("String_Node_Str",refineHomography(tol,MAX_ITER,EpipolarError.SIMPLE)),TEST_TIME);
  ProfileOperation.printOpsPerSec(new Refine("String_Node_Str",refineHomography(tol,MAX_ITER,EpipolarError.SAMPSON)),TEST_TIME);
  System.out.println();
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public void runAll(){
  System.out.println("String_Node_Str" + NUM_POINTS);
  System.out.println();
  double tol=1e-16;
  int MAX_ITER=200;
  init(NUM_POINTS,PIXELS,true);
  EpipolarMatrixEstimator computeAlg=FactoryEpipolar.computeHomography(true);
  computeAlg.process(pairs);
  initialF=computeAlg.getEpipolarMatrix();
  initialF.data[0]+=0.1;
  initialF.data[4]-=0.15;
  initialF.data[7]-=0.2;
  ProfileOperation.printOpsPerSec(new Refine("String_Node_Str",refineHomography(tol,MAX_ITER,EpipolarError.SIMPLE)),TEST_TIME);
  ProfileOperation.printOpsPerSec(new Refine("String_Node_Str",refineHomography(tol,MAX_ITER,EpipolarError.SAMPSON)),TEST_TIME);
  ProfileOperation.printOpsPerSec(new Linear4(),TEST_TIME);
  System.out.println();
  System.out.println("String_Node_Str");
}
Program: 151102
Project: 151102
Buggy source:
@Override public void process(I input){
  if (featSrc == null) {
    featSrc=createFeatureDescQueue(false);
    featDst=createFeatureDescQueue(true);
  }
  setInputImage(input);
  tick++;
  tracksActive.clear();
  tracksDropped.clear();
  tracksNew.clear();
  featDst.reset();
  locDst.reset();
  detectFeatures(locDst,featDst);
  pruneTracks();
  if (keyFrameSet) {
    matches=associate(featSrc,featDst);
    for (int i=0; i < matches.size; i++) {
      AssociatedIndex indexes=matches.data[i];
      PointTrack pair=tracksAll.get(indexes.src);
      Point2D_F64 loc=locDst.data[indexes.dst];
      pair.set(loc.x,loc.y);
      tracksActive.add(pair);
      TrackInfo info=(TrackInfo)pair.getDescription();
      info.lastAssociated=tick;
      if (updateState) {
        setDescription(info.desc,featDst.get(indexes.dst));
      }
    }
  }
}

Fixed version (ground truth):
@Override public void process(I input){
  if (featSrc == null) {
    featSrc=createFeatureDescQueue(false);
    featDst=createFeatureDescQueue(true);
  }
  setInputImage(input);
  tick++;
  tracksActive.clear();
  tracksDropped.clear();
  tracksNew.clear();
  featDst.reset();
  locDst.reset();
  detectFeatures(locDst,featDst);
  pruneTracks();
  if (keyFrameSet) {
    matches=associate(featSrc,featDst);
    for (int i=0; i < matches.size; i++) {
      AssociatedIndex indexes=matches.data[i];
      PointTrack track=tracksAll.get(indexes.src);
      Point2D_F64 loc=locDst.data[indexes.dst];
      track.set(loc.x,loc.y);
      tracksActive.add(track);
      TrackInfo info=(TrackInfo)track.getDescription();
      info.lastAssociated=tick;
      if (updateState) {
        setDescription(info.desc,featDst.get(indexes.dst));
      }
    }
  }
}
Program: 151103
Project: 151103
Buggy source:
/** 
 * Tracks features inside the image and updates feature locations.
 * @param image
 */
public void process(T image){
  tracker.process(image);
  List<PointTrack> dropped=tracker.getDroppedTracks();
  for (int i=0; i < dropped.size(); i++) {
    if (!pairs.remove((AssociatedPair)dropped.get(i).cookie))     throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Tracks features inside the image and updates feature locations.
 * @param image
 */
public void process(T image){
  tracker.process(image);
  pairs.clear();
  List<PointTrack> tracks=tracker.getActiveTracks();
  for (  PointTrack t : tracks) {
    AssociatedPair p=t.getCookie();
    pairs.add(p);
  }
}
Program: 151104
Project: 151104
Buggy source:
@Test public void enforceZeroDeterminant(){
  for (int i=0; i < 20; i++) {
    SimpleMatrix F1=SimpleMatrix.random(3,3,0.1,2,rand);
    SimpleMatrix F2=SimpleMatrix.random(3,3,0.1,2,rand);
    double alpha=FundamentalLinear7.enforceZeroDeterminant(F1.getMatrix(),F2.getMatrix(),new double[4]);
    SimpleMatrix F=F1.scale(alpha).plus(F2.scale(1 - alpha));
    System.out.println("String_Node_Str" + F.determinant() + "String_Node_Str"+ F1.determinant());
    assertEquals(0,F.determinant(),1e-8);
  }
}

Fixed version (ground truth):
@Test public void enforceZeroDeterminant(){
  for (int i=0; i < 20; i++) {
    SimpleMatrix F1=SimpleMatrix.random(3,3,0.1,2,rand);
    SimpleMatrix F2=SimpleMatrix.random(3,3,0.1,2,rand);
    double alpha=FundamentalLinear7.enforceZeroDeterminant(F1.getMatrix(),F2.getMatrix(),new double[4]);
    SimpleMatrix F=F1.scale(alpha).plus(F2.scale(1 - alpha));
    assertEquals(0,F.determinant(),1e-8);
  }
}
Program: 151105
Project: 151105
Buggy source:
/** 
 * <p> A cubic polynomial of the form "f(x) =  a + b*x + c*x<sup>2</sup> + d*x<sup>3</sup>" has three roots.  These roots will either be all real or one real and two imaginary.  This function will return a root which is always real. </p> <p> WARNING: Not as numerically stable as   {@link #polynomialRootsEVD(double)}, but still fairly stable. </p>
 * @param a polynomial coefficient.
 * @param b polynomial coefficient.
 * @param c polynomial coefficient.
 * @param d polynomial coefficient.
 * @return A real root of the cubic polynomial
 */
public static double cubicRootReal(double a,double b,double c,double d){
  double norm=Math.max(Math.abs(a),Math.abs(b));
  norm=Math.max(norm,Math.abs(c));
  norm=Math.max(norm,Math.abs(d));
  a/=norm;
  b/=norm;
  c/=norm;
  d/=norm;
  double insideLeft=c * (2 * c * c - 9 * d * b) + 27 * d * d* a;
  double temp=c * c - 3 * d * b;
  double insideOfSqrt=insideLeft * insideLeft - 4 * temp * temp* temp;
  if (insideOfSqrt >= 0) {
    double insideRight=Math.sqrt(insideOfSqrt);
    double ret=c / d + root3(0.5 * (insideLeft + insideRight)) + root3(0.5 * (insideLeft - insideRight));
    return -ret / (3.0 * d);
  }
 else {
    Complex64F inside=new Complex64F(0.5 * insideLeft,0.5 * Math.sqrt(-insideOfSqrt));
    Complex64F root=new Complex64F();
    ComplexMath.root(inside,3,2,root);
    double ret=c + 2 * root.getReal();
    return -ret / (3.0 * d);
  }
}

Fixed version (ground truth):
/** 
 * <p> A cubic polynomial of the form "f(x) =  a + b*x + c*x<sup>2</sup> + d*x<sup>3</sup>" has three roots.  These roots will either be all real or one real and two imaginary.  This function will return a root which is always real. </p> <p> WARNING: Not as numerically stable as   {@link #polynomialRootsEVD(double)}, but still fairly stable. </p>
 * @param a polynomial coefficient.
 * @param b polynomial coefficient.
 * @param c polynomial coefficient.
 * @param d polynomial coefficient.
 * @return A real root of the cubic polynomial
 */
public static double cubicRootReal(double a,double b,double c,double d){
  double norm=Math.max(Math.abs(a),Math.abs(b));
  norm=Math.max(norm,Math.abs(c));
  norm=Math.max(norm,Math.abs(d));
  a/=norm;
  b/=norm;
  c/=norm;
  d/=norm;
  double insideLeft=2 * c * c* c - 9 * d * c* b + 27 * d * d* a;
  double temp=c * c - 3 * d * b;
  double insideOfSqrt=insideLeft * insideLeft - 4 * temp * temp* temp;
  if (insideOfSqrt >= 0) {
    double insideRight=Math.sqrt(insideOfSqrt);
    double ret=c + root3(0.5 * (insideLeft + insideRight)) + root3(0.5 * (insideLeft - insideRight));
    return -ret / (3.0 * d);
  }
 else {
    Complex64F inside=new Complex64F(0.5 * insideLeft,0.5 * Math.sqrt(-insideOfSqrt));
    Complex64F root=new Complex64F();
    ComplexMath.root(inside,3,2,root);
    double ret=c + 2 * root.getReal();
    return -ret / (3.0 * d);
  }
}
Program: 151106
Project: 151106
Buggy source:
public static void main(String args[]){
  BufferedImage in=UtilImageIO.loadImage("String_Node_Str");
  WaveletVisualizeApp app=new WaveletVisualizeApp(ImageFloat32.class);
  ImageListManager manager=new ImageListManager();
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  app.setInputManager(manager);
  while (!app.getHasProcessedImage()) {
    Thread.yield();
  }
  ShowImages.showWindow(app,"String_Node_Str");
}

Fixed version (ground truth):
public static void main(String args[]){
  BufferedImage in=UtilImageIO.loadImage("String_Node_Str");
  WaveletVisualizeApp app=new WaveletVisualizeApp(ImageFloat32.class);
  ImageListManager manager=new ImageListManager();
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  app.setInputManager(manager);
  while (!app.getHasProcessedImage()) {
    Thread.yield();
  }
  ShowImages.showWindow(app,"String_Node_Str");
}
Program: 151107
Project: 151107
Buggy source:
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  if (img != null) {
    if (resize) {
      double ratioW=(double)getWidth() / (double)img.getWidth();
      double ratioH=(double)getHeight() / (double)img.getHeight();
      double ratio=Math.min(ratioW,ratioH);
      if (ratio == 1) {
        g.drawImage(img,0,0,this);
      }
 else {
        AffineTransform tran=AffineTransform.getScaleInstance(ratio,ratio);
        g2.drawImage(img,tran,null);
      }
    }
 else {
      g2.drawImage(img,0,0,this);
    }
  }
}

Fixed version (ground truth):
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  if (img != null) {
    if (resize) {
      double ratioW=(double)getWidth() / (double)img.getWidth();
      double ratioH=(double)getHeight() / (double)img.getHeight();
      double ratio=Math.min(ratioW,ratioH);
      if (ratio >= 1)       ratio=1;
      if (ratio == 1) {
        g.drawImage(img,0,0,this);
      }
 else {
        AffineTransform tran=AffineTransform.getScaleInstance(ratio,ratio);
        g2.drawImage(img,tran,null);
      }
    }
 else {
      g2.drawImage(img,0,0,this);
    }
  }
}
Program: 151108
Project: 151108
Buggy source:
@Override public synchronized void paintComponent(Graphics g){
  super.paintComponent(g);
  if (orig == null || stabilized == null)   return;
  Graphics2D g2=(Graphics2D)g;
  int w=getWidth() / 2 - 10;
  int h=getHeight();
  double scaleX=w / (double)orig.getWidth();
  double scaleY=h / (double)orig.getHeight();
  double scale=Math.min(scaleX,scaleY);
  if (scale > 1)   scale=1;
  int scaledWidth=(int)(scale * orig.getWidth());
  int scaledHeight=(int)(scale * orig.getHeight());
  g2.drawImage(orig,0,0,scaledWidth,scaledHeight,0,0,orig.getWidth(),orig.getHeight(),null);
  g2.drawImage(stabilized,scaledWidth + 10,0,scaledWidth * 2 + 10,scaledHeight,0,0,orig.getWidth(),orig.getHeight(),null);
  for (int i=0; i < features.size(); i++) {
    Point2D_F64 p=features.get(i);
    VisualizeFeatures.drawPoint(g2,(int)p.x,(int)p.y,Color.BLUE);
  }
}

Fixed version (ground truth):
@Override public synchronized void paintComponent(Graphics g){
  super.paintComponent(g);
  if (orig == null || stabilized == null)   return;
  Graphics2D g2=(Graphics2D)g;
  int w=getWidth() / 2 - 10;
  int h=getHeight();
  double scaleX=w / (double)orig.getWidth();
  double scaleY=h / (double)orig.getHeight();
  double scale=Math.min(scaleX,scaleY);
  if (scale > 1)   scale=1;
  int scaledWidth=(int)(scale * orig.getWidth());
  int scaledHeight=(int)(scale * orig.getHeight());
  g2.drawImage(orig,0,0,scaledWidth,scaledHeight,0,0,orig.getWidth(),orig.getHeight(),null);
  g2.drawImage(stabilized,scaledWidth + 10,0,scaledWidth * 2 + 10,scaledHeight,0,0,orig.getWidth(),orig.getHeight(),null);
  for (int i=0; i < features.size(); i++) {
    Point2D_F64 p=features.get(i);
    VisualizeFeatures.drawPoint(g2,(int)(scale * p.x),(int)(scale * p.y),Color.BLUE);
  }
}
Program: 151109
Project: 151109
Buggy source:
@Override public void setActiveAlgorithm(int indexFamily,String name,Object cookie){
  if (image == null)   return;
  WaveletDescription<C> desc=(WaveletDescription<C>)cookie;
  WaveletTransform<T,W,C> waveletTran=FactoryWaveletTransform.create((Class)image.getClass(),desc,numLevels);
  panel.reset();
  W imageWavelet=waveletTran.transform(image,null);
  waveletTran.invert(imageWavelet,imageInv);
  float maxValue=(float)GPixelMath.maxAbs(imageWavelet);
  BufferedImage buffWavelet=VisualizeImageData.grayMagnitude(imageWavelet,null,maxValue);
  BufferedImage buffInv=ConvertBufferedImage.convertTo(imageInv,null);
  panel.addImage(buffWavelet,"String_Node_Str");
  panel.addImage(buffInv,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void setActiveAlgorithm(int indexFamily,String name,Object cookie){
  if (image == null)   return;
  WaveletDescription<C> desc=(WaveletDescription<C>)cookie;
  WaveletTransform<T,W,C> waveletTran=FactoryWaveletTransform.create((Class)image.getClass(),desc,numLevels);
  panel.reset();
  W imageWavelet=waveletTran.transform(image,null);
  waveletTran.invert(imageWavelet,imageInv);
  UtilWavelet.adjustForDisplay(imageWavelet,waveletTran.getLevels(),255);
  BufferedImage buffWavelet=VisualizeImageData.grayMagnitude(imageWavelet,null,255);
  BufferedImage buffInv=ConvertBufferedImage.convertTo(imageInv,null);
  panel.addImage(buffWavelet,"String_Node_Str");
  panel.addImage(buffInv,"String_Node_Str");
}
Program: 151110
Project: 151110
Buggy source:
public static void main(String args[]){
  double tolerance=3;
  ScoreAssociation score=new ScoreAssociateEuclideanSq();
  GeneralAssociation<TupleDesc_F64> assoc=FactoryAssociation.greedy(score,Double.MAX_VALUE,-1,true);
  BenchmarkFeatureHomography app=new BenchmarkFeatureHomography(assoc,"String_Node_Str","String_Node_Str",tolerance);
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
}

Fixed version (ground truth):
public static void main(String args[]){
  double tolerance=3;
  ScoreAssociation score=new ScoreAssociateEuclideanSq();
  GeneralAssociation<TupleDesc_F64> assoc=FactoryAssociation.greedy(score,Double.MAX_VALUE,-1,true);
  BenchmarkFeatureHomography app=new BenchmarkFeatureHomography(assoc,"String_Node_Str","String_Node_Str",tolerance);
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
}
Program: 151111
Project: 151111
Buggy source:
public static void main(String args[]){
  IntensityFeatureScaleSpaceApp app=new IntensityFeatureScaleSpaceApp(ImageUInt8.class,ImageSInt16.class);
  ImageListManager manager=new ImageListManager();
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  app.setInputManager(manager);
  while (!app.getHasProcessedImage()) {
    Thread.yield();
  }
  ShowImages.showWindow(app,"String_Node_Str");
}

Fixed version (ground truth):
public static void main(String args[]){
  IntensityFeatureScaleSpaceApp<ImageFloat32,ImageFloat32> app=new IntensityFeatureScaleSpaceApp<ImageFloat32,ImageFloat32>(ImageFloat32.class,ImageFloat32.class);
  ImageListManager manager=new ImageListManager();
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  manager.add("String_Node_Str","String_Node_Str");
  app.setInputManager(manager);
  while (!app.getHasProcessedImage()) {
    Thread.yield();
  }
  ShowImages.showWindow(app,"String_Node_Str");
}
Program: 151112
Project: 151112
Buggy source:
public DetectFeaturePyramidApp(Class<T> imageType,Class<D> derivType){
  super(1);
  this.imageType=imageType;
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianLaplacePyramid(r,1,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisLaplacePyramid(r,1,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianPyramid(r,1,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisPyramid(r,1,NUM_FEATURES,imageType,derivType));
  ss=new ScaleSpacePyramid<T>(imageType,1,1.5,2,4,8,12,24);
  panel=new ScaleSpacePyramidPointPanel(ss,r);
  setMainGUI(panel);
}

Fixed version (ground truth):
public DetectFeaturePyramidApp(Class<T> imageType,Class<D> derivType){
  super(1);
  this.imageType=imageType;
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianLaplacePyramid(r,1f,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisLaplacePyramid(r,1f,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianPyramid(r,1,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisPyramid(r,1,NUM_FEATURES,imageType,derivType));
  ss=new ScaleSpacePyramid<T>(imageType,1,1.5,2,3,4,8,12,16,24);
  panel=new ScaleSpacePyramidPointPanel(ss,r);
  setMainGUI(panel);
}
Program: 151113
Project: 151113
Buggy source:
public DetectFeatureScaleSpaceApp(Class<T> imageType,Class<D> derivType){
  super(1);
  this.imageType=imageType;
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianLaplace(r,1,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisLaplace(r,1,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianScaleSpace(r,1,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisScaleSpace(r,1,NUM_FEATURES,imageType,derivType));
  ss=FactoryGaussianScaleSpace.nocache(imageType);
  ss.setScales(1,1.5,2,4,8,12,24);
  panel=new ScaleSpacePointPanel(ss,r);
  setMainGUI(panel);
}

Fixed version (ground truth):
public DetectFeatureScaleSpaceApp(Class<T> imageType,Class<D> derivType){
  super(1);
  this.imageType=imageType;
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianLaplace(r,1f,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisLaplace(r,0.5f,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.hessianScaleSpace(r,1f,NUM_FEATURES,imageType,derivType));
  addAlgorithm(0,"String_Node_Str",FactoryInterestPointAlgs.harrisScaleSpace(r,0.5f,NUM_FEATURES,imageType,derivType));
  ss=FactoryGaussianScaleSpace.nocache(imageType);
  ss.setScales(1,1.5,2,3,4,8,12,16,24);
  panel=new ScaleSpacePointPanel(ss,r);
  levelPanel=new SelectScaleSpacePanel(ss,panel);
  add(levelPanel,BorderLayout.WEST);
  setMainGUI(panel);
}
Program: 151114
Project: 151114
Buggy source:
@Override public void setActiveAlgorithm(int indexFamily,String name,Object cookie){
  if (!hasImage)   return;
  final InterestPointScaleSpace<T,D> det=(InterestPointScaleSpace<T,D>)cookie;
  det.detect(ss);
  panel.setPoints(det.getInterestPoints());
  panel.repaint();
  panel.requestFocusInWindow();
}

Fixed version (ground truth):
@Override public void setActiveAlgorithm(int indexFamily,String name,Object cookie){
  if (!hasImage)   return;
  final InterestPointScaleSpace<T,D> det=(InterestPointScaleSpace<T,D>)cookie;
  det.detect(ss);
  panel.setPoints(det.getInterestPoints());
  levelPanel.reset();
}
Program: 151115
Project: 151115
Buggy source:
private void printPreamble(){
  out.print(CodeGeneratorUtil.copyright);
  out.print("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + className + "String_Node_Str");
}

Fixed version (ground truth):
private void printPreamble() throws FileNotFoundException {
  setOutputFile(className);
  out.print("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + className + "String_Node_Str");
}
Program: 151116
Project: 151116
Buggy source:
public static void determinant(ImageFloat32 featureIntensity,ImageSInt16 hessianXX,ImageSInt16 hessianYY,ImageSInt16 hessianXY){
  final int width=hessianXX.width;
  final int height=hessianXX.height;
  if (featureIntensity == null) {
    featureIntensity=new ImageFloat32(width,height);
  }
  for (int y=0; y < height; y++) {
    int indexXX=hessianXX.startIndex + y * hessianXX.stride;
    int indexYY=hessianYY.startIndex + y * hessianYY.stride;
    int indexXY=hessianXY.startIndex + y * hessianXY.stride;
    int indexInten=featureIntensity.startIndex + y * featureIntensity.stride;
    for (int x=0; x < width; x++) {
      int dxx=hessianXX.data[indexXX++];
      int dyy=hessianYY.data[indexYY++];
      int dxy=hessianXY.data[indexXY++];
      featureIntensity.data[indexInten++]=dxx * dyy - dxy * dxy;
    }
  }
}

Fixed version (ground truth):
public static void determinant(ImageFloat32 featureIntensity,ImageSInt16 hessianXX,ImageSInt16 hessianYY,ImageSInt16 hessianXY){
  final int width=hessianXX.width;
  final int height=hessianXX.height;
  if (featureIntensity == null) {
    featureIntensity=new ImageFloat32(width,height);
  }
  for (int y=0; y < height; y++) {
    int indexXX=hessianXX.startIndex + y * hessianXX.stride;
    int indexYY=hessianYY.startIndex + y * hessianYY.stride;
    int indexXY=hessianXY.startIndex + y * hessianXY.stride;
    int indexInten=featureIntensity.startIndex + y * featureIntensity.stride;
    for (int x=0; x < width; x++) {
      int dxx=hessianXX.data[indexXX++];
      int dyy=hessianYY.data[indexYY++];
      int dxy=hessianXY.data[indexXY++];
      featureIntensity.data[indexInten++]=Math.abs(dxx * dyy - dxy * dxy);
    }
  }
}
Program: 151117
Project: 151117
Buggy source:
/** 
 * See if each feature is a maximum in its local scale-space.
 */
protected void findLocalScaleSpaceMax(ScaleSpacePyramid<T> ss,int layerID){
  int index1=(spaceIndex + 1) % 3;
  List<Point2D_I16> candidates=maximums[index1];
  float scale0=(float)ss.scale[layerID - 1];
  float scale1=(float)ss.scale[layerID];
  float scale2=(float)ss.scale[layerID + 1];
  float ss0=(float)Math.pow(scale0,scalePower);
  float ss1=(float)Math.pow(scale1,scalePower);
  float ss2=(float)Math.pow(scale2,scalePower);
  for (  Point2D_I16 c : candidates) {
    sparseLaplace.setImage(ss.getLayer(layerID));
    float val=ss1 * (float)Math.abs(sparseLaplace.compute(c.x,c.y));
    int x0=(int)(c.x * scale1 / scale0);
    int y0=(int)(c.y * scale1 / scale0);
    int x2=(int)(c.x * scale1 / scale2);
    int y2=(int)(c.y * scale1 / scale2);
    if (checkMax(ss.getLayer(layerID - 1),val / ss0,x0,y0) && checkMax(ss.getLayer(layerID + 1),val / ss2,x2,y2)) {
      foundPoints.add(new ScalePoint((int)(c.x * scale1),(int)(c.y * scale1),scale1));
    }
  }
}

Fixed version (ground truth):
/** 
 * See if each feature is a maximum in its local scale-space.
 */
protected void findLocalScaleSpaceMax(ScaleSpacePyramid<T> ss,int layerID){
  int index1=(spaceIndex + 1) % 3;
  List<Point2D_I16> candidates=maximums[index1];
  float scale0=(float)ss.scale[layerID - 1];
  float scale1=(float)ss.scale[layerID];
  float scale2=(float)ss.scale[layerID + 1];
  float ss0=1;
  float ss1=1;
  float ss2=1;
  for (  Point2D_I16 c : candidates) {
    sparseLaplace.setImage(ss.getLayer(layerID));
    float val=ss1 * (float)Math.abs(sparseLaplace.compute(c.x,c.y));
    int x0=(int)(c.x * scale1 / scale0);
    int y0=(int)(c.y * scale1 / scale0);
    int x2=(int)(c.x * scale1 / scale2);
    int y2=(int)(c.y * scale1 / scale2);
    if (checkMax(ss.getLayer(layerID - 1),val / ss0,x0,y0) && checkMax(ss.getLayer(layerID + 1),val / ss2,x2,y2)) {
      foundPoints.add(new ScalePoint((int)(c.x * scale1),(int)(c.y * scale1),scale1));
    }
  }
}
Program: 151118
Project: 151118
Buggy source:
/** 
 * Searches the pyramid layers up and down to see if the found 2D features are also scale space maximums.
 */
protected void findLocalScaleSpaceMax(GaussianScaleSpace<T,D> ss,int layerID){
  int index0=spaceIndex;
  int index1=(spaceIndex + 1) % 3;
  int index2=(spaceIndex + 2) % 3;
  List<Point2D_I16> candidates=maximums[index1];
  T image0=localSpace[index0];
  T image1=localSpace[index1];
  T image2=localSpace[index2];
  float scale0=(float)ss.getScale(layerID - 1);
  float scale1=(float)ss.getScale(layerID);
  float scale2=(float)ss.getScale(layerID + 1);
  float ss0=(float)Math.pow(scale0,scalePower);
  float ss1=(float)Math.pow(scale1,scalePower);
  float ss2=(float)Math.pow(scale2,scalePower);
  for (  Point2D_I16 c : candidates) {
    sparseLaplace.setImage(image1);
    float val=ss1 * (float)Math.abs(sparseLaplace.compute(c.x,c.y));
    if (checkMax(image0,ss0,val,c.x,c.y) && checkMax(image2,ss2,val,c.x,c.y)) {
      foundPoints.add(new ScalePoint(c.x,c.y,scale1));
    }
  }
}

Fixed version (ground truth):
/** 
 * Searches the pyramid layers up and down to see if the found 2D features are also scale space maximums.
 */
protected void findLocalScaleSpaceMax(GaussianScaleSpace<T,D> ss,int layerID){
  int index0=spaceIndex;
  int index1=(spaceIndex + 1) % 3;
  int index2=(spaceIndex + 2) % 3;
  List<Point2D_I16> candidates=maximums[index1];
  T image0=localSpace[index0];
  T image1=localSpace[index1];
  T image2=localSpace[index2];
  float scale0=(float)ss.getScale(layerID - 1);
  float scale1=(float)ss.getScale(layerID);
  float scale2=(float)ss.getScale(layerID + 1);
  float ss0=(float)Math.pow(scale0,2.0 * 0.75);
  float ss1=(float)Math.pow(scale1,2.0 * 0.75);
  float ss2=(float)Math.pow(scale2,2.0 * 0.75);
  for (  Point2D_I16 c : candidates) {
    sparseLaplace.setImage(image1);
    float val=ss1 * (float)Math.abs(sparseLaplace.compute(c.x,c.y));
    if (checkMax(image0,ss0,val,c.x,c.y) && checkMax(image2,ss2,val,c.x,c.y)) {
      foundPoints.add(new ScalePoint(c.x,c.y,scale1));
    }
  }
}
Program: 151119
Project: 151119
Buggy source:
/** 
 * Creates a   {@link boofcv.alg.feature.detect.interest.FeaturePyramid} which is uses a hessian blob detector.
 * @param featureRadius Size of the feature used to detect the corners.
 * @param cornerThreshold Minimum corner intensity required
 * @param maxFeatures Max number of features that can be found.
 * @param imageType Type of input image.
 * @param derivType Image derivative type.
 * @return CornerLaplaceScaleSpace
 */
public static <T extends ImageBase,D extends ImageBase>FeaturePyramid<T,D> hessianPyramid(int featureRadius,float cornerThreshold,int maxFeatures,Class<T> imageType,Class<D> derivType){
  GeneralFeatureIntensity<T,D> intensity=new WrapperLaplacianBlobIntensity<T,D>(HessianBlobIntensity.Type.DETERMINANT,derivType);
  FeatureExtractor extractor=createExtractor(featureRadius,cornerThreshold,intensity);
  GeneralFeatureDetector<T,D> detector=new GeneralFeatureDetector<T,D>(intensity,extractor,maxFeatures);
  AnyImageDerivative<T,D> deriv=UtilScaleSpace.createDerivatives(imageType,FactoryImageGenerator.create(derivType));
  return new FeaturePyramid<T,D>(detector,deriv,1);
}

Fixed version (ground truth):
/** 
 * Creates a   {@link boofcv.alg.feature.detect.interest.FeaturePyramid} which is uses a hessian blob detector.
 * @param featureRadius Size of the feature used to detect the corners.
 * @param cornerThreshold Minimum corner intensity required
 * @param maxFeatures Max number of features that can be found.
 * @param imageType Type of input image.
 * @param derivType Image derivative type.
 * @return CornerLaplaceScaleSpace
 */
public static <T extends ImageBase,D extends ImageBase>FeaturePyramid<T,D> hessianPyramid(int featureRadius,float cornerThreshold,int maxFeatures,Class<T> imageType,Class<D> derivType){
  GeneralFeatureIntensity<T,D> intensity=new WrapperLaplacianBlobIntensity<T,D>(HessianBlobIntensity.Type.DETERMINANT,derivType);
  FeatureExtractor extractor=createExtractor(featureRadius,cornerThreshold,intensity);
  GeneralFeatureDetector<T,D> detector=new GeneralFeatureDetector<T,D>(intensity,extractor,maxFeatures);
  AnyImageDerivative<T,D> deriv=UtilScaleSpace.createDerivatives(imageType,FactoryImageGenerator.create(derivType));
  return new FeaturePyramid<T,D>(detector,deriv,0);
}
Program: 151120
Project: 151120
Buggy source:
/** 
 * Creates a   {@link FeatureLaplaceScaleSpace} which is uses the Harris corner detector.
 * @param featureRadius Size of the feature used to detect the corners.
 * @param cornerThreshold Minimum corner intensity required
 * @param maxFeatures Max number of features that can be found.
 * @param imageType Type of input image.
 * @param derivType Image derivative type.
 * @return CornerLaplaceScaleSpace
 */
public static <T extends ImageBase,D extends ImageBase>FeaturePyramid<T,D> harrisPyramid(int featureRadius,float cornerThreshold,int maxFeatures,Class<T> imageType,Class<D> derivType){
  GradientCornerIntensity<D> harris=FactoryPointIntensityAlg.createHarris(featureRadius,0.04f,derivType);
  GeneralFeatureIntensity<T,D> intensity=new WrapperGradientCornerIntensity<T,D>(harris);
  FeatureExtractor extractor=createExtractor(featureRadius,cornerThreshold,intensity);
  GeneralFeatureDetector<T,D> detector=new GeneralFeatureDetector<T,D>(intensity,extractor,maxFeatures);
  AnyImageDerivative<T,D> deriv=UtilScaleSpace.createDerivatives(imageType,FactoryImageGenerator.create(derivType));
  return new FeaturePyramid<T,D>(detector,deriv,1);
}

Fixed version (ground truth):
/** 
 * Creates a   {@link FeatureLaplaceScaleSpace} which is uses the Harris corner detector.
 * @param featureRadius Size of the feature used to detect the corners.
 * @param cornerThreshold Minimum corner intensity required
 * @param maxFeatures Max number of features that can be found.
 * @param imageType Type of input image.
 * @param derivType Image derivative type.
 * @return CornerLaplaceScaleSpace
 */
public static <T extends ImageBase,D extends ImageBase>FeaturePyramid<T,D> harrisPyramid(int featureRadius,float cornerThreshold,int maxFeatures,Class<T> imageType,Class<D> derivType){
  GradientCornerIntensity<D> harris=FactoryPointIntensityAlg.createHarris(featureRadius,0.04f,derivType);
  GeneralFeatureIntensity<T,D> intensity=new WrapperGradientCornerIntensity<T,D>(harris);
  FeatureExtractor extractor=createExtractor(featureRadius,cornerThreshold,intensity);
  GeneralFeatureDetector<T,D> detector=new GeneralFeatureDetector<T,D>(intensity,extractor,maxFeatures);
  AnyImageDerivative<T,D> deriv=UtilScaleSpace.createDerivatives(imageType,FactoryImageGenerator.create(derivType));
  return new FeaturePyramid<T,D>(detector,deriv,0);
}
Program: 151121
Project: 151121
Buggy source:
public static void main(String args[]){
  BenchmarkStabilityDescribe<ImageFloat32,ImageFloat32> benchmark=new BenchmarkStabilityDescribe<ImageFloat32,ImageFloat32>(ImageFloat32.class,ImageFloat32.class);
  benchmark.testRotation();
}

Fixed version (ground truth):
public static void main(String args[]){
  BenchmarkStabilityDescribe<ImageFloat32,ImageFloat32> benchmark=new BenchmarkStabilityDescribe<ImageFloat32,ImageFloat32>(ImageFloat32.class,ImageFloat32.class);
  benchmark.testIntensity();
}
Program: 151122
Project: 151122
Buggy source:
@Override public double[] evaluateImage(BenchmarkAlgorithm alg,T image,double scale,double theta,List<Point2D_I32> points,List<Integer> indexes){
  ExtractFeatureDescription<T> extract=alg.getAlgorithm();
  currentDescriptions(image,extract,scale,theta,points,indexes);
  double associationScore=computeAssociationScore(indexes);
  computeErrorScore(indexes);
  double p50=errors.getFraction(0.5);
  double p90=errors.getFraction(0.9);
  return new double[]{associationScore,p50 * 10,p90 * 10};
}

Fixed version (ground truth):
@Override public double[] evaluateImage(BenchmarkAlgorithm alg,T image,double scale,double theta,List<Point2D_I32> points,List<Integer> indexes){
  ExtractFeatureDescription<T> extract=alg.getAlgorithm();
  currentDescriptions(image,extract,scale,theta,points,indexes);
  double associationScore=computeAssociationScore(indexes);
  computeErrorScore(indexes);
  double p50=errors.getFraction(0.5);
  double p90=errors.getFraction(0.9);
  return new double[]{current.size(),matcher.getMatches().size(),associationScore,p50 * 10,p90 * 10};
}
Program: 151123
Project: 151123
Buggy source:
private void computeErrorScore(List<Integer> indexes){
  errors.reset();
  for (int i=0; i < indexes.size(); i++) {
    TupleDesc_F64 f=currentList.get(i);
    TupleDesc_F64 e=initList.get(indexes.get(i));
    if (f != null && e != null) {
      double errorNorm=errorNorm(f,e);
      double initNorm=norm(e);
      errors.add(errorNorm / initNorm);
    }
  }
}

Fixed version (ground truth):
private void computeErrorScore(List<Integer> currentToInitialIndex){
  errors.reset();
  for (int i=0; i < currentToInitialIndex.size(); i++) {
    TupleDesc_F64 f=currentList.get(i);
    TupleDesc_F64 e=initList.get(currentToInitialIndex.get(i));
    if (f != null && e != null) {
      double errorNorm=errorNorm(f,e);
      double initNorm=norm(e);
      errors.add(errorNorm / initNorm);
    }
  }
}
Program: 151124
Project: 151124
Buggy source:
@Override public String[] getMetricNames(){
  return new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
}

Fixed version (ground truth):
@Override public String[] getMetricNames(){
  return new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
}
Program: 151125
Project: 151125
Buggy source:
@Override public double[] evaluateImage(BenchmarkAlgorithm alg,T image,DistortParam param){
  Affine2D_F32 initToImage=StabilityEvaluatorPoint.createTransform(param.scale,param.rotation,image);
  List<Point2D_I32> original=transformOriginal(image,initToImage);
  InterestPointDetector<T> detector=alg.getAlgorithm();
  detector.detect(image);
  List<Point2D_I32> found=createDetectionList(detector);
  int numMissed=0;
  for (  Point2D_I32 origPt : original) {
    double bestDist=Double.MAX_VALUE;
    for (    Point2D_I32 p : found) {
      double d=UtilPoint2D_I32.distance(origPt,p);
      if (d < bestDist) {
        bestDist=d;
      }
    }
    if (bestDist > matchTolerance) {
      numMissed++;
    }
  }
  double[] results=new double[3];
  results[0]=original.size();
  results[1]=100.0 * (original.size() - numMissed) / (double)original.size();
  return results;
}

Fixed version (ground truth):
@Override public double[] evaluateImage(BenchmarkAlgorithm alg,T image,DistortParam param){
  Affine2D_F32 initToImage=StabilityEvaluatorPoint.createTransform(param.scale,param.rotation,image.width,image.height);
  List<Point2D_I32> original=transformOriginal(image,initToImage);
  InterestPointDetector<T> detector=alg.getAlgorithm();
  detector.detect(image);
  List<Point2D_I32> found=createDetectionList(detector);
  int numMissed=0;
  for (  Point2D_I32 origPt : original) {
    double bestDist=Double.MAX_VALUE;
    for (    Point2D_I32 p : found) {
      double d=UtilPoint2D_I32.distance(origPt,p);
      if (d < bestDist) {
        bestDist=d;
      }
    }
    if (bestDist > matchTolerance) {
      numMissed++;
    }
  }
  double[] results=new double[3];
  results[0]=original.size();
  results[1]=100.0 * (original.size() - numMissed) / (double)original.size();
  return results;
}
Program: 151126
Project: 151126
Buggy source:
public List<MetricResult> evaluate(BufferedImage original){
  T image=ConvertBufferedImage.convertFrom(original,null,imageType);
  T noisy=(T)image._createNew(image.width,image.height);
  evaluator.extractInitial(alg,image);
  List<MetricResult> results=createResultsStorage(evaluator,variable);
  for (int i=0; i < variable.length; i++) {
    distortImage(image,distortedImage,variable[i]);
    DistortParam param=createDistortParam(variable[i]);
    double[] metrics=evaluator.evaluateImage(alg,distortedImage,param);
    for (int j=0; j < results.size(); j++) {
      results.get(j).observed[i]=metrics[j];
    }
  }
  return results;
}

Fixed version (ground truth):
public List<MetricResult> evaluate(BufferedImage original){
  T image=ConvertBufferedImage.convertFrom(original,null,imageType);
  evaluator.extractInitial(alg,image);
  List<MetricResult> results=createResultsStorage(evaluator,variable);
  for (int i=0; i < variable.length; i++) {
    distortImage(image,distortedImage,variable[i]);
    DistortParam param=createDistortParam(variable[i]);
    double[] metrics=evaluator.evaluateImage(alg,distortedImage,param);
    for (int j=0; j < results.size(); j++) {
      results.get(j).observed[i]=metrics[j];
    }
  }
  return results;
}
Program: 151127
Project: 151127
Buggy source:
public static <T extends ImageBase>BenchmarkFeatureDistort<T> rotate(Class<T> imageType){
  double thetas[]=UtilOrientationBenchmark.makeSample(0,Math.PI,20);
  return new Rotation<T>(SEED,thetas,imageType);
}

Fixed version (ground truth):
public static <T extends ImageBase>BenchmarkFeatureDistort<T> rotate(Class<T> imageType){
  double thetas[]=UtilOrientationBenchmark.makeSample(0,2.0 * Math.PI,20);
  return new Rotation<T>(SEED,thetas,imageType);
}
Program: 151128
Project: 151128
Buggy source:
@Override protected void distortImage(T image,T distortedImage,double scale){
  distortedImage.reshape(image.width,image.height);
  Affine2D_F32 initToImage=StabilityEvaluatorPoint.createScale((float)scale,image.width,image.height);
  Affine2D_F32 imageToInit=initToImage.invert(null);
  PixelTransformAffine affine=new PixelTransformAffine(imageToInit);
  ImageDistort<T> distorter=DistortSupport.createDistort(imageType,affine,TypeInterpolate.BILINEAR);
  distorter.apply(image,distortedImage,125);
}

Fixed version (ground truth):
@Override protected void distortImage(T image,T distortedImage,double scale){
  distortedImage.reshape(image.width,image.height);
  Affine2D_F32 initToImage=StabilityEvaluatorPoint.createScale((float)scale,image.width,image.height);
  Affine2D_F32 imageToInit=initToImage.invert(null);
  PixelTransformAffine affine=new PixelTransformAffine(imageToInit);
  InterpolatePixel<T> interp=FactoryInterpolation.createPixel(0,255,TypeInterpolate.BILINEAR,imageType);
  ImageDistort<T> distorter=DistortSupport.createDistort(imageType,affine,interp,null);
  distorter.apply(image,distortedImage);
}
Program: 151129
Project: 151129
Buggy source:
public static Affine2D_F32 createTransform(double scale,double theta,ImageBase image){
  Affine2D_F32 a=createScale((float)scale,image.width,image.height);
  Affine2D_F32 b=DistortSupport.transformRotate(image.width / 2f,image.height / 2f,(float)theta).getModel();
  return a.concat(b,null);
}

Fixed version (ground truth):
public static Affine2D_F32 createTransform(double scale,double theta,int imageWidth,int imageHeight){
  Affine2D_F32 a=createScale((float)scale,imageWidth,imageHeight);
  Affine2D_F32 b=DistortSupport.transformRotate(imageWidth / 2,imageHeight / 2,imageWidth / 2,imageHeight / 2,(float)theta).getModel();
  return a.concat(b,null).invert(null);
}
Program: 151130
Project: 151130
Buggy source:
public static void main(String args[]){
  double tolerance=3;
  ScoreAssociation score=new ScoreAssociateEuclideanSq();
  GeneralAssociation<TupleDesc_F64> assoc=FactoryAssociationTuple.greedy(score,Double.MAX_VALUE,-1,true);
  BenchmarkFeatureHomography app=new BenchmarkFeatureHomography(assoc,"String_Node_Str","String_Node_Str",tolerance);
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
}

Fixed version (ground truth):
public static void main(String args[]){
  double tolerance=3;
  ScoreAssociation score=new ScoreAssociateEuclideanSq();
  GeneralAssociation<TupleDesc_F64> assoc=FactoryAssociationTuple.greedy(score,Double.MAX_VALUE,-1,true);
  BenchmarkFeatureHomography app=new BenchmarkFeatureHomography(assoc,"String_Node_Str","String_Node_Str",tolerance);
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
}
Program: 151131
Project: 151131
Buggy source:
public static void main(String args[]){
  double tolerance=3;
  ScoreAssociation score=new ScoreAssociateEuclideanSq();
  GeneralAssociation<TupleDesc_F64> assoc=FactoryAssociation.greedy(score,Double.MAX_VALUE,-1,true);
  BenchmarkFeatureHomography app=new BenchmarkFeatureHomography(assoc,"String_Node_Str","String_Node_Str",tolerance);
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
}

Fixed version (ground truth):
public static void main(String args[]){
  double tolerance=3;
  ScoreAssociation score=new ScoreAssociateEuclideanSq();
  GeneralAssociation<TupleDesc_F64> assoc=FactoryAssociation.greedy(score,Double.MAX_VALUE,-1,true);
  BenchmarkFeatureHomography app=new BenchmarkFeatureHomography(assoc,"String_Node_Str","String_Node_Str",tolerance);
  app.evaluate("String_Node_Str");
  app.evaluate("String_Node_Str");
}
Program: 151132
Project: 151132
Buggy source:
public static <T extends ImageBase>void doStuff(String directory,String imageSuffix,Class<T> imageType) throws FileNotFoundException {
  int radius=12;
  int numAngles=8;
  int numJoints=2;
  IntensityGraphDesc graph=createCircle(radius,numAngles,numJoints);
  connectSpiderWeb(numAngles,numJoints,graph);
  ExtractFeatureDescription<T> alg=FactoryExtractFeatureDescription.brief(16,512,-1,4,false,imageType);
  OrientationImage<T> orientation=FactoryOrientationAlgs.nogradient(alg.getRadius(),imageType);
  CreateDescriptionFile<T> cdf=new CreateDescriptionFile<T>(alg,orientation,imageType,"String_Node_Str");
  cdf.directory(directory,imageSuffix,"String_Node_Str");
}

Fixed version (ground truth):
public static <T extends ImageBase>void doStuff(String directory,String imageSuffix,Class<T> imageType) throws FileNotFoundException {
  ExtractFeatureDescription<T> alg=FactoryExtractFeatureDescription.surf(true,imageType);
  int radius=12;
  int numAngles=8;
  int numJoints=2;
  IntensityGraphDesc graph=createCircle(radius,numAngles,numJoints);
  connectSpiderWeb(numAngles,numJoints,graph);
  OrientationImage<T> orientation=FactoryOrientationAlgs.nogradient(alg.getRadius(),imageType);
  CreateDescriptionFile<T> cdf=new CreateDescriptionFile<T>(alg,orientation,imageType,"String_Node_Str");
  cdf.directory(directory,imageSuffix,"String_Node_Str");
}
Program: 151133
Project: 151133
Buggy source:
public static void main(String args[]) throws FileNotFoundException {
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
}

Fixed version (ground truth):
public static void main(String args[]) throws FileNotFoundException {
  doStuff("String_Node_Str","String_Node_Str",ImageFloat32.class);
}
Program: 151134
Project: 151134
Buggy source:
private void printWeighted(){
  out.print("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
private void printWeighted(){
  out.print("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 151135
Project: 151135
Buggy source:
private void printPreamble(){
  out.print(CodeGeneratorUtil.copyright);
  out.print("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str" + imageType.getImageName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ imageType.getImageName()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ imageType.getImageName()+ "String_Node_Str"+ "String_Node_Str"+ imageType.getImageName()+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
private void printPreamble() throws FileNotFoundException {
  setOutputFile(className);
  out.print("String_Node_Str" + "String_Node_Str" + imageType.getImageName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ imageType.getImageName()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ imageType.getImageName()+ "String_Node_Str"+ "String_Node_Str"+ imageType.getImageName()+ "String_Node_Str"+ "String_Node_Str");
}
Program: 151136
Project: 151136
Buggy source:
@Override protected double computeWeightedOrientation(int c_x,int c_y){
  double windowRadius=windowSize / 2.0;
  int w=rect.x1 - rect.x0;
  double bestScore=-1;
  double bestAngle=0;
  double stepAngle=Math.PI * 2.0 / numAngles;
  int N=w * (rect.y1 - rect.y0);
  for (double angle=-Math.PI; angle < Math.PI; angle+=stepAngle) {
    double dx=0;
    double dy=0;
    for (int i=0; i < N; i++) {
      double diff=UtilAngle.dist(angle,angles[i]);
      if (diff <= windowRadius) {
        int localX=i % w;
        int localY=i / w;
        double ww=weights.get(localX,localY);
        int x=rect.x0 + i % w;
        int y=rect.y0 + i / w;
        dx+=ww * derivX.get(x,y);
        dy+=ww * derivY.get(x,y);
      }
    }
    double n=dx * dx + dy * dy;
    if (n > bestScore) {
      bestAngle=Math.atan2(dy,dx);
      bestScore=n;
    }
  }
  return bestAngle;
}

Fixed version (ground truth):
@Override protected double computeWeightedOrientation(int c_x,int c_y){
  computeAngles();
  double windowRadius=windowSize / 2.0;
  int w=rect.x1 - rect.x0;
  double bestScore=-1;
  double bestAngle=0;
  double stepAngle=Math.PI * 2.0 / numAngles;
  int N=w * (rect.y1 - rect.y0);
  for (double angle=-Math.PI; angle < Math.PI; angle+=stepAngle) {
    double dx=0;
    double dy=0;
    for (int i=0; i < N; i++) {
      double diff=UtilAngle.dist(angle,angles[i]);
      if (diff <= windowRadius) {
        int localX=i % w;
        int localY=i / w;
        double ww=weights.get(localX,localY);
        int x=rect.x0 + i % w;
        int y=rect.y0 + i / w;
        dx+=ww * derivX.get(x,y);
        dy+=ww * derivY.get(x,y);
      }
    }
    double n=dx * dx + dy * dy;
    if (n > bestScore) {
      bestAngle=Math.atan2(dy,dx);
      bestScore=n;
    }
  }
  return bestAngle;
}