Program: 21485
Project: 21485
Buggy source:
private double scanIntersection(int xx,int yy,int left,int top,int tmpIntersectionWidth,int tmpIntersectionHeight){
  double tmpError;
  pixelAll=0;
  tmpPixelBButNotA=0;
  tmpPixelAButNotB=0;
  tmpPixelBoth=0;
  tmpCoverageFaktorA=0;
  tmpCoverageFaktorB=0;
  bothElements.removeAllElements();
  elementGrid=new int[tmpIntersectionWidth][tmpIntersectionHeight];
  for (int x=0; x < tmpIntersectionWidth; x++) {
    for (int y=0; y < tmpIntersectionHeight; y++) {
      int pixelType=getPixelType(x,y,xx,yy,left,top);
      pixelAll++;
switch (pixelType) {
case 0:
        if (isCreateIntersectionLetter())         intersectionGrid[x][y]=BOTHCOLOR;
      getElement(x,y,xx,yy,left,top,pixelType,elementGrid,element=new Vector<Integer>());
    if (element.size() > minCleftSize)     bothElements.add(element);
  tmpPixelBoth++;
break;
case 1:
if (hasNeighbour(x,y,xx,yy,left,top,pixelType) > overlayNoiseSize) {
tmpPixelBButNotA++;
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=BNACOLOR;
}
 else {
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=BNAFILTEREDCOLOR;
}
break;
case 2:
if (hasNeighbour(x,y,xx,yy,left,top,pixelType) > overlayNoiseSize) {
tmpPixelAButNotB++;
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=ANBCOLOR;
}
 else {
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=ANBFILTEREDCOLOR;
}
break;
default :
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=0xffffff;
}
}
}
if (pixelAll > 0 && bothElements.size() > 0) {
tmpErrorA=(double)tmpPixelAButNotB / (double)(tmpPixelBoth + tmpPixelAButNotB);
tmpErrorB=(double)tmpPixelBButNotA / (double)(tmpPixelBButNotA + tmpPixelBoth);
tmpErrorTotal=tmpErrorA * errorAWeight + tmpErrorB * errorbWeight;
tmpCoverageFaktorA=1.0 - ((double)tmpPixelBoth / (double)a.getElementPixel());
tmpCoverageFaktorA=1.0 - ((double)tmpPixelBoth / (double)b.getElementPixel());
localHeightPercent=(double)tmpIntersectionHeight / a.getHeight();
localWidthPercent=(double)tmpIntersectionWidth / a.getWidth();
heightFaktor=Math.pow(1.0 - localHeightPercent,2);
widthFaktor=Math.pow(1.0 - localWidthPercent,2);
tmpError=tmpErrorTotal;
tmpError+=Math.min(1.0,tmpCoverageFaktorA * coverageFaktorAWeight);
tmpError+=Math.min(1.0,tmpCoverageFaktorA * coverageFaktorBWeight);
tmpError+=Math.min(1.0,heightFaktor * intersectionDimensionWeight);
tmpError+=Math.min(1.0,widthFaktor * intersectionDimensionWeight);
tmpError+=(bothElements.size() - 1) * cleftFaktor;
tmpError/=6.0;
tmpError=Math.min(1.0,tmpError);
if ((tmpPixelBoth * 8) < (tmpIntersectionHeight * tmpIntersectionWidth)) {
tmpError=tmpErrorA=tmpErrorB=tmpErrorTotal=1.0;
}
return 100.0 * tmpError;
}
 else {
return 100.0;
}
}

Fixed version (ground truth):
private double scanIntersection(int xx,int yy,int left,int top,int tmpIntersectionWidth,int tmpIntersectionHeight){
  double tmpError;
  pixelAll=0;
  tmpPixelBButNotA=0;
  tmpPixelAButNotB=0;
  tmpPixelBoth=0;
  tmpCoverageFaktorA=0;
  tmpCoverageFaktorB=0;
  bothElements.removeAllElements();
  elementGrid=new int[tmpIntersectionWidth][tmpIntersectionHeight];
  for (int x=0; x < tmpIntersectionWidth; x++) {
    for (int y=0; y < tmpIntersectionHeight; y++) {
      int pixelType=getPixelType(x,y,xx,yy,left,top);
      pixelAll++;
switch (pixelType) {
case 0:
        if (isCreateIntersectionLetter())         intersectionGrid[x][y]=BOTHCOLOR;
      getElement(x,y,xx,yy,left,top,pixelType,elementGrid,element=new Vector<Integer>());
    if (element.size() > minCleftSize)     bothElements.add(element);
  tmpPixelBoth++;
break;
case 1:
if (hasNeighbour(x,y,xx,yy,left,top,pixelType) > overlayNoiseSize) {
tmpPixelBButNotA++;
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=BNACOLOR;
}
 else {
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=BNAFILTEREDCOLOR;
}
break;
case 2:
if (hasNeighbour(x,y,xx,yy,left,top,pixelType) > overlayNoiseSize) {
tmpPixelAButNotB++;
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=ANBCOLOR;
}
 else {
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=ANBFILTEREDCOLOR;
}
break;
default :
if (isCreateIntersectionLetter()) intersectionGrid[x][y]=0xffffff;
}
}
}
if (pixelAll > 0 && bothElements.size() > 0) {
tmpErrorA=(double)tmpPixelAButNotB / (double)(tmpPixelBoth + tmpPixelAButNotB);
tmpErrorB=(double)tmpPixelBButNotA / (double)(tmpPixelBButNotA + tmpPixelBoth);
tmpErrorTotal=tmpErrorA * errorAWeight + tmpErrorB * errorbWeight;
tmpCoverageFaktorA=1.0 - ((double)tmpPixelBoth / (double)a.getElementPixel());
tmpCoverageFaktorB=1.0 - ((double)tmpPixelBoth / (double)b.getElementPixel());
localHeightPercent=(double)tmpIntersectionHeight / (double)b.getHeight();
localWidthPercent=(double)tmpIntersectionWidth / (double)b.getWidth();
tmpHeightFaktor=Math.pow(1.0 - localHeightPercent,2);
tmpWidthFaktor=Math.pow(1.0 - localWidthPercent,2);
tmpError=tmpErrorTotal;
tmpError+=Math.min(1.0,tmpCoverageFaktorA * coverageFaktorAWeight);
tmpError+=Math.min(1.0,tmpCoverageFaktorB * coverageFaktorBWeight);
tmpError+=Math.min(1.0,tmpHeightFaktor * intersectionDimensionWeight);
tmpError+=Math.min(1.0,tmpWidthFaktor * intersectionDimensionWeight);
tmpError+=(bothElements.size() - 1) * cleftFaktor;
tmpError/=6.0;
tmpError=Math.min(1.0,tmpError);
if ((tmpPixelBoth * 8) < (tmpIntersectionHeight * tmpIntersectionWidth)) {
tmpError=tmpErrorA=tmpErrorB=tmpErrorTotal=1.0;
}
return 100.0 * tmpError;
}
 else {
return 100.0;
}
}