Esempio n. 1
0
int main(int argc, char **argv) {

  if(argc!=5){
    printf("Usage: cubeNonMaxSup cube.nfo theta.nfo phi.nfo output\n");
    exit(0);
  }

  Cube< float, double>* orig  = new Cube<float, double>(argv[1]);
  Cube< float, double>* theta = new Cube<float, double>(argv[2]);
  Cube< float, double>* phi   = new Cube<float, double>(argv[3]);
  Cube< float, double>* output;
  // Cube< float, double>* outputOrient;

  string outputName       = argv[4];
  // string outputOrientName = argv[5];
  if(fileExists(outputName)){
    output = new Cube<float, double>(outputName);
  } else {
    output = orig->duplicate_clean(outputName);
  }
  // if(fileExists(outputOrientName)){
    // outputOrient = new Cube<float, double>(outputOrientName);
  // } else {
    // outputOrient = orig->duplicate_clean(outputOrientName);
  // }


  // Loop for all the voxels of the cube. For now we will ignore the borders

  printf("Performing non-maxima-supression[");
#pragma omp parallel for
  for(int z = 1; z < orig->cubeDepth -1; z++){
    int  currOrient = 0;
    bool isMax = false;
    for(int y = 1; y < orig->cubeHeight -1; y++){
      for(int x = 1; x < orig->cubeWidth -1; x++){
        isMax = true;
        currOrient = computeOrientation(theta->at(x,y,z), phi->at(x,y,z));
        // outputOrient->put(x,y,z,currOrient);
        for(int neigh = 0; neigh < 8; neigh++){
          if(orig->at(x+nbrToIdx[perpNeigh[currOrient][neigh]][0],
                      y+nbrToIdx[perpNeigh[currOrient][neigh]][1],
                      z+nbrToIdx[perpNeigh[currOrient][neigh]][2])
             > orig->at(x,y,z)){
            isMax = false;
            break;
          }
        } //Neighbors
        if(isMax){
          output->put(x,y,z, orig->at(x,y,z));
        }
      }
    }
    printf("#"); fflush(stdout);
  }
  printf("]\n");

}
Esempio n. 2
0
int main(int argc, char **argv) {

  if(argc!=7) {
    printf("Usage: kMSTanalyzeDir directory kInit kEnd kStep groundTruth.nfo pp.asc\n");
    exit(0);
  }

  //string directory = "/home/ggonzale/mount/bbpsg1scratch/n2/3d/tree/";
  string directory = argv[1];
  Cube<uchar, ulong>* mask = new Cube<uchar, ulong>(argv[5]);
  Cube<uchar, ulong>* rendered = new Cube<uchar, ulong>(argv[5], false);
  rendered->load_volume_data("", false);
  //Cube<uchar, ulong>* rendered = mask->duplicate_clean("rendered");
  int kInit = atoi(argv[2]);;
  int kEnd  = atoi(argv[3]);
  int kStep = atoi(argv[4]);
  Neuron* gtNeuron = new Neuron(argv[6]);
  char nameGraph[2048];

  vector< vector< double > > toSave;

  //Counts all the negative points in the ground truth
  int negativePoints = 0;
  for(int z = 0; z < mask->cubeDepth; z++)
    for(int y = 0; y < mask->cubeHeight; y++)
      for(int x = 0; x < mask->cubeWidth; x++)
        if(mask->at(x,y,z) == 255)
          negativePoints++;

  double tp = 0;
  double fp = 0;
  double fn = 0;

  if(0){
    Cube<uchar, ulong>* rendered = mask->duplicate_clean("rendered");
    sprintf(nameGraph, "%s/tree/kmsts/kmst%iw.gr", directory.c_str(), 725);
    printf("%s\n", nameGraph);
    Graph< Point3Dw, EdgeW<Point3Dw> >* gr =
      new Graph< Point3Dw, EdgeW<Point3Dw> >(nameGraph);
    evaluateGraph(directory, mask, rendered, gtNeuron, gr, tp, fp, fn);
  }

  if(0){
    for(int k = kInit; k <=kEnd; k+=kStep){
      tp = 0; fp = 0; fn = 0;
      sprintf(nameGraph, "%s/tree/kmsts/kmst%iw.gr", directory.c_str(), k);
      printf("%s\n", nameGraph);
      Graph< Point3Dw, EdgeW<Point3Dw> >* gr =
        new Graph< Point3Dw, EdgeW<Point3Dw> >(nameGraph);
      evaluateGraph(directory, mask, rendered, gtNeuron, gr, tp, fp, fn);
      vector< double > it(5);
      double tn = negativePoints - fp;
      it[0] = k; it[1] = tp; it[2] = fp; it[3] = tn; it[4] = fn;
      toSave.push_back(it);
    }
    saveMatrix(toSave, directory + "/tree/kmsts/evaluation.txt");
  }

  //Evaluatoin of the mst
  if(1){
    toSave.resize(0);
    sprintf(nameGraph, "%s/tree/mstFromCptGraphw.gr", directory.c_str());
    printf("Evaluating the graph: %s\n", nameGraph);
    tp = 0; fp = 0; fn = 0;
    Graph< Point3Dw, EdgeW<Point3Dw> >* gr =
      new Graph< Point3Dw, EdgeW<Point3Dw> >(nameGraph);
    printf("Loaded the graph: %s\n", nameGraph);
    evaluateGraph(directory, mask, rendered, gtNeuron, gr, tp, fp, fn);
    vector< double > it(5);
    double tn = negativePoints - fp;
    it[0] = 0; it[1] = tp; it[2] = fp; it[3] = tn; it[4] = fn;
    toSave.push_back(it);
    saveMatrix(toSave, directory + "/tree/mstFromCptGraphwE.txt");
  }

  if(0){
    toSave.resize(0);
    sprintf(nameGraph, "%s/tree/mst/mstFromCptGraphPrunedw.gr", directory.c_str());
    printf("Evaluating the graph: %s\n", nameGraph);
    tp = 0; fp = 0; fn = 0;
    Graph< Point3Dw, EdgeW<Point3Dw> >* gr =
      new Graph< Point3Dw, EdgeW<Point3Dw> >(nameGraph);
    printf("Loaded the graph: %s\n", nameGraph);
    evaluateGraph(directory, mask, rendered, gtNeuron, gr, tp, fp, fn);
    vector< double > it(5);
    double tn = negativePoints - fp;
    it[0] = 0; it[1] = tp; it[2] = fp; it[3] = tn; it[4] = fn;
    toSave.push_back(it);
    saveMatrix(toSave, directory + "/tree/mst/mstFromCptGraphwPrunedE.txt");
  }
}