nus-yam/ex-repair huggingface dataset:
Program: 150671
Project: 150671
Buggy source:
/** 
 * Localizizes the alignment pattern crudely by searching for the black box in the center by looking for its edges in the gray scale image
 * @return true if success or false if it doesn't resemble an alignment pattern
 */
protected boolean localize(QrCode.Alignment pattern,float guessX,float guessY){
  for (int i=0; i < arrayY.length; i++) {
    float x=guessX - 1.25f + i * 2.5f / 10.0f;
    float y=guessY - 1.25f + i * 2.5f / 10.0f;
    arrayX[i]=interpolate.get(x,guessY);
    arrayY[i]=interpolate.get(guessX,y);
  }
  int downX=greatestDown(arrayX);
  int upX=greatestUp(arrayX,downX);
  if (downX == -1 || upX == -1)   return false;
  int downY=greatestDown(arrayY);
  int upY=greatestUp(arrayY,downY);
  if (downY == -1 || upY == -1)   return false;
  pattern.moduleFound.x=guessX - 1.25f + (downX + upX) * 2.5f / 20.0f;
  pattern.moduleFound.y=guessY - 1.25f + (downY + upY) * 2.5f / 20.0f;
  gridToImage.compute((float)pattern.moduleFound.x,(float)pattern.moduleFound.y,p32);
  pattern.pixel.set(p32.x,p32.y);
  return true;
}

Fixed version (ground truth):
/** 
 * Localizizes the alignment pattern crudely by searching for the black box in the center by looking for its edges in the gray scale image
 * @return true if success or false if it doesn't resemble an alignment pattern
 */
boolean localize(QrCode.Alignment pattern,float guessX,float guessY){
  for (int i=0; i < arrayY.length; i++) {
    float x=guessX - 1.5f + i * 3f / 12.0f;
    float y=guessY - 1.5f + i * 3f / 12.0f;
    gridToImage.compute(x,guessY,pixel);
    arrayX[i]=interpolate.get(pixel.x,pixel.y);
    gridToImage.compute(guessX,y,pixel);
    arrayY[i]=interpolate.get(pixel.x,pixel.y);
  }
  int downX=greatestDown(arrayX);
  if (downX == -1)   return false;
  int upX=greatestUp(arrayX,downX);
  if (upX == -1)   return false;
  int downY=greatestDown(arrayY);
  if (downY == -1)   return false;
  int upY=greatestUp(arrayY,downY);
  if (upY == -1)   return false;
  pattern.moduleFound.x=guessX - 1.5f + (downX + upX) * 3f / 24.0f;
  pattern.moduleFound.y=guessY - 1.5f + (downY + upY) * 3f / 24.0f;
  gridToImage.compute((float)pattern.moduleFound.x,(float)pattern.moduleFound.y,pixel);
  pattern.pixel.set(pixel.x,pixel.y);
  return true;
}
Program: 150672
Project: 150672
Buggy source:
static int greatestUp(float array[],int start){
  int best=-1;
  float bestScore=0;
  for (int i=start; i < array.length; i++) {
    float diff=array[i] - array[i - 1];
    if (diff > bestScore) {
      bestScore=diff;
      best=i;
    }
  }
  return best;
}

Fixed version (ground truth):
static int greatestUp(float array[],int start){
  int best=-1;
  float bestScore=0;
  for (int i=start; i < array.length; i++) {
    float diff=array[i] - array[i - 1];
    if (diff > bestScore) {
      bestScore=diff;
      best=i - 1;
    }
  }
  return best;
}
Program: 150673
Project: 150673
Buggy source:
/** 
 * Computes an approximate homography the initialize the search. Avoid corner features since they are more likely to be damaged. Outside features are also likely to be damaged fewer of them are sampled
 * @param qr The QR code with detected position patterns
 */
private boolean computeHomography(QrCode qr){
  int gridSize=patternLocations.size[qr.version];
  associatedPairs.get(0).p1.set(7,0);
  associatedPairs.get(1).p1.set(7,7);
  associatedPairs.get(2).p1.set(0,7);
  associatedPairs.get(3).p1.set(gridSize - 7,0);
  associatedPairs.get(4).p1.set(gridSize - 7,7);
  associatedPairs.get(5).p1.set(0,gridSize - 7);
  associatedPairs.get(6).p1.set(7,gridSize - 7);
  set(0,qr.ppCorner,1);
  set(1,qr.ppCorner,2);
  set(2,qr.ppCorner,3);
  set(3,qr.ppRight,0);
  set(4,qr.ppRight,3);
  set(5,qr.ppDown,0);
  set(6,qr.ppDown,1);
  if (!computeHomography.process(associatedPairs,H))   return false;
  ConvertMatrixData.convert(H,H32);
  UnrolledInverseFromMinor_FDRM.inv(H32,H_inv);
  gridToImage.set(H32);
  imageToGrid.set(H_inv);
  return true;
}

Fixed version (ground truth):
/** 
 * Computes an approximate homography the initialize the search. Avoid corner features since they are more likely to be damaged. Outside features are also likely to be damaged fewer of them are sampled
 * @param qr The QR code with detected position patterns
 */
boolean computeHomography(QrCode qr){
  int gridSize=patternLocations.size[qr.version];
  associatedPairs.get(0).p1.set(7,0);
  associatedPairs.get(1).p1.set(7,7);
  associatedPairs.get(2).p1.set(0,7);
  associatedPairs.get(3).p1.set(gridSize - 7,0);
  associatedPairs.get(4).p1.set(gridSize - 7,7);
  associatedPairs.get(5).p1.set(0,gridSize - 7);
  associatedPairs.get(6).p1.set(7,gridSize - 7);
  set(0,qr.ppCorner,1);
  set(1,qr.ppCorner,2);
  set(2,qr.ppCorner,3);
  set(3,qr.ppRight,0);
  set(4,qr.ppRight,3);
  set(5,qr.ppDown,0);
  set(6,qr.ppDown,1);
  if (!computeHomography.process(associatedPairs,H))   return false;
  ConvertMatrixData.convert(H,H32);
  UnrolledInverseFromMinor_FDRM.inv(H32,H_inv);
  gridToImage.set(H32);
  imageToGrid.set(H_inv);
  return true;
}
Program: 150674
Project: 150674
Buggy source:
/** 
 * Searches for the greatest down slope in the list
 */
static int greatestDown(float array[]){
  int best=-1;
  float bestScore=0;
  for (int i=1; i < array.length; i++) {
    float diff=array[i] - array[i - 1];
    if (diff < bestScore) {
      bestScore=diff;
      best=i;
    }
  }
  return best;
}

Fixed version (ground truth):
/** 
 * Searches for the greatest down slope in the list
 */
static int greatestDown(float array[]){
  int best=-1;
  float bestScore=0;
  for (int i=5; i < array.length; i++) {
    float diff=(4.0f / 2.0f) * (array[i - 5] + array[i]);
    diff-=array[i - 4] + array[i - 3] + array[i - 2]+ array[i - 1];
    if (diff > bestScore) {
      bestScore=diff;
      best=i - 4;
    }
  }
  return best;
}
Program: 150675
Project: 150675
Buggy source:
/** 
 * Creates a list of alignment patterns to look for and their grid coordinates
 */
private void initializePatterns(QrCode qr){
  int where[]=patternLocations.alignment[qr.version];
  qr.alignment.reset();
  for (int row=0; row < where.length; row++) {
    for (int col=0; col < where.length; col++) {
      boolean skip=false;
      if (row == 0 & col == 0)       skip=true;
 else       if (row == where.length - 1 & col == 0)       skip=true;
 else       if (row == where.length - 1 & col == where.length - 1)       skip=true;
      if (skip) {
        lookup.add(null);
      }
 else {
        QrCode.Alignment a=qr.alignment.grow();
        a.moduleX=col;
        a.moduleY=row;
        lookup.add(a);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Creates a list of alignment patterns to look for and their grid coordinates
 */
void initializePatterns(QrCode qr){
  int qrsize=patternLocations.size[qr.version];
  int where[]=patternLocations.alignment[qr.version];
  qr.alignment.reset();
  lookup.reset();
  for (int row=where.length - 1; row >= 0; row--) {
    for (int col=0; col < where.length; col++) {
      boolean skip=false;
      if (row == 0 & col == 0)       skip=true;
 else       if (row == where.length - 1 & col == 0)       skip=true;
 else       if (row == where.length - 1 & col == where.length - 1)       skip=true;
      if (skip) {
        lookup.add(null);
      }
 else {
        QrCode.Alignment a=qr.alignment.grow();
        a.moduleX=where[col];
        a.moduleY=qrsize - where[row] - 1;
        lookup.add(a);
      }
    }
  }
}
Program: 150676
Project: 150676
Buggy source:
public QrCodeAlignmentPatternLocator(Class<T> imageType){
  interpolate=FactoryInterpolation.nearestNeighborPixelS(imageType);
  for (int i=0; i < 5; i++) {
    associatedPairs.add(new AssociatedPair());
  }
}

Fixed version (ground truth):
public QrCodeAlignmentPatternLocator(Class<T> imageType){
  interpolate=FactoryInterpolation.nearestNeighborPixelS(imageType);
  interpolate.setBorder(FactoryImageBorder.single(imageType,BorderType.EXTENDED));
  for (int i=0; i < 7; i++) {
    associatedPairs.add(new AssociatedPair());
  }
}
Program: 150677
Project: 150677
Buggy source:
private boolean localizePositionPatterns(int[] alignmentLocations){
  int size=alignmentLocations.length;
  for (int row=0; row < size; row++) {
    for (int col=0; col < size; col++) {
      QrCode.Alignment a=lookup.get(row * size + col);
      if (a == null)       continue;
      double adjY=0, adjX=0;
      if (row > 0) {
        QrCode.Alignment p=lookup.get((row - 1) * size + col);
        adjY=p.moduleY + 0.5 - p.moduleFound.y;
      }
      if (col > 0) {
        QrCode.Alignment p=lookup.get((row - 1) * size + col);
        adjX=p.moduleX + 0.5 - p.moduleFound.x;
      }
      if (!localize(a,(float)(a.moduleX + 0.5 + adjX),(float)(a.moduleY + 0.5 + adjY)))       return false;
    }
  }
  return true;
}

Fixed version (ground truth):
boolean localizePositionPatterns(int[] alignmentLocations){
  int size=alignmentLocations.length;
  for (int row=0; row < size; row++) {
    for (int col=0; col < size; col++) {
      QrCode.Alignment a=lookup.get(row * size + col);
      if (a == null)       continue;
      double adjY=0, adjX=0;
      if (row > 0) {
        QrCode.Alignment p=lookup.get((row - 1) * size + col);
        if (p != null)         adjY=p.moduleY + 0.5 - p.moduleFound.y;
      }
      if (col > 0) {
        QrCode.Alignment p=lookup.get(row * size + col - 1);
        if (p != null)         adjX=p.moduleX + 0.5 - p.moduleFound.x;
      }
      if (!centerOnSquare(a,(float)(a.moduleX + 0.5 + adjX),(float)(a.moduleY + 0.5 + adjY))) {
        return false;
      }
      if (!localize(a,(float)a.moduleFound.x,(float)a.moduleFound.y)) {
        return false;
      }
    }
  }
  return true;
}
Program: 150678
Project: 150678
Buggy source:
public static ConfigThreshold local(ThresholdType type,int radius){
  if (!type.isAdaptive())   throw new IllegalArgumentException("String_Node_Str");
  if (type.isGlobal())   throw new IllegalArgumentException("String_Node_Str");
  if (type == ThresholdType.LOCAL_BLOCK_MIN_MAX) {
    return new ConfigThresholdBlockMinMax(radius,10,true);
  }
 else {
    ConfigThreshold config=new ConfigThreshold();
    config.type=type;
    config.radius=radius;
    return config;
  }
}

Fixed version (ground truth):
public static <T extends ConfigThreshold>T local(ThresholdType type,int radius){
  if (!type.isAdaptive())   throw new IllegalArgumentException("String_Node_Str");
  if (type.isGlobal())   throw new IllegalArgumentException("String_Node_Str");
  ConfigThreshold config;
  if (type == ThresholdType.LOCAL_BLOCK_MIN_MAX) {
    config=new ConfigThresholdBlockMinMax(radius,10,true);
  }
 else   if (type == ThresholdType.LOCAL_BLOCK_OTSU) {
    config=new ConfigThresholdBlockOtsu();
  }
 else {
    config=new ConfigThreshold();
  }
  config.type=type;
  config.radius=radius;
  return (T)config;
}
Program: 150679
Project: 150679
Buggy source:
/** 
 * Step 2: If the pixel below is unmarked and white then it must be an internal contour Same behavior it the pixel in question has been labeled or not already
 */
private void handleStep2(GrayS32 labeled,int label){
  if (label == 0)   label=labeled.data[indexOut - 1];
  Contour c=contours.get(label - 1);
  List<Point2D_I32> inner=storageLists.grow();
  inner.clear();
  tracer.setMaxContourSize(saveInternalContours ? maxContourSize : 0);
  tracer.trace(label,x,y,false,inner);
  if (inner.size() >= maxContourSize || inner.size() == 0) {
    storagePoints.size-=inner.size();
    storageLists.removeTail();
    inner.clear();
  }
  c.internal.add(inner);
}

Fixed version (ground truth):
/** 
 * Step 2: If the pixel below is unmarked and white then it must be an internal contour Same behavior it the pixel in question has been labeled or not already
 */
private void handleStep2(GrayS32 labeled,int label){
  if (label == 0)   label=labeled.data[indexOut - 1];
  Contour c=contours.get(label - 1);
  List<Point2D_I32> inner=storageLists.grow();
  inner.clear();
  tracer.setMaxContourSize(saveInternalContours ? maxContourSize : 0);
  tracer.trace(label,x,y,false,inner);
  if (inner.size() >= maxContourSize) {
    storagePoints.size-=inner.size();
    inner.clear();
  }
  c.internal.add(inner);
}
Program: 150682
Project: 150682
Buggy source:
/** 
 * See if it can detect targets distorted by fisheye lens. Entire target is always seen
 */
@Test public void fisheye_fullview(){
  CameraUniversalOmni model=CalibrationIO.load(getClass().getResource("String_Node_Str"));
  SimulatePlanarWorld simulator=new SimulatePlanarWorld();
  simulator.setCamera(model);
  List<Point2D_F64> locations2D=new ArrayList<>();
  GrayF32 pattern=new GrayF32(1,1);
  for (int i=0; i < targetConfigs.size(); i++) {
    DetectorFiducialCalibration detector=createDetector(targetConfigs.get(i));
    renderTarget(targetConfigs.get(i),simulatedTargetWidth,pattern,locations2D);
    simulator.resetScene();
    Se3_F64 markerToWorld=new Se3_F64();
    simulator.addTarget(markerToWorld,simulatedTargetWidth,pattern);
    for (int j=0; j < fisheye_poses.size(); j++) {
      System.out.println("String_Node_Str" + j);
      markerToWorld.set(fisheye_poses.get(j));
      checkRenderedResults(detector,simulator,locations2D);
    }
  }
}

Fixed version (ground truth):
/** 
 * See if it can detect targets distorted by fisheye lens. Entire target is always seen
 */
@Test public void fisheye_fullview(){
  CameraUniversalOmni model=CalibrationIO.load(getClass().getResource("String_Node_Str"));
  SimulatePlanarWorld simulator=new SimulatePlanarWorld();
  simulator.setCamera(model);
  List<Point2D_F64> locations2D=new ArrayList<>();
  GrayF32 pattern=new GrayF32(1,1);
  for (int i=0; i < targetConfigs.size(); i++) {
    DetectorFiducialCalibration detector=createDetector(targetConfigs.get(i));
    renderTarget(targetConfigs.get(i),simulatedTargetWidth,pattern,locations2D);
    simulator.resetScene();
    Se3_F64 markerToWorld=new Se3_F64();
    simulator.addTarget(markerToWorld,simulatedTargetWidth,pattern);
    failedToDetect=0;
    for (int j=0; j < fisheye_poses.size(); j++) {
      markerToWorld.set(fisheye_poses.get(j));
      checkRenderedResults(detector,simulator,locations2D);
    }
  }
  assertTrue(failedToDetect <= fisheyeAllowedFails);
}
Program: 150683
Project: 150683
Buggy source:
private void checkRenderedResults(DetectorFiducialCalibration detector,SimulatePlanarWorld simulator,List<Point2D_F64> locations2D){
  simulator.render();
  if (!detector.process(simulator.getOutput())) {
    visualize(simulator,locations2D,null);
    fail("String_Node_Str");
  }
  checkResults(simulator,detector.getDetectedPoints(),locations2D);
}

Fixed version (ground truth):
private void checkRenderedResults(DetectorFiducialCalibration detector,SimulatePlanarWorld simulator,List<Point2D_F64> locations2D){
  simulator.render();
  if (!detector.process(simulator.getOutput())) {
    visualize(simulator,locations2D,null);
    failedToDetect++;
    return;
  }
  checkResults(simulator,detector.getDetectedPoints(),locations2D);
}
Program: 150685
Project: 150685
Buggy source:
public TestCalibrationDetectorCircleHexagonalGrid(){
  targetConfigs.add(new ConfigCircleHexagonalGrid(5,5,20,24));
  targetConfigs.add(new ConfigCircleHexagonalGrid(5,4,20,24));
  fisheyeMatchTol=10;
}

Fixed version (ground truth):
public TestCalibrationDetectorCircleHexagonalGrid(){
  targetConfigs.add(new ConfigCircleHexagonalGrid(5,5,20,24));
  targetConfigs.add(new ConfigCircleHexagonalGrid(5,6,20,24));
  targetConfigs.add(new ConfigCircleHexagonalGrid(6,6,20,24));
  fisheyeMatchTol=10;
  fisheyeAllowedFails=4;
}
Program: 150686
Project: 150686
Buggy source:
@Override protected List<EllipseRotated_F64> getFoundEllipses(){
  return detector.getDetector().getEllipseDetector().getFoundEllipses().toList();
}

Fixed version (ground truth):
@Override protected List<EllipseRotated_F64> getFoundEllipses(){
  return detector.getDetector().getEllipseDetector().getFoundEllipses(null);
}
Program: 150687
Project: 150687
Buggy source:
@Override protected void renderClusters(Graphics2D g2,double scale){
  List<EllipseRotated_F64> found=detector.getDetector().getEllipseDetector().getFoundEllipses().toList();
  List<List<EllipsesIntoClusters.Node>> clusters=detector.getDetector().getClusters();
  g2.setStroke(new BasicStroke(2));
  int id=0;
  for (  List<EllipsesIntoClusters.Node> c : clusters) {
    g2.setColor(colorId[Math.min(id++,colorId.length - 1)]);
    for (    EllipsesIntoClusters.Node n : c) {
      EllipseRotated_F64 a=found.get(n.which);
      for (int i=0; i < n.connections.size; i++) {
        EllipseRotated_F64 b=found.get(n.connections.get(i));
        g2.drawLine((int)(a.center.x * scale),(int)(a.center.y * scale),(int)(b.center.x * scale),(int)(b.center.y * scale));
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void renderClusters(Graphics2D g2,double scale){
  List<EllipseRotated_F64> found=detector.getDetector().getEllipseDetector().getFoundEllipses(null);
  List<List<EllipsesIntoClusters.Node>> clusters=detector.getDetector().getClusters();
  g2.setStroke(new BasicStroke(2));
  int id=0;
  for (  List<EllipsesIntoClusters.Node> c : clusters) {
    g2.setColor(colorId[Math.min(id++,colorId.length - 1)]);
    for (    EllipsesIntoClusters.Node n : c) {
      EllipseRotated_F64 a=found.get(n.which);
      for (int i=0; i < n.connections.size; i++) {
        EllipseRotated_F64 b=found.get(n.connections.get(i));
        g2.drawLine((int)(a.center.x * scale),(int)(a.center.y * scale),(int)(b.center.x * scale),(int)(b.center.y * scale));
      }
    }
  }
}
Program: 150688
Project: 150688
Buggy source:
@Override protected List<EllipseRotated_F64> getFoundEllipses(){
  return detector.getDetector().getEllipseDetector().getFoundEllipses().toList();
}

Fixed version (ground truth):
@Override protected List<EllipseRotated_F64> getFoundEllipses(){
  return detector.getDetector().getEllipseDetector().getFoundEllipses(null);
}
Program: 150689
Project: 150689
Buggy source:
@Override protected void renderClusters(Graphics2D g2,double scale){
  List<EllipseRotated_F64> found=detector.getDetector().getEllipseDetector().getFoundEllipses().toList();
  List<List<EllipsesIntoClusters.Node>> clusters=detector.getDetector().getClusters();
  g2.setStroke(new BasicStroke(2));
  int id=0;
  for (  List<EllipsesIntoClusters.Node> c : clusters) {
    g2.setColor(colorId[Math.min(id++,colorId.length - 1)]);
    for (    EllipsesIntoClusters.Node n : c) {
      EllipseRotated_F64 a=found.get(n.which);
      for (int i=0; i < n.connections.size; i++) {
        EllipseRotated_F64 b=found.get(n.connections.get(i));
        g2.drawLine((int)(a.center.x * scale),(int)(a.center.y * scale),(int)(b.center.x * scale),(int)(b.center.y * scale));
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void renderClusters(Graphics2D g2,double scale){
  List<BinaryEllipseDetector.EllipseInfo> found=detector.getDetector().getEllipseDetector().getFound().toList();
  List<List<EllipsesIntoClusters.Node>> clusters=detector.getDetector().getClusters();
  g2.setStroke(new BasicStroke(2));
  int id=0;
  for (  List<EllipsesIntoClusters.Node> c : clusters) {
    g2.setColor(colorId[Math.min(id++,colorId.length - 1)]);
    for (    EllipsesIntoClusters.Node n : c) {
      EllipseRotated_F64 a=found.get(n.which).ellipse;
      for (int i=0; i < n.connections.size; i++) {
        EllipseRotated_F64 b=found.get(n.connections.get(i)).ellipse;
        g2.drawLine((int)(a.center.x * scale),(int)(a.center.y * scale),(int)(b.center.x * scale),(int)(b.center.y * scale));
      }
    }
  }
}
Program: 150690
Project: 150690
Buggy source:
@Override protected void paintInPanel(AffineTransform tran,Graphics2D g2){
  DetectEllipseControlPanel controls=(DetectEllipseControlPanel)DetectBlackEllipseApp.this.controls;
synchronized (DetectBlackEllipseApp.this) {
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_PURE);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    if (controls.bShowContour) {
      List<Contour> contours=detector.getAllContours();
      g2.setStroke(new BasicStroke(1));
      VisualizeBinaryData.render(contours,null,Color.CYAN,scale,g2);
    }
    if (controls.bShowShapes) {
      List<EllipseRotated_F64> ellipses=detector.getFoundEllipses().toList();
      g2.setColor(Color.RED);
      g2.setStroke(new BasicStroke(3));
      for (      EllipseRotated_F64 p : ellipses) {
        VisualizeShapes.drawEllipse(p,scale,g2);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void paintInPanel(AffineTransform tran,Graphics2D g2){
  DetectEllipseControlPanel controls=(DetectEllipseControlPanel)DetectBlackEllipseApp.this.controls;
synchronized (DetectBlackEllipseApp.this) {
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_PURE);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    if (controls.bShowContour) {
      List<Contour> contours=detector.getAllContours();
      g2.setStroke(new BasicStroke(1));
      VisualizeBinaryData.render(contours,null,Color.CYAN,scale,g2);
    }
    if (controls.bShowShapes) {
      List<BinaryEllipseDetector.EllipseInfo> ellipses=detector.getFound().toList();
      g2.setColor(Color.RED);
      g2.setStroke(new BasicStroke(3));
      for (      BinaryEllipseDetector.EllipseInfo p : ellipses) {
        VisualizeShapes.drawEllipse(p.ellipse,scale,g2);
      }
    }
  }
}
Program: 150691
Project: 150691
Buggy source:
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  System.out.flush();
  original=ConvertBufferedImage.checkCopy(buffered,original);
  work=ConvertBufferedImage.checkDeclare(buffered,work);
  binary.reshape(work.getWidth(),work.getHeight());
  final double timeInSeconds;
synchronized (this) {
    long before=System.nanoTime();
    inputToBinary.process((T)input,binary);
    detectorProcess((T)input,binary);
    long after=System.nanoTime();
    timeInSeconds=(after - before) * 1e-9;
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      controls.setProcessingTime(timeInSeconds);
      viewUpdated();
    }
  }
);
}

Fixed version (ground truth):
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  System.out.flush();
  original=ConvertBufferedImage.checkCopy(buffered,original);
  work=ConvertBufferedImage.checkDeclare(buffered,work);
  binary.reshape(work.getWidth(),work.getHeight());
  final double timeInSeconds;
synchronized (this) {
    long before=System.nanoTime();
    inputToBinary.process((T)input,binary);
    long middle=System.nanoTime();
    double a=(middle - before) * 1e-6;
    if (milliBinary == 0) {
      milliBinary=a;
    }
 else {
      milliBinary=0.95 * milliBinary + 0.05 * a;
    }
    System.out.printf("String_Node_Str",milliBinary);
    detectorProcess((T)input,binary);
    long after=System.nanoTime();
    timeInSeconds=(after - before) * 1e-9;
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      controls.setProcessingTime(timeInSeconds);
      viewUpdated();
    }
  }
);
}
Program: 150692
Project: 150692
Buggy source:
@Override protected void handleInputChange(int source,InputMethod method,final int width,final int height){
  BoofSwingUtil.invokeNowOrLater(new Runnable(){
    @Override public void run(){
      int w=guiImage.getWidth();
      int h=guiImage.getHeight();
      if (w == 0) {
        w=guiImage.getPreferredSize().width;
        h=guiImage.getPreferredSize().height;
      }
      double scale=Math.max(width / (double)w,height / (double)h);
      if (scale > 1.0) {
        controls.setZoom(1.0 / scale);
      }
 else {
        controls.setZoom(1.0);
      }
    }
  }
);
}

Fixed version (ground truth):
@Override protected void handleInputChange(int source,InputMethod method,final int width,final int height){
  BoofSwingUtil.invokeNowOrLater(new Runnable(){
    @Override public void run(){
      int w=guiImage.getWidth();
      int h=guiImage.getHeight();
      if (w == 0) {
        w=guiImage.getPreferredSize().width;
        h=guiImage.getPreferredSize().height;
      }
      double scale=Math.max(width / (double)w,height / (double)h);
      if (scale > 1.0) {
        controls.setZoom(1.0 / scale);
      }
 else {
        controls.setZoom(1.0);
      }
      milliBinary=0;
    }
  }
);
}
Program: 150693
Project: 150693
Buggy source:
public static void main(String[] args){
  String images[]=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  ListDisplayPanel panel=new ListDisplayPanel();
  BinaryEllipseDetector<GrayU8> detector=FactoryShapeDetector.ellipse(null,GrayU8.class);
  for (  String fileName : images) {
    BufferedImage image=UtilImageIO.loadImage(UtilIO.pathExample(fileName));
    GrayU8 input=ConvertBufferedImage.convertFromSingle(image,null,GrayU8.class);
    GrayU8 binary=new GrayU8(input.width,input.height);
    int threshold=GThresholdImageOps.computeOtsu(input,0,255);
    ThresholdImageOps.threshold(input,binary,threshold,true);
    detector.process(input,binary);
    FastQueue<EllipseRotated_F64> found=detector.getFoundEllipses();
    Graphics2D g2=image.createGraphics();
    g2.setStroke(new BasicStroke(3));
    g2.setColor(Color.RED);
    for (int i=0; i < found.size; i++) {
      VisualizeShapes.drawEllipse(found.get(i),g2);
    }
    panel.addImage(image,new File(fileName).getName());
  }
  ShowImages.showWindow(panel,"String_Node_Str",true);
}

Fixed version (ground truth):
public static void main(String[] args){
  String images[]=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  ListDisplayPanel panel=new ListDisplayPanel();
  BinaryEllipseDetector<GrayU8> detector=FactoryShapeDetector.ellipse(null,GrayU8.class);
  for (  String fileName : images) {
    BufferedImage image=UtilImageIO.loadImage(UtilIO.pathExample(fileName));
    GrayU8 input=ConvertBufferedImage.convertFromSingle(image,null,GrayU8.class);
    GrayU8 binary=new GrayU8(input.width,input.height);
    int threshold=GThresholdImageOps.computeOtsu(input,0,255);
    ThresholdImageOps.threshold(input,binary,threshold,true);
    detector.process(input,binary);
    FastQueue<BinaryEllipseDetector.EllipseInfo> found=detector.getFound();
    Graphics2D g2=image.createGraphics();
    g2.setStroke(new BasicStroke(3));
    g2.setColor(Color.RED);
    for (int i=0; i < found.size; i++) {
      VisualizeShapes.drawEllipse(found.get(i).ellipse,g2);
    }
    panel.addImage(image,new File(fileName).getName());
  }
  ShowImages.showWindow(panel,"String_Node_Str",true);
}
Program: 150694
Project: 150694
Buggy source:
/** 
 * Detects ellipses inside the binary image and refines the edges for all detections inside the gray image
 * @param gray Grayscale image
 * @param binary Binary image of grayscale. 1 = ellipse and 0 = ignored background
 */
public void process(T gray,GrayU8 binary){
  refined.reset();
  ellipseDetector.process(binary);
  if (ellipseRefiner != null)   ellipseRefiner.setImage(gray);
  intensityCheck.setImage(gray);
  List<BinaryEllipseDetectorPixel.Found> found=ellipseDetector.getFound();
  for (  BinaryEllipseDetectorPixel.Found f : found) {
    if (!intensityCheck.process(f.ellipse)) {
      if (verbose)       System.out.println("String_Node_Str");
      continue;
    }
    EllipseRotated_F64 r=refined.grow();
    if (ellipseRefiner != null) {
      if (!ellipseRefiner.process(f.ellipse,r)) {
        refined.removeTail();
      }
    }
 else {
      r.set(f.ellipse);
    }
  }
}

Fixed version (ground truth):
/** 
 * Detects ellipses inside the binary image and refines the edges for all detections inside the gray image
 * @param gray Grayscale image
 * @param binary Binary image of grayscale. 1 = ellipse and 0 = ignored background
 */
public void process(T gray,GrayU8 binary){
  results.reset();
  ellipseDetector.process(binary);
  if (ellipseRefiner != null)   ellipseRefiner.setImage(gray);
  intensityCheck.setImage(gray);
  List<BinaryEllipseDetectorPixel.Found> found=ellipseDetector.getFound();
  for (  BinaryEllipseDetectorPixel.Found f : found) {
    if (!intensityCheck.process(f.ellipse)) {
      if (verbose)       System.out.println("String_Node_Str");
      continue;
    }
    EllipseInfo r=results.grow();
    r.contour=f.contour;
    if (ellipseRefiner != null) {
      if (!ellipseRefiner.process(f.ellipse,r.ellipse)) {
        if (verbose)         System.out.println("String_Node_Str");
        results.removeTail();
        continue;
      }
 else       if (!intensityCheck.process(f.ellipse)) {
        if (verbose)         System.out.println("String_Node_Str");
        continue;
      }
    }
 else {
      r.ellipse.set(f.ellipse);
    }
    r.averageInside=intensityCheck.averageInside;
    r.averageOutside=intensityCheck.averageOutside;
  }
}
Program: 150695
Project: 150695
Buggy source:
/** 
 * <p>Returns all the found ellipses in the input image.</p> WARNING: Returned data is recycled on the next call to process
 * @return List of found ellipses.
 */
public FastQueue<EllipseRotated_F64> getFoundEllipses(){
  return refined;
}

Fixed version (ground truth):
public List<EllipseRotated_F64> getFoundEllipses(List<EllipseRotated_F64> storage){
  if (storage == null)   storage=new ArrayList<>();
  for (int i=0; i < results.size; i++) {
    storage.add(results.get(i).ellipse);
  }
  return storage;
}
Program: 150697
Project: 150697
Buggy source:
/** 
 * Detects polygons inside the grayscale image and its thresholded version
 * @param gray Gray scale image
 * @param binary Binary version of grayscale image
 */
public void process(T gray,GrayU8 binary){
  detector.process(gray,binary);
  if (refineGray != null)   refineGray.setImage(gray);
  edgeIntensity.setImage(gray);
  List<DetectPolygonFromContour.Info> detections=detector.getFound().toList();
  if (adjustForBias != null) {
    for (int i=0; i < detections.size(); i++) {
      adjustForBias.process(detections.get(i).polygon,detector.isOutputClockwise());
    }
  }
}

Fixed version (ground truth):
/** 
 * Detects polygons inside the grayscale image and its thresholded version
 * @param gray Gray scale image
 * @param binary Binary version of grayscale image
 */
public void process(T gray,GrayU8 binary){
  detector.process(gray,binary);
  if (refineGray != null)   refineGray.setImage(gray);
  edgeIntensity.setImage(gray);
  long time0=System.nanoTime();
  List<DetectPolygonFromContour.Info> detections=detector.getFound().toList();
  if (adjustForBias != null) {
    for (int i=0; i < detections.size(); i++) {
      adjustForBias.process(detections.get(i).polygon,detector.isOutputClockwise());
    }
  }
  long time1=System.nanoTime();
  double milli=(time1 - time0) * 1e-6;
  if (milliAdjustBias == 0) {
    milliAdjustBias=milli;
  }
 else {
    milliAdjustBias=0.95 * milliAdjustBias + 0.5 * milli;
  }
  System.out.printf("String_Node_Str",milliAdjustBias);
}
Program: 150698
Project: 150698
Buggy source:
/** 
 * Examines the undistorted gray scake input image for squares.
 * @param gray Input image
 */
public void process(T gray,GrayU8 binary){
  if (verbose)   System.out.println("String_Node_Str");
  InputSanityCheck.checkSameShape(binary,gray);
  if (labeled.width != gray.width || labeled.height != gray.height)   configure(gray.width,gray.height);
  for (int i=0; i < foundInfo.size; i++) {
    foundInfo.get(i).reset();
  }
  foundInfo.reset();
  if (contourEdgeIntensity != null)   contourEdgeIntensity.setImage(gray);
  contourFinder.process(binary,labeled);
  findCandidateShapes();
  if (verbose)   System.out.println("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Examines the undistorted gray scake input image for squares.
 * @param gray Input image
 */
public void process(T gray,GrayU8 binary){
  if (verbose)   System.out.println("String_Node_Str");
  InputSanityCheck.checkSameShape(binary,gray);
  if (labeled.width != gray.width || labeled.height != gray.height)   configure(gray.width,gray.height);
  for (int i=0; i < foundInfo.size; i++) {
    foundInfo.get(i).reset();
  }
  foundInfo.reset();
  if (contourEdgeIntensity != null)   contourEdgeIntensity.setImage(gray);
  long time0=System.nanoTime();
  contourFinder.process(binary,labeled);
  long time1=System.nanoTime();
  findCandidateShapes();
  long time2=System.nanoTime();
  double a=(time1 - time0) * 1e-6;
  double b=(time2 - time1) * 1e-6;
  if (milliContour == 0) {
    milliContour=a;
    milliShapes=b;
  }
 else {
    double alpha=0.95;
    milliContour=alpha * milliContour + (1.0 - alpha) * a;
    milliShapes=alpha * milliShapes + (1.0 - alpha) * b;
  }
  System.out.printf("String_Node_Str",milliContour,milliShapes);
  if (verbose)   System.out.println("String_Node_Str");
}
Program: 150699
Project: 150699
Buggy source:
/** 
 * Specifies the image's intrinsic parameters and target size
 * @param width Width of the input image
 * @param height Height of the input image
 */
private void configure(int width,int height){
  labeled.reshape(width,height);
  this.minimumContour=minimumContourConfig.computeI(width,height);
  this.minimumArea=Math.pow(this.minimumContour / 4.0,2);
  if (helper != null)   helper.setImageShape(width,height);
}

Fixed version (ground truth):
/** 
 * Specifies the image's intrinsic parameters and target size
 * @param width Width of the input image
 * @param height Height of the input image
 */
private void configure(int width,int height){
  milliContour=0;
  milliShapes=0;
  labeled.reshape(width,height);
  this.minimumContour=minimumContourConfig.computeI(width,height);
  this.minimumArea=Math.pow(this.minimumContour / 4.0,2);
  if (helper != null)   helper.setImageShape(width,height);
}
Program: 150700
Project: 150700
Buggy source:
/** 
 * Loads a pinhole camera model with radian and tangential distortion in OpenCV format
 * @param fileName path to file
 * @return CameraPinholeRadial
 */
public static CameraPinholeRadial loadPinholeRadial(String fileName){
  FileStorage fs=new FileStorage(fileName,FileStorage.READ);
  IntPointer width=new IntPointer(1);
  IntPointer height=new IntPointer(1);
  read(fs.get("String_Node_Str"),width,-1);
  read(fs.get("String_Node_Str"),height,-1);
  Mat K=new Mat();
  read(fs.get("String_Node_Str"),K);
  Mat distortion=new Mat();
  read(fs.get("String_Node_Str"),distortion);
  CameraPinholeRadial boof=new CameraPinholeRadial();
  boof.width=width.get();
  boof.height=height.get();
  DoubleRawIndexer indexerK=K.createIndexer();
  boof.fx=indexerK.get(0,0);
  boof.skew=indexerK.get(0,1);
  boof.fy=indexerK.get(1,1);
  boof.cx=indexerK.get(0,2);
  boof.cy=indexerK.get(1,2);
  DoubleRawIndexer indexerD=distortion.createIndexer();
  if (distortion.rows() == 5)   boof.setRadial(indexerD.get(0,0),indexerD.get(1,0),indexerD.get(4,0));
 else   if (distortion.rows() >= 2)   boof.setRadial(indexerD.get(0,0),indexerD.get(1,0));
  if (distortion.rows() >= 5)   boof.fsetTangental(indexerD.get(2,0),indexerD.get(3,0));
  return boof;
}

Fixed version (ground truth):
/** 
 * Loads a pinhole camera model with radian and tangential distortion in OpenCV format
 * @param fileName path to file
 * @return CameraPinholeRadial
 */
public static CameraPinholeRadial loadPinholeRadial(String fileName){
  FileStorage fs=new FileStorage(new File(fileName).getAbsolutePath(),FileStorage.READ);
  IntPointer width=new IntPointer(1);
  IntPointer height=new IntPointer(1);
  read(fs.get("String_Node_Str"),width,-1);
  read(fs.get("String_Node_Str"),height,-1);
  Mat K=new Mat();
  read(fs.get("String_Node_Str"),K);
  Mat distortion=new Mat();
  read(fs.get("String_Node_Str"),distortion);
  CameraPinholeRadial boof=new CameraPinholeRadial();
  boof.width=width.get();
  boof.height=height.get();
  DoubleRawIndexer indexerK=K.createIndexer();
  boof.fx=indexerK.get(0,0);
  boof.skew=indexerK.get(0,1);
  boof.fy=indexerK.get(1,1);
  boof.cx=indexerK.get(0,2);
  boof.cy=indexerK.get(1,2);
  DoubleRawIndexer indexerD=distortion.createIndexer();
  if (distortion.rows() == 5)   boof.setRadial(indexerD.get(0,0),indexerD.get(1,0),indexerD.get(4,0));
 else   if (distortion.rows() >= 2)   boof.setRadial(indexerD.get(0,0),indexerD.get(1,0));
  if (distortion.rows() >= 5)   boof.fsetTangental(indexerD.get(2,0),indexerD.get(3,0));
  return boof;
}
Program: 150701
Project: 150701
Buggy source:
public static void save(CameraPinholeRadial model,String fileName){
  FileStorage fs=new FileStorage(fileName,FileStorage.WRITE);
  DMatrixRMaj K=PerspectiveOps.calibrationMatrix(model,(DMatrixRMaj)null);
  write(fs,"String_Node_Str",model.width);
  write(fs,"String_Node_Str",model.height);
  write(fs,"String_Node_Str",toMat(K));
  DMatrixRMaj D=new DMatrixRMaj(2 + model.radial.length,1);
  D.set(0,0,model.radial[0]);
  D.set(1,0,model.radial[1]);
  D.set(4,0,model.radial[2]);
  D.set(2,0,model.t1);
  D.set(3,0,model.t2);
  write(fs,"String_Node_Str",toMat(D));
  try {
    fs.close();
  }
 catch (  Exception ignore) {
  }
}

Fixed version (ground truth):
public static void save(CameraPinholeRadial model,String fileName){
  FileStorage fs=new FileStorage(new File(fileName).getAbsolutePath(),FileStorage.WRITE);
  DMatrixRMaj K=PerspectiveOps.calibrationMatrix(model,(DMatrixRMaj)null);
  write(fs,"String_Node_Str",model.width);
  write(fs,"String_Node_Str",model.height);
  write(fs,"String_Node_Str",toMat(K));
  DMatrixRMaj D=new DMatrixRMaj(2 + model.radial.length,1);
  D.set(0,0,model.radial[0]);
  D.set(1,0,model.radial[1]);
  D.set(4,0,model.radial[2]);
  D.set(2,0,model.t1);
  D.set(3,0,model.t2);
  write(fs,"String_Node_Str",toMat(D));
  try {
    fs.close();
  }
 catch (  Exception ignore) {
  }
}
Program: 150702
Project: 150702
Buggy source:
@Test public void loadImage_saveImage(){
  BufferedImage orig=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);
  for (int i=0; i < height; i++) {
    for (int j=0; j < width; j++) {
      int a=rand.nextInt(255);
      int rgb=a << 16 | a << 8 << a;
      orig.setRGB(j,i,rgb);
    }
  }
  UtilImageIO.saveImage(orig,"String_Node_Str");
  BufferedImage found=UtilImageIO.loadImage("String_Node_Str");
  for (int i=0; i < height; i++) {
    for (int j=0; j < width; j++) {
      int a=orig.getRGB(j,i) & 0xFF;
      int b=found.getRGB(j,i) & 0xFF;
      assertEquals(a,b);
    }
  }
  File f=new File("String_Node_Str");
  assertTrue(f.delete());
}

Fixed version (ground truth):
@Test public void loadImage_saveImage() throws IOException {
  BufferedImage orig=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);
  for (int i=0; i < height; i++) {
    for (int j=0; j < width; j++) {
      int a=rand.nextInt(255);
      int rgb=a << 16 | a << 8 << a;
      orig.setRGB(j,i,rgb);
    }
  }
  File temp=File.createTempFile("String_Node_Str","String_Node_Str");
  UtilImageIO.saveImage(orig,temp.getPath());
  BufferedImage found=UtilImageIO.loadImage("String_Node_Str");
  for (int i=0; i < height; i++) {
    for (int j=0; j < width; j++) {
      int a=orig.getRGB(j,i) & 0xFF;
      int b=found.getRGB(j,i) & 0xFF;
      assertEquals(a,b);
    }
  }
  assertTrue(temp.delete());
}
Program: 150703
Project: 150703
Buggy source:
@Test public void loadImage_saveImage_PPM() throws IOException {
  Planar<GrayU8> orig=new Planar<>(GrayU8.class,width,height,3);
  GImageMiscOps.fillUniform(orig,rand,0,256);
  UtilImageIO.savePPM(orig,"String_Node_Str",null);
  Planar<GrayU8> found=UtilImageIO.loadPPM_U8("String_Node_Str",null,null);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      for (int k=0; k < 3; k++)       assertEquals(orig.getBand(k).get(x,y),found.getBand(k).get(x,y));
    }
  }
  File f=new File("String_Node_Str");
  assertTrue(f.delete());
}

Fixed version (ground truth):
@Test public void loadImage_saveImage_PPM() throws IOException {
  Planar<GrayU8> orig=new Planar<>(GrayU8.class,width,height,3);
  GImageMiscOps.fillUniform(orig,rand,0,256);
  File temp=File.createTempFile("String_Node_Str","String_Node_Str");
  UtilImageIO.savePPM(orig,temp.getPath(),null);
  Planar<GrayU8> found=UtilImageIO.loadPPM_U8("String_Node_Str",null,null);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      for (int k=0; k < 3; k++)       assertEquals(orig.getBand(k).get(x,y),found.getBand(k).get(x,y));
    }
  }
  assertTrue(temp.delete());
}
Program: 150704
Project: 150704
Buggy source:
@Test public void loadImage_saveImage_PGM() throws IOException {
  GrayU8 orig=new GrayU8(width,height);
  GImageMiscOps.fillUniform(orig,rand,0,256);
  UtilImageIO.savePGM(orig,"String_Node_Str");
  GrayU8 found=UtilImageIO.loadPGM_U8("String_Node_Str",null);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      assertEquals(orig.get(x,y),found.get(x,y));
    }
  }
  File f=new File("String_Node_Str");
  assertTrue(f.delete());
}

Fixed version (ground truth):
@Test public void loadImage_saveImage_PGM() throws IOException {
  GrayU8 orig=new GrayU8(width,height);
  GImageMiscOps.fillUniform(orig,rand,0,256);
  File temp=File.createTempFile("String_Node_Str","String_Node_Str");
  UtilImageIO.savePGM(orig,temp.getPath());
  GrayU8 found=UtilImageIO.loadPGM_U8("String_Node_Str",null);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      assertEquals(orig.get(x,y),found.get(x,y));
    }
  }
  assertTrue(temp.delete());
}
Program: 150705
Project: 150705
Buggy source:
/** 
 * Configures the detector
 * @param minimumSpread If the difference between min max is less than or equal to thisvalue then it is considered textureless.  Set to <= -1 to disable.
 * @param requestedBlockWidth About how wide and tall you wish a block to be in pixels.
 */
public ThresholdSquareBlockMinMax(double minimumSpread,int requestedBlockWidth){
  this.minimumSpread=minimumSpread;
  this.requestedBlockWidth=requestedBlockWidth;
}

Fixed version (ground truth):
/** 
 * Configures the detector
 * @param minimumSpread If the difference between min max is less than or equal to thisvalue then it is considered textureless.  Set to &le; -1 to disable.
 * @param requestedBlockWidth About how wide and tall you wish a block to be in pixels.
 */
public ThresholdSquareBlockMinMax(double minimumSpread,int requestedBlockWidth){
  this.minimumSpread=minimumSpread;
  this.requestedBlockWidth=requestedBlockWidth;
}
Program: 150706
Project: 150706
Buggy source:
public static <T extends ImageGray<T>>InputToBinary<T> localSquareBlockMinMax(int regionWidth,double scale,boolean down,double minimumSpread,Class<T> inputType){
  return new LocalSquareBlockMinMaxBinaryFilter<>(minimumSpread,regionWidth,scale,down,inputType);
}

Fixed version (ground truth):
/** 
 * Applies a very fast non-overlapping block thresholding algorithm which uses min/max statistics.
 * @see ThresholdSquareBlockMinMax
 * @param scale Scale factor adjust for threshold.  1.0 means no change.
 * @param down Should it threshold up or down.
 * @param minimumSpread If the difference between min max is less than or equal to thisvalue then it is considered textureless.  Set to &le; -1 to disable.
 * @param regionWidth About how wide and tall you wish a block to be in pixels.
 * @param inputType Type of input image
 * @return Filter to binary
 */
public static <T extends ImageGray<T>>InputToBinary<T> localSquareBlockMinMax(int regionWidth,double scale,boolean down,double minimumSpread,Class<T> inputType){
  return new LocalSquareBlockMinMaxBinaryFilter<>(minimumSpread,regionWidth,scale,down,inputType);
}
Program: 150707
Project: 150707
Buggy source:
/** 
 * Make sure the requested VFOV is the actual
 */
@Test public void checkFOV(){
  CylinderToEquirectangular_F32 alg=new CylinderToEquirectangular_F32();
  alg.setEquirectangularShape(400,500);
  alg.configure(200,300,UtilAngle.radian(100));
  GeoLL_F32 ll=new GeoLL_F32();
  alg.compute(100,0);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  float lon0=ll.lon;
  alg.compute(100,299);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  float lon1=ll.lon;
  assertEquals(UtilAngle.radian(100),lon1 - lon0,GrlConstants.TEST_F32);
}

Fixed version (ground truth):
/** 
 * Make sure the requested VFOV is the actual
 */
@Test public void checkFOV(){
  CylinderToEquirectangular_F32 alg=new CylinderToEquirectangular_F32();
  alg.setEquirectangularShape(400,500);
  alg.configure(200,300,UtilAngle.radian(100));
  GeoLL_F32 ll=new GeoLL_F32();
  alg.compute(100,0);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  double lat0=ll.lat;
  alg.compute(100,299);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  double lat1=ll.lat;
  assertEquals(UtilAngle.radian(100),lat1 - lat0,GrlConstants.TEST_F64);
}
Program: 150708
Project: 150708
Buggy source:
/** 
 * Make sure the requested VFOV is the actual
 */
@Test public void checkFOV(){
  CylinderToEquirectangular_F64 alg=new CylinderToEquirectangular_F64();
  alg.setEquirectangularShape(400,500);
  alg.configure(200,300,UtilAngle.radian(100));
  GeoLL_F64 ll=new GeoLL_F64();
  alg.compute(100,0);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  double lon0=ll.lon;
  alg.compute(100,299);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  double lon1=ll.lon;
  assertEquals(UtilAngle.radian(100),lon1 - lon0,GrlConstants.TEST_F64);
}

Fixed version (ground truth):
/** 
 * Make sure the requested VFOV is the actual
 */
@Test public void checkFOV(){
  CylinderToEquirectangular_F64 alg=new CylinderToEquirectangular_F64();
  alg.setEquirectangularShape(400,500);
  alg.configure(200,300,UtilAngle.radian(100));
  GeoLL_F64 ll=new GeoLL_F64();
  alg.compute(100,0);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  double lat0=ll.lat;
  alg.compute(100,299);
  alg.getTools().equiToLatLon(alg.distX,alg.distY,ll);
  double lat1=ll.lat;
  assertEquals(UtilAngle.radian(100),lat1 - lat0,GrlConstants.TEST_F64);
}
Program: 150709
Project: 150709
Buggy source:
/** 
 * Computes tangent points to the two ellipses specified by the grid coordinates
 */
private boolean addTangents(Grid grid,int rowA,int colA,int rowB,int colB){
  EllipseRotated_F64 a=grid.get(rowA,colA);
  EllipseRotated_F64 b=grid.get(rowB,colB);
  if (!tangentFinder.process(a,b,A0,A1,A2,A3,B0,B1,B2,B3)) {
    return false;
  }
  Tangents ta=tangents.get(grid.getIndexOfRegEllipse(rowA,colA));
  Tangents tb=tangents.get(grid.getIndexOfRegEllipse(rowB,colB));
  if (rowA == rowB) {
    ta.t[ta.countT++].set(A0);
    ta.b[ta.countB++].set(A3);
    tb.t[tb.countT++].set(B0);
    tb.b[tb.countB++].set(B3);
  }
 else {
    ta.r[ta.countL++].set(A0);
    ta.l[ta.countR++].set(A3);
    tb.r[tb.countL++].set(B0);
    tb.l[tb.countR++].set(B3);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Computes tangent points to the two ellipses specified by the grid coordinates
 */
private boolean addTangents(Grid grid,int rowA,int colA,int rowB,int colB){
  EllipseRotated_F64 a=grid.get(rowA,colA);
  EllipseRotated_F64 b=grid.get(rowB,colB);
  if (!tangentFinder.process(a,b,A0,A1,A2,A3,B0,B1,B2,B3)) {
    return false;
  }
  Tangents ta=tangents.get(grid.getIndexOfRegEllipse(rowA,colA));
  Tangents tb=tangents.get(grid.getIndexOfRegEllipse(rowB,colB));
  double slopeX=b.center.x - a.center.x;
  double slopeY=b.center.y - a.center.y;
  double dx0=A0.x - a.center.x;
  double dy0=A0.y - a.center.y;
  double z=slopeX * dy0 - slopeY * dx0;
  if (z < 0 == (rowA == rowB)) {
    Point2D_F64 tmp=A0;
    A0=A3;
    A3=tmp;
    tmp=B0;
    B0=B3;
    B3=tmp;
  }
  if (rowA == rowB) {
    ta.t[ta.countT++].set(A0);
    ta.b[ta.countB++].set(A3);
    tb.t[tb.countT++].set(B0);
    tb.b[tb.countB++].set(B3);
  }
 else {
    ta.r[ta.countL++].set(A0);
    ta.l[ta.countR++].set(A3);
    tb.r[tb.countL++].set(B0);
    tb.l[tb.countR++].set(B3);
  }
  return true;
}