Program: 154107
Project: 154107
Buggy source:
protected synchronized void train(){
  network=new int[maxColorNum][];
  for (int i=0; i < maxColorNum; i++) {
    network[i]=new int[4];
    int[] p=network[i];
    p[0]=p[1]=p[2]=(i << (netbiasshift + 8)) / maxColorNum;
    freq[i]=intbias / maxColorNum;
    bias[i]=0;
  }
  PlanarImage source=getSourceImage(0);
  Rectangle rect=source.getBounds();
  if (roi != null)   rect=roi.getBounds();
  RandomIter iterator=RandomIterFactory.create(source,rect);
  int samplefac=xPeriod * yPeriod;
  int startX=rect.x / xPeriod;
  int startY=rect.y / yPeriod;
  int offsetX=rect.x % xPeriod;
  int offsetY=rect.y % yPeriod;
  int pixelsPerLine=(rect.width - 1) / xPeriod + 1;
  int numSamples=pixelsPerLine * ((rect.height - 1) / yPeriod + 1);
  if (numSamples < minpicturebytes)   samplefac=1;
  alphadec=30 + ((samplefac - 1) / 3);
  int pix=0;
  int delta=numSamples / ncycles;
  int alpha=initalpha;
  int radius=initradius;
  int rad=radius >> radiusbiasshift;
  if (rad <= 1)   rad=0;
  for (int i=0; i < rad; i++)   radpower[i]=alpha * (((rad * rad - i * i) * radbias) / (rad * rad));
  int step;
  if (numSamples < minpicturebytes)   step=3;
 else   if ((numSamples % prime1) != 0)   step=3 * prime1;
 else {
    if ((numSamples % prime2) != 0)     step=3 * prime2;
 else {
      if ((numSamples % prime3) != 0)       step=3 * prime3;
 else       step=3 * prime4;
    }
  }
  int[] pixel=new int[3];
  for (int i=0; i < numSamples; ) {
    int y=(pix / pixelsPerLine + startY) * yPeriod + offsetY;
    int x=(pix % pixelsPerLine + startX) * xPeriod + offsetX;
    try {
      iterator.getPixel(x,y,pixel);
    }
 catch (    Exception e) {
      continue;
    }
    int b=pixel[2] << netbiasshift;
    int g=pixel[1] << netbiasshift;
    int r=pixel[0] << netbiasshift;
    int j=contest(b,g,r);
    altersingle(alpha,j,b,g,r);
    if (rad != 0)     alterneigh(rad,j,b,g,r);
    pix+=step;
    if (pix >= numSamples)     pix-=numSamples;
    i++;
    if (i % delta == 0) {
      alpha-=alpha / alphadec;
      radius-=radius / radiusdec;
      rad=radius >> radiusbiasshift;
      if (rad <= 1)       rad=0;
      for (j=0; j < rad; j++)       radpower[j]=alpha * (((rad * rad - j * j) * radbias) / (rad * rad));
    }
  }
  unbiasnet();
  inxbuild();
  createLUT();
  setProperty("String_Node_Str",colorMap);
}

Fixed version (ground truth):
protected synchronized void train(){
  network=new int[maxColorNum][];
  for (int i=0; i < maxColorNum; i++) {
    network[i]=new int[4];
    int[] p=network[i];
    p[0]=p[1]=p[2]=(i << (netbiasshift + 8)) / maxColorNum;
    freq[i]=intbias / maxColorNum;
    bias[i]=0;
  }
  PlanarImage source=getSourceImage(0);
  Rectangle rect=source.getBounds();
  if (roi != null)   rect=roi.getBounds();
  RandomIter iterator=RandomIterFactory.create(source,rect);
  int samplefac=xPeriod * yPeriod;
  int startX=rect.x / xPeriod;
  int startY=rect.y / yPeriod;
  int offsetX=rect.x % xPeriod;
  int offsetY=rect.y % yPeriod;
  int pixelsPerLine=(rect.width - 1) / xPeriod + 1;
  int numSamples=pixelsPerLine * ((rect.height - 1) / yPeriod + 1);
  if (numSamples < minpicturebytes)   samplefac=1;
  alphadec=30 + ((samplefac - 1) / 3);
  int pix=0;
  int delta=numSamples / ncycles;
  int alpha=initalpha;
  int radius=initradius;
  int rad=radius >> radiusbiasshift;
  if (rad <= 1)   rad=0;
  for (int i=0; i < rad; i++)   radpower[i]=alpha * (((rad * rad - i * i) * radbias) / (rad * rad));
  int step;
  if (numSamples < minpicturebytes)   step=3;
 else   if ((numSamples % prime1) != 0)   step=3 * prime1;
 else {
    if ((numSamples % prime2) != 0)     step=3 * prime2;
 else {
      if ((numSamples % prime3) != 0)       step=3 * prime3;
 else       step=3 * prime4;
    }
  }
  int[] pixel=new int[3];
  for (int i=0; i < numSamples; ) {
    int y=(pix / pixelsPerLine + startY) * yPeriod + offsetY;
    int x=(pix % pixelsPerLine + startX) * xPeriod + offsetX;
    try {
      iterator.getPixel(x,y,pixel);
    }
 catch (    Exception e) {
      continue;
    }
    int b=pixel[2] << netbiasshift;
    int g=pixel[1] << netbiasshift;
    int r=pixel[0] << netbiasshift;
    int j=contest(b,g,r);
    altersingle(alpha,j,b,g,r);
    if (rad != 0)     alterneigh(rad,j,b,g,r);
    pix+=step;
    if (pix >= numSamples)     pix-=numSamples;
    i++;
    if (i % delta == 0) {
      alpha-=alpha / alphadec;
      radius-=radius / radiusdec;
      rad=radius >> radiusbiasshift;
      if (rad <= 1)       rad=0;
      for (j=0; j < rad; j++)       radpower[j]=alpha * (((rad * rad - j * j) * radbias) / (rad * rad));
    }
  }
  unbiasnet();
  inxbuild();
  createLUT();
  setProperty("String_Node_Str",colorMap);
  setProperty("String_Node_Str",colorMap);
}