Exemple #1
0
ZMatrix* FlyEm::ZBcfSet::load(const vector<string> &name)
{
  ZMatrix *matrix = NULL;
  for (vector<string>::const_iterator iter = name.begin(); iter != name.end();
       ++iter) {
    ZHdf5Reader reader;
    if (reader.open(m_featurePath + "/" + *iter + ".h5")) {
      mylib::Array *array = reader.readArray(*iter);

      if (matrix == NULL) {
        matrix = new ZMatrix(array->dims[0], array->dims[1]);
        matrix->copyValueFrom((double*) array->data);
      } else {
        int oldColumnNumber = matrix->getColumnNumber();
        matrix->resize(matrix->getRowNumber(),
                       matrix->getColumnNumber() + array->dims[1]);
        matrix->copyColumnValueFrom((double*) array->data, oldColumnNumber,
                                array->dims[1]);
      }

      mylib::Kill_Array(array);

      reader.close();
    } else {
      cout << "Failed to open " << *iter << endl;
    }
  }

  return matrix;
}
Exemple #2
0
void ZFlyEmMisc::NormalizeSimmat(ZMatrix &simmat)
{
  for (int j = 0; j < simmat.getColumnNumber(); ++j) {
    double maxC = simmat.getValue(j, j);
    for (int i = 0; i < simmat.getRowNumber(); ++i) {
      if (i != j) {
        double maxR = simmat.getValue(i, i);
        simmat.set(i, j, simmat.getValue(i, j) / dmax2(maxC, maxR));
      }
    }
  }
  simmat.setDiag(1);
}