Program: 11703
Project: 11703
Buggy source:
final public void run() throws Exception {
  final ImagePlus imp=WindowManager.getCurrentImage();
  if (imp == null) {
    System.err.println("String_Node_Str");
    return;
  }
  if (!p.setup())   return;
  final ImageStack stack=imp.getStack();
  final ExecutorService exec=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<?>> tasks=new ArrayList<Future<?>>();
  final String base_path=System.getProperty("String_Node_Str") + "String_Node_Str";
  final AtomicInteger counter=new AtomicInteger(0);
  for (int i=1; i <= stack.getSize(); i++) {
    final int slice=i;
    tasks.add(exec.submit(new Callable<Object>(){
      public Object call(){
        IJ.showProgress(counter.getAndIncrement(),stack.getSize());
        final String path=base_path + stack.getSliceLabel(slice) + "String_Node_Str";
        ArrayList<Feature> fs=deserializeFeatures(p.sift,path);
        if (null == fs) {
          final FloatArray2DSIFT sift=new FloatArray2DSIFT(p.sift);
          final SIFT ijSIFT=new SIFT(sift);
          fs=new ArrayList<Feature>();
          ijSIFT.extractFeatures(stack.getProcessor(slice),fs);
          if (!serializeFeatures(p.sift,fs,path)) {
            IJ.log("String_Node_Str" + stack.getSliceLabel(slice));
          }
        }
        IJ.log(fs.size() + "String_Node_Str" + stack.getSliceLabel(slice));
        return null;
      }
    }
));
  }
  for (  Future<?> fu : tasks) {
    fu.get();
  }
  tasks.clear();
  final InvertibleCoordinateTransform[] transforms=new InvertibleCoordinateTransform[stack.getSize() - 1];
  final SpringMesh[] meshes=new SpringMesh[stack.getSize()];
  meshes[0]=new SpringMesh(p.springMeshResolution,stack.getWidth(),stack.getHeight(),p.stiffness,p.maxStretch,p.springMeshDamp);
  counter.set(0);
  for (int i=2; i <= stack.getSize(); i++) {
    final int slice=i;
    tasks.add(exec.submit(new Callable<Object>(){
      public Object call(){
        IJ.showProgress(counter.getAndIncrement(),stack.getSize() - 1);
        String path=base_path + stack.getSliceLabel(slice) + "String_Node_Str";
        ArrayList<PointMatch> candidates=deserializePointMatches(p,path);
        if (null == candidates) {
          ArrayList<Feature> fs1=deserializeFeatures(p.sift,base_path + stack.getSliceLabel(slice - 1) + "String_Node_Str");
          ArrayList<Feature> fs2=deserializeFeatures(p.sift,base_path + stack.getSliceLabel(slice) + "String_Node_Str");
          candidates=new ArrayList<PointMatch>(FloatArray2DSIFT.createMatches(fs2,fs1,p.rod));
          if (!serializePointMatches(p,candidates,path)) {
            IJ.log("String_Node_Str");
          }
        }
        AbstractAffineModel2D<?> model;
switch (p.modelIndex) {
case 0:
          model=new TranslationModel2D();
        break;
case 1:
      model=new RigidModel2D();
    break;
case 2:
  model=new SimilarityModel2D();
break;
case 3:
model=new AffineModel2D();
break;
default :
return null;
}
final ArrayList<PointMatch> inliers=new ArrayList<PointMatch>();
boolean modelFound;
try {
modelFound=model.filterRansac(candidates,inliers,1000,p.maxEpsilon,p.minInlierRatio);
}
 catch (Exception e) {
modelFound=false;
System.err.println(e.getMessage());
}
if (modelFound) {
transforms[slice - 1]=model;
}
meshes[slice - 1]=new SpringMesh(p.springMeshResolution,stack.getWidth(),stack.getHeight(),p.stiffness,p.maxStretch,p.springMeshDamp);
return null;
}
}
));
}
for (Future<?> fu : tasks) {
fu.get();
}
tasks.clear();
final int blockRadius=Math.max(32,stack.getWidth() / p.springMeshResolution / 2);
final int searchRadius=Math.round(p.maxEpsilon);
for (int i=1; i < stack.getSize(); ++i) {
final int slice=i;
tasks.add(exec.submit(new Callable<Object>(){
public Object call(){
final SpringMesh m1=meshes[slice - 1];
final SpringMesh m2=meshes[slice];
String path12=base_path + stack.getSliceLabel(slice) + "String_Node_Str"+ stack.getSliceLabel(slice + 1)+ "String_Node_Str";
String path21=base_path + stack.getSliceLabel(slice + 1) + "String_Node_Str"+ stack.getSliceLabel(slice)+ "String_Node_Str";
ArrayList<PointMatch> pm12=deserializeBlockMatches(p,path12);
ArrayList<PointMatch> pm21=deserializeBlockMatches(p,path21);
if (null == pm12 || null == pm21) {
pm12=new ArrayList<PointMatch>();
pm21=new ArrayList<PointMatch>();
final Collection<Vertex> v1=m1.getVertices();
final Collection<Vertex> v2=m2.getVertices();
final FloatProcessor ip1=(FloatProcessor)stack.getProcessor(slice).convertToFloat().duplicate();
final FloatProcessor ip2=(FloatProcessor)stack.getProcessor(slice + 1).convertToFloat().duplicate();
BlockMatching.matchByMaximalPMCC(ip1,ip2,Math.min(1.0f,(float)p.sift.maxOctaveSize / ip1.getWidth()),transforms[slice - 1].createInverse(),blockRadius,blockRadius,searchRadius,searchRadius,p.minR,p.rodR,p.maxCurvatureR,v1,pm12,new ErrorStatistic(1));
IJ.log("String_Node_Str" + pm12.size() + "String_Node_Str");
BlockMatching.matchByMaximalPMCC(ip2,ip1,Math.min(1.0f,(float)p.sift.maxOctaveSize / ip1.getWidth()),transforms[slice - 1],blockRadius,blockRadius,searchRadius,searchRadius,p.minR,p.rodR,p.maxCurvatureR,v2,pm21,new ErrorStatistic(1));
IJ.log("String_Node_Str" + pm21.size() + "String_Node_Str");
}
serializePointMatches(p,pm12,path12);
serializePointMatches(p,pm21,path21);
synchronized (m2) {
for (final PointMatch pm : pm12) {
final Vertex p1=(Vertex)pm.getP1();
final Vertex p2=new Vertex(pm.getP2());
p1.addSpring(p2,new Spring(0,1));
m2.addPassiveVertex(p2);
}
}
synchronized (m1) {
for (final PointMatch pm : pm21) {
final Vertex p1=(Vertex)pm.getP1();
final Vertex p2=new Vertex(pm.getP2());
p1.addSpring(p2,new Spring(0,1));
m1.addPassiveVertex(p2);
}
}
return null;
}
}
));
}
for (Future<?> fu : tasks) {
fu.get();
}
tasks.clear();
for (int i=1; i < stack.getSize(); ++i) {
final CoordinateTransformList<CoordinateTransform> ctl=new CoordinateTransformList<CoordinateTransform>();
for (int j=i - 1; j >= 0; --j) ctl.add(transforms[j]);
meshes[i].init(ctl);
}
try {
long t0=System.currentTimeMillis();
IJ.log("String_Node_Str");
SpringMesh.optimizeMeshes(Arrays.asList(meshes),p.maxEpsilon,p.maxIterations,p.maxPlateauwidth);
IJ.log("String_Node_Str" + (System.currentTimeMillis() - t0) + "String_Node_Str");
}
 catch (NotEnoughDataPointsException e) {
e.printStackTrace();
}
final float[] min=new float[2];
final float[] max=new float[2];
for (final SpringMesh mesh : meshes) {
final float[] meshMin=new float[2];
final float[] meshMax=new float[2];
mesh.bounds(meshMin,meshMax);
Util.min(min,meshMin);
Util.max(max,meshMax);
}
for (final SpringMesh mesh : meshes) {
for (final Vertex vertex : mesh.getVertices()) {
final float[] w=vertex.getW();
w[0]-=min[0];
w[1]-=min[1];
}
mesh.updateAffines();
mesh.updatePassiveVertices();
}
final int width=(int)Math.ceil(max[0] - min[0]);
final int height=(int)Math.ceil(max[1] - min[1]);
for (int i=1; i <= stack.getSize(); ++i) {
final TransformMeshMapping<SpringMesh> meshMapping=new TransformMeshMapping<SpringMesh>(meshes[i - 1]);
final ImageProcessor ip=stack.getProcessor(i).createProcessor(width,height);
if (p.interpolate) meshMapping.mapInterpolated(stack.getProcessor(i),ip);
 else meshMapping.map(stack.getProcessor(i),ip);
IJ.save(new ImagePlus("String_Node_Str" + i,ip),"String_Node_Str" + String.format("String_Node_Str",i) + "String_Node_Str");
}
IJ.log("String_Node_Str");
}

Fixed version (ground truth):
final public void run() throws Exception {
  final ImagePlus imp=WindowManager.getCurrentImage();
  if (imp == null) {
    System.err.println("String_Node_Str");
    return;
  }
  if (!p.setup())   return;
  final ImageStack stack=imp.getStack();
  final ExecutorService exec=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<?>> tasks=new ArrayList<Future<?>>();
  final String base_path=System.getProperty("String_Node_Str") + "String_Node_Str";
  final AtomicInteger counter=new AtomicInteger(0);
  for (int i=1; i <= stack.getSize(); i++) {
    final int slice=i;
    tasks.add(exec.submit(new Callable<Object>(){
      public Object call(){
        IJ.showProgress(counter.getAndIncrement(),stack.getSize());
        final String path=base_path + stack.getSliceLabel(slice) + "String_Node_Str";
        ArrayList<Feature> fs=deserializeFeatures(p.sift,path);
        if (null == fs) {
          final FloatArray2DSIFT sift=new FloatArray2DSIFT(p.sift);
          final SIFT ijSIFT=new SIFT(sift);
          fs=new ArrayList<Feature>();
          ijSIFT.extractFeatures(stack.getProcessor(slice),fs);
          if (!serializeFeatures(p.sift,fs,path)) {
            IJ.log("String_Node_Str" + stack.getSliceLabel(slice));
          }
        }
        IJ.log(fs.size() + "String_Node_Str" + stack.getSliceLabel(slice));
        return null;
      }
    }
));
  }
  for (  Future<?> fu : tasks) {
    fu.get();
  }
  tasks.clear();
  final InvertibleCoordinateTransform[] transforms=new InvertibleCoordinateTransform[stack.getSize() - 1];
  final SpringMesh[] meshes=new SpringMesh[stack.getSize()];
  meshes[0]=new SpringMesh(p.springMeshResolution,stack.getWidth(),stack.getHeight(),p.stiffness,p.maxStretch,p.springMeshDamp);
  counter.set(0);
  for (int i=2; i <= stack.getSize(); i++) {
    final int slice=i;
    tasks.add(exec.submit(new Callable<Object>(){
      public Object call(){
        IJ.showProgress(counter.getAndIncrement(),stack.getSize() - 1);
        String path=base_path + stack.getSliceLabel(slice) + "String_Node_Str";
        ArrayList<PointMatch> candidates=deserializePointMatches(p,path);
        if (null == candidates) {
          ArrayList<Feature> fs1=deserializeFeatures(p.sift,base_path + stack.getSliceLabel(slice - 1) + "String_Node_Str");
          ArrayList<Feature> fs2=deserializeFeatures(p.sift,base_path + stack.getSliceLabel(slice) + "String_Node_Str");
          candidates=new ArrayList<PointMatch>(FloatArray2DSIFT.createMatches(fs2,fs1,p.rod));
          if (!serializePointMatches(p,candidates,path)) {
            IJ.log("String_Node_Str");
          }
        }
        AbstractAffineModel2D<?> model;
switch (p.modelIndex) {
case 0:
          model=new TranslationModel2D();
        break;
case 1:
      model=new RigidModel2D();
    break;
case 2:
  model=new SimilarityModel2D();
break;
case 3:
model=new AffineModel2D();
break;
default :
return null;
}
final ArrayList<PointMatch> inliers=new ArrayList<PointMatch>();
boolean modelFound;
try {
modelFound=model.filterRansac(candidates,inliers,1000,p.maxEpsilon,p.minInlierRatio);
}
 catch (Exception e) {
modelFound=false;
System.err.println(e.getMessage());
}
if (modelFound) {
transforms[slice - 2]=model;
}
meshes[slice - 1]=new SpringMesh(p.springMeshResolution,stack.getWidth(),stack.getHeight(),p.stiffness,p.maxStretch,p.springMeshDamp);
return null;
}
}
));
}
for (Future<?> fu : tasks) {
fu.get();
}
tasks.clear();
final int blockRadius=Math.max(32,stack.getWidth() / p.springMeshResolution / 2);
final int searchRadius=Math.round(p.maxEpsilon);
for (int i=1; i < stack.getSize(); ++i) {
final int slice=i;
tasks.add(exec.submit(new Callable<Object>(){
public Object call(){
final SpringMesh m1=meshes[slice - 1];
final SpringMesh m2=meshes[slice];
String path12=base_path + stack.getSliceLabel(slice) + "String_Node_Str"+ stack.getSliceLabel(slice + 1)+ "String_Node_Str";
String path21=base_path + stack.getSliceLabel(slice + 1) + "String_Node_Str"+ stack.getSliceLabel(slice)+ "String_Node_Str";
ArrayList<PointMatch> pm12=deserializeBlockMatches(p,path12);
ArrayList<PointMatch> pm21=deserializeBlockMatches(p,path21);
if (null == pm12 || null == pm21) {
pm12=new ArrayList<PointMatch>();
pm21=new ArrayList<PointMatch>();
final Collection<Vertex> v1=m1.getVertices();
final Collection<Vertex> v2=m2.getVertices();
final FloatProcessor ip1=(FloatProcessor)stack.getProcessor(slice).convertToFloat().duplicate();
final FloatProcessor ip2=(FloatProcessor)stack.getProcessor(slice + 1).convertToFloat().duplicate();
BlockMatching.matchByMaximalPMCC(ip1,ip2,Math.min(1.0f,(float)p.sift.maxOctaveSize / ip1.getWidth()),transforms[slice - 1].createInverse(),blockRadius,blockRadius,searchRadius,searchRadius,p.minR,p.rodR,p.maxCurvatureR,v1,pm12,new ErrorStatistic(1));
IJ.log("String_Node_Str" + pm12.size() + "String_Node_Str");
BlockMatching.matchByMaximalPMCC(ip2,ip1,Math.min(1.0f,(float)p.sift.maxOctaveSize / ip1.getWidth()),transforms[slice - 1],blockRadius,blockRadius,searchRadius,searchRadius,p.minR,p.rodR,p.maxCurvatureR,v2,pm21,new ErrorStatistic(1));
IJ.log("String_Node_Str" + pm21.size() + "String_Node_Str");
}
serializePointMatches(p,pm12,path12);
serializePointMatches(p,pm21,path21);
synchronized (m2) {
for (final PointMatch pm : pm12) {
final Vertex p1=(Vertex)pm.getP1();
final Vertex p2=new Vertex(pm.getP2());
p1.addSpring(p2,new Spring(0,1));
m2.addPassiveVertex(p2);
}
}
synchronized (m1) {
for (final PointMatch pm : pm21) {
final Vertex p1=(Vertex)pm.getP1();
final Vertex p2=new Vertex(pm.getP2());
p1.addSpring(p2,new Spring(0,1));
m1.addPassiveVertex(p2);
}
}
return null;
}
}
));
}
for (Future<?> fu : tasks) {
fu.get();
}
tasks.clear();
for (int i=1; i < stack.getSize(); ++i) {
final CoordinateTransformList<CoordinateTransform> ctl=new CoordinateTransformList<CoordinateTransform>();
for (int j=i - 1; j >= 0; --j) ctl.add(transforms[j]);
meshes[i].init(ctl);
}
try {
long t0=System.currentTimeMillis();
IJ.log("String_Node_Str");
SpringMesh.optimizeMeshes(Arrays.asList(meshes),p.maxEpsilon,p.maxIterations,p.maxPlateauwidth);
IJ.log("String_Node_Str" + (System.currentTimeMillis() - t0) + "String_Node_Str");
}
 catch (NotEnoughDataPointsException e) {
e.printStackTrace();
}
final float[] min=new float[2];
final float[] max=new float[2];
for (final SpringMesh mesh : meshes) {
final float[] meshMin=new float[2];
final float[] meshMax=new float[2];
mesh.bounds(meshMin,meshMax);
Util.min(min,meshMin);
Util.max(max,meshMax);
}
for (final SpringMesh mesh : meshes) {
for (final Vertex vertex : mesh.getVertices()) {
final float[] w=vertex.getW();
w[0]-=min[0];
w[1]-=min[1];
}
mesh.updateAffines();
mesh.updatePassiveVertices();
}
final int width=(int)Math.ceil(max[0] - min[0]);
final int height=(int)Math.ceil(max[1] - min[1]);
for (int i=1; i <= stack.getSize(); ++i) {
final TransformMeshMapping<SpringMesh> meshMapping=new TransformMeshMapping<SpringMesh>(meshes[i - 1]);
final ImageProcessor ip=stack.getProcessor(i).createProcessor(width,height);
if (p.interpolate) meshMapping.mapInterpolated(stack.getProcessor(i),ip);
 else meshMapping.map(stack.getProcessor(i),ip);
IJ.save(new ImagePlus("String_Node_Str" + i,ip),"String_Node_Str" + String.format("String_Node_Str",i) + "String_Node_Str");
}
IJ.log("String_Node_Str");
}