コード例 #1
0
ファイル: ListReaderH5.cpp プロジェクト: Aquaveo/MFLib
bool ListReaderH5::GetCellKIJ (T *a_) const
{
  std::pair<int, int> myPair(0, m_nRows);
  VEC_INT_PAIR indices(1, myPair);

  CStr str(m_path);
  str += "/";
  str += CELLIDS;

  H5DataSetReader r(m_file, str, indices);
  CellIdToIJK g(m_nGridRows, m_nGridCols);

  std::vector<int> cellIds(m_nRows, 0);
  if (!r.GetData(&cellIds[0], cellIds.size()))
    return false;

  for (size_t i=0; i<cellIds.size(); i++)
  {
    a_[i*m_nFields] = (T)g.KFromId(cellIds.at(i));
    a_[i*m_nFields+1] = (T)g.IFromId(cellIds.at(i));
    a_[i*m_nFields+2] = (T)g.JFromId(cellIds.at(i));
  }

  return true;
} // ListReaderH5::GetCellKIJ
コード例 #2
0
ファイル: readfields.cpp プロジェクト: tkoskela/vlasiator
/* Read the cellIDs into an array */
std::vector<uint64_t> readCellIds(vlsvinterface::Reader& r) {

   uint64_t arraySize=0;
   uint64_t vectorSize=0;
   uint64_t byteSize=0;
   vlsv::datatype::type dataType;
   std::list<std::pair<std::string,std::string> > attribs;
   attribs.push_back(std::pair<std::string,std::string>("name","CellID"));
   if( r.getArrayInfo("VARIABLE",attribs, arraySize,vectorSize,dataType,byteSize) == false ) {
      std::cerr << "getArrayInfo returned false when trying to read CellID VARIABLE." << std::endl;
      exit(1);
   }

   if(dataType != vlsv::datatype::type::UINT || byteSize != 8 || vectorSize != 1) {
      std::cerr << "Datatype of CellID VARIABLE entries is not uint64_t." << std::endl;
      exit(1);
   }

   /* Allocate memory for the cellIds */
   std::vector<uint64_t> cellIds(arraySize*vectorSize);

   if( r.readArray("VARIABLE",attribs,0,arraySize,(char*) cellIds.data()) == false) {
      std::cerr << "readArray faied when trying to read CellID Variable." << std::endl;
      exit(1);
   }

   return cellIds;
}
コード例 #3
0
void
TolerantEditDistance::extractCells() {

	if (_groundTruth->size() != _reconstruction->size())
		BOOST_THROW_EXCEPTION(SizeMismatchError() << error_message("ground truth and reconstruction have different size") << STACK_TRACE);

	if (_groundTruth->height() != _reconstruction->height() || _groundTruth->width() != _reconstruction->width())
		BOOST_THROW_EXCEPTION(SizeMismatchError() << error_message("ground truth and reconstruction have different size") << STACK_TRACE);

	_depth  = _groundTruth->size();
	_width  = _groundTruth->width();
	_height = _groundTruth->height();

	LOG_ALL(tedlog) << "extracting cells in " << _width << "x" << _height << "x" << _depth << " volume" << std::endl;

	vigra::MultiArray<3, std::pair<float, float> > gtAndRec(vigra::Shape3(_width, _height, _depth));
	vigra::MultiArray<3, unsigned int>             cellIds(vigra::Shape3(_width, _height, _depth));

	// prepare gt and rec image

	for (unsigned int z = 0; z < _depth; z++) {

		boost::shared_ptr<Image> gt  = (*_groundTruth)[z];
		boost::shared_ptr<Image> rec = (*_reconstruction)[z];

		for (unsigned int x = 0; x < _width; x++)
			for (unsigned int y = 0; y < _height; y++) {

				float gtLabel  = (*gt)(x, y);
				float recLabel = (*rec)(x, y);

				gtAndRec(x, y, z) = std::make_pair(gtLabel, recLabel);
			}
	}

	// find connected components in gt and rec image
	cellIds = 0;
	_numCells = vigra::labelMultiArray(gtAndRec, cellIds);

	LOG_DEBUG(tedlog) << "found " << _numCells << " cells" << std::endl;

	// let tolerance function extract cells from that
	_toleranceFunction->extractCells(
			_numCells,
			cellIds,
			*_reconstruction,
			*_groundTruth);

	LOG_ALL(tedlog)
			<< "found "
			<< _toleranceFunction->getGroundTruthLabels().size()
			<< " ground truth labels and "
			<< _toleranceFunction->getReconstructionLabels().size()
			<< " reconstruction labels"
			<< std::endl;
}