Program: 150696
Project: 150696
Buggy source:
/** 
 * Processes the edge along the ellipse and determines if the edge intensity is strong enough to pass or not
 * @param ellipse The ellipse in undistorted image coordinates.
 * @return true if it passes or false if not
 */
public boolean process(EllipseRotated_F64 ellipse){
  if (numContourPoints <= 0) {
    score=0;
    return true;
  }
  double cphi=Math.cos(ellipse.phi);
  double sphi=Math.sin(ellipse.phi);
  double aveInside=0;
  double aveOutside=0;
  int total=0;
  for (int contourIndex=0; contourIndex < numContourPoints; contourIndex++) {
    double theta=contourIndex * Math.PI * 2.0 / numContourPoints;
    double ct=Math.cos(theta);
    double st=Math.sin(theta);
    double px=ellipse.center.x + ellipse.a * ct * cphi - ellipse.b * st * sphi;
    double py=ellipse.center.y + ellipse.a * ct * sphi + ellipse.b * st * cphi;
    double edx=ellipse.a * ct * ellipse.b* ellipse.b;
    double edy=ellipse.b * st * ellipse.a* ellipse.a;
    double r=Math.sqrt(edx * edx + edy * edy);
    edx/=r;
    edy/=r;
    double dx=edx * cphi - edy * sphi;
    double dy=edx * sphi + edy * cphi;
    double xin=px - dx * tangentDistance;
    double yin=py - dy * tangentDistance;
    double xout=px + dx * tangentDistance;
    double yout=py + dy * tangentDistance;
    if (integral.isInside(xin,yin) && integral.isInside(xout,yout)) {
      aveInside+=integral.compute(px,py,xin,yin);
      aveOutside+=integral.compute(px,py,xout,yout);
      total++;
    }
  }
  score=0;
  if (total > 0) {
    score=Math.abs(aveOutside - aveInside) / (total * tangentDistance);
  }
  return score >= passThreshold;
}

Fixed version (ground truth):
/** 
 * Processes the edge along the ellipse and determines if the edge intensity is strong enough to pass or not
 * @param ellipse The ellipse in undistorted image coordinates.
 * @return true if it passes or false if not
 */
public boolean process(EllipseRotated_F64 ellipse){
  if (numContourPoints <= 0) {
    score=0;
    return true;
  }
  double cphi=Math.cos(ellipse.phi);
  double sphi=Math.sin(ellipse.phi);
  averageInside=0;
  averageOutside=0;
  int total=0;
  for (int contourIndex=0; contourIndex < numContourPoints; contourIndex++) {
    double theta=contourIndex * Math.PI * 2.0 / numContourPoints;
    double ct=Math.cos(theta);
    double st=Math.sin(theta);
    double px=ellipse.center.x + ellipse.a * ct * cphi - ellipse.b * st * sphi;
    double py=ellipse.center.y + ellipse.a * ct * sphi + ellipse.b * st * cphi;
    double edx=ellipse.a * ct * ellipse.b* ellipse.b;
    double edy=ellipse.b * st * ellipse.a* ellipse.a;
    double r=Math.sqrt(edx * edx + edy * edy);
    edx/=r;
    edy/=r;
    double dx=edx * cphi - edy * sphi;
    double dy=edx * sphi + edy * cphi;
    double xin=px - dx * tangentDistance;
    double yin=py - dy * tangentDistance;
    double xout=px + dx * tangentDistance;
    double yout=py + dy * tangentDistance;
    if (integral.isInside(xin,yin) && integral.isInside(xout,yout)) {
      averageInside+=integral.compute(px,py,xin,yin);
      averageOutside+=integral.compute(px,py,xout,yout);
      total++;
    }
  }
  score=0;
  if (total > 0) {
    score=Math.abs(averageOutside - averageInside) / (total * tangentDistance);
  }
  return score >= passThreshold;
}